Example #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();
        }
Example #2
0
        void ResetScene()
        {
            ModuleLoaderCore.instance.UnloadModules();
            ModuleLoaderCore.instance.LoadModules();

            m_EnvironmentManager    = ModuleLoaderCore.instance.GetModule <MARSEnvironmentManager>();
            m_QuerySimulationModule = ModuleLoaderCore.instance.GetModule <QuerySimulationModule>();

            if (m_EnvironmentManager == null)
            {
                return;
            }

            SetEnvironmentModeSettings(m_CachedEnvironmentModeSettings);
        }
Example #3
0
        static bool FindTestGameObject(MARSEnvironmentManager envManager, string name)
        {
            var root = envManager.EnvironmentParent;

            Assert.True(root != null);
            for (var i = 0; i < root.transform.childCount; i++)
            {
                var child = root.transform.GetChild(i);
                if (child.name == name)
                {
                    return(true);
                }
            }

            return(false);
        }
        public void InspectorGUI(SerializedObject serializedObject)
        {
            serializedObject.Update();
            EditorGUIUtility.labelWidth = MarsEditorGUI.SettingsLabelWidth;

            using (new EditorGUI.DisabledScope(EditorApplication.isPlayingOrWillChangePlaymode))
            {
                using (var change = new EditorGUI.ChangeCheckScope())
                {
                    EnvironmentMode environmentMode;

                    using (new EditorGUILayout.HorizontalScope())
                    {
                        GUILayout.Label(new GUIContent(m_EnvironmentModeProperty.displayName,
                                                       m_EnvironmentModeProperty.tooltip), GUILayout.Width(MarsEditorGUI.SettingsLabelWidth));

                        environmentMode = (EnvironmentMode)EditorGUILayout.Popup(
                            m_EnvironmentModeProperty.enumValueIndex,
                            MARSEnvironmentManager.ModeTypes, MarsEditorGUI.InternalEditorStyles.Popup);
                    }

                    if (change.changed)
                    {
                        var environmentModule = ModuleLoaderCore.instance.GetModule <MARSEnvironmentManager>();
                        if (environmentModule == null)
                        {
                            m_EnvironmentModeProperty.enumValueIndex = (int)environmentMode;
                            serializedObject.ApplyModifiedProperties();
                        }
                        else if (environmentModule.TrySetModeAndRestartSimulation(environmentMode))
                        {
                            m_EnvironmentModeProperty.enumValueIndex = (int)environmentMode;
                            serializedObject.ApplyModifiedProperties();
                        }
                    }
                }

                switch (m_EnvironmentModeProperty.enumValueIndex)
                {
                case (int)EnvironmentMode.Synthetic:
                    DrawSyntheticEnvironmentGUI(serializedObject);
                    break;

                case (int)EnvironmentMode.Live:
                    DrawLiveVideoGUI();
                    break;

                case (int)EnvironmentMode.Recorded:
                    DrawCapturedVideoGUI(serializedObject);
                    break;

                case (int)EnvironmentMode.Custom:
                    DrawCustomEnvironmentGUI();
                    break;
                }
            }

            EditorGUILayout.Space();
            EditorGUILayout.PropertyField(m_FindAllMatchingDataPerQueryProperty);
            EditorGUILayout.PropertyField(m_TimeToFinalizeQueryDataChangeProperty);

            EditorGUI.BeginChangeCheck();
            EditorGUILayout.PropertyField(m_ShowSimulatedEnvironmentProperty);
            EditorGUILayout.PropertyField(m_ShowSimulatedDataProperty);
            if (EditorGUI.EndChangeCheck())
            {
                MARSEnvironmentManager.SetSimDataVisibility(m_ShowSimulatedDataProperty.boolValue);
                MARSEnvironmentManager.SetSimEnvironmentVisibility(m_ShowSimulatedEnvironmentProperty.boolValue);
            }

            EditorGUILayout.PropertyField(m_AutoResetDevicePoseProperty);
            EditorGUILayout.PropertyField(m_AutoSyncWithSceneChangesProperty);

            serializedObject.ApplyModifiedProperties();
        }
 void IModuleDependency <MARSEnvironmentManager> .ConnectDependency(MARSEnvironmentManager dependency)
 {
     m_EnvironmentManager = dependency;
 }