Search Unity

  1. Unity 2020.1 has been released.
    Dismiss Notice
  2. We are looking for feedback on the experimental Unity Safe Mode which is aiming to help you resolve compilation errors faster during project startup.
    Dismiss Notice
  3. Good news ✨ We have more Unite Now videos available for you to watch on-demand! Come check them out and ask our experts any questions!
    Dismiss Notice

Physics Unit Test

Discussion in 'DOTS Physics' started by MerlinM1S, Sep 10, 2019.

  1. MerlinM1S

    MerlinM1S

    Joined:
    Sep 10, 2019
    Posts:
    1
    Hi,
    I try to perform a simulation step inside a unit test with the following code:

    Code (CSharp):
    1.        
    2. [Test]
    3. public void BasicPhysicsWorldTest() {
    4.     DefaultWorldInitialization.Initialize("Test World", false);
    5.  
    6.     ScriptBehaviourUpdateOrder.UpdatePlayerLoop(null);
    7.  
    8.     World.Active.Update();
    9.  
    10.     ref var physicsWorld = ref World.Active.GetExistingSystem<BuildPhysicsWorld>().PhysicsWorld;
    11.  
    12.     var localPhysicsWorld = (PhysicsWorld)physicsWorld.Clone();
    13.  
    14.     var simulation = new Simulation();
    15.  
    16.     SimulationStepInput stepInput = CreateSimulationStepInput(localPhysicsWorld);
    17.  
    18.     try {
    19.         localPhysicsWorld.CollisionWorld.ScheduleUpdateDynamicLayer(ref localPhysicsWorld, stepInput.TimeStep, stepInput.ThreadCountHint, new JobHandle()).Complete();
    20.  
    21.         simulation.Step(stepInput);
    22.     } finally {
    23.         localPhysicsWorld.Dispose();
    24.         simulation.Dispose();
    25.     }
    26.  
    27.     World.Active.Dispose();
    28. }
    29.  
    However, running the test only results in an exception: "TypeLoadException: Recursive type definition detected"
    Am I doing something wrong or is it impossible to run the simulation step inside a unit test?

    Thanks,
    Markus
     
    Tony_Max likes this.
unityunity