Esempio n. 1
0
        public void Setup()
        {
            MARSSession.TestMode           = true;
            QuerySimulationModule.TestMode = true;
            m_TestSimulationUser           = ScriptableObject.CreateInstance <TestSimulationUser>();
            MARSSession.EnsureSessionInActiveScene();

            var moduleLoader = ModuleLoaderCore.instance;

            moduleLoader.GetModule <SimulationSceneModule>().RegisterSimulationUser(m_TestSimulationUser);
            moduleLoader.GetModule <SceneWatchdogModule>().ScenePoll();

            EditorWindow.GetWindow <SimulationView>(); // Tests will fail if a Simulation isn't open.

            m_EnvironmentManager            = moduleLoader.GetModule <MARSEnvironmentManager>();
            m_CachedEnvironmentModeSettings = m_EnvironmentManager.CustomModeSettings;
            m_CachedEnvironmentMode         = SimulationSettings.instance.EnvironmentMode;

            m_TestModeSettings.Clear();
            var testModeA = ScriptableObject.CreateInstance <TestSimulationEnvironmentModeSettings>();

            testModeA.TestDefaultSimulationMode = SimulationModeSelection.TemporalMode;
            testModeA.TestIsFramingEnabled      = false;
            testModeA.TestEnvironmentModeName   = "TestSimulationEnvironmentModeSettings_testModeA";
            m_TestModeSettings.Add(testModeA.EnvironmentModeName, testModeA);

            var testModeB = ScriptableObject.CreateInstance <TestSimulationEnvironmentModeSettings>();

            testModeB.TestDefaultSimulationMode = SimulationModeSelection.SingleFrameMode;
            testModeA.TestIsFramingEnabled      = true;
            testModeB.TestEnvironmentModeName   = "TestSimulationEnvironmentModeSettings_testModeB";
            m_TestModeSettings.Add(testModeB.EnvironmentModeName, testModeB);

            ResetScene();
        }
Esempio n. 2
0
        static void OnSceneLoaded(Scene scene, LoadSceneMode mode)
        {
            // List is cleared by GetInstances
            SubsystemManager.GetInstances(k_MarsXRSubsystems);
            var anyMarsSubsystemsRunning = false;

            foreach (var subsystem in k_MarsXRSubsystems)
            {
                if (subsystem.running)
                {
                    anyMarsSubsystemsRunning = true;
                    break;
                }
            }

            if (anyMarsSubsystemsRunning)
            {
                MARSSession.EnsureSessionInActiveScene();
            }
        }
        public IEnumerator Setup()
        {
            MARSSession.TestMode = true;

            ResetScene();

            m_Module = ScriptableObject.CreateInstance <TestModule>();
            // Setup 2 parents with 1 child each
            m_Parent1 = new GameObject {
                name = "Parent 1"
            }.transform;
            var child1 = new GameObject {
                name = "Child 1"
            }.transform;

            child1.SetParent(m_Parent1);

            m_Parent2 = new GameObject {
                name = "Parent 2"
            }.transform;
            var child2 = new GameObject {
                name = "Child 2"
            }.transform;

            child2.SetParent(m_Parent2);

            // Setup MARS entities and session
            m_Parent1.gameObject.AddComponent <Proxy>();
            m_Parent2.gameObject.AddComponent <Proxy>();

            MARSSession.EnsureSessionInActiveScene();

            var moduleLoader = ModuleLoaderCore.instance;

            moduleLoader.GetModule <SimulationSceneModule>().RegisterSimulationUser(m_Module);
            moduleLoader.GetModule <SceneWatchdogModule>().ScenePoll();

            // Open simulation view and hierarchy panel in a window
            EditorWindow.GetWindow <SimulationView>();
            m_ContentHierarchyPanel = ScriptableObject.CreateInstance <ContentHierarchyPanel>();
            m_HierarchyWindow       = ScriptableObject.CreateInstance <SinglePanelWindow>();
            m_HierarchyWindow.InitWindow(m_ContentHierarchyPanel);
            m_HierarchyWindow.Show();

            // Change to synthetic type environment
            SimulationSettings.instance.EnvironmentMode = EnvironmentMode.Synthetic;

            // Load an environment
            moduleLoader.GetModule <MARSEnvironmentManager>().RefreshEnvironment();
            var querySimModule = moduleLoader.GetModule <QuerySimulationModule>();

            querySimModule.SimulateOneShot();
            while (querySimModule.simulating)
            {
                yield return(null);
            }

            GetCopies();

            // Expand root (parent of parent 1)
            m_ContentHierarchyPanel.HierarchyTreeView.SetExpanded(m_Parent1Copy.parent.gameObject.GetInstanceID(), true);

            // Expand parent 1, collapse parent 2
            m_ContentHierarchyPanel.HierarchyTreeView.SetExpanded(m_Parent1Copy.gameObject.GetInstanceID(), true);
            m_ContentHierarchyPanel.HierarchyTreeView.SetExpanded(m_Parent2Copy.gameObject.GetInstanceID(), false);

            // Select parent2, deselect everything else
            var newSelection = new List <UnityObject>();

            newSelection.Add(m_Parent2Copy.gameObject);
            m_PreviousSelection = Selection.objects;
            Selection.objects   = newSelection.ToArray();
        }