Example #1
0
        public override void OnInspectorGUI()
        {
            _simulationManager = (SimulationManager)target;

            EditorGUILayout.BeginVertical();
            GUILayout.Label("Simulation Environment:");
            EditorGUI.BeginChangeCheck();
            var env = (SimulationEnvironment)EditorGUILayout.ObjectField(_simulationManager.simulationEnvironment, typeof(SimulationEnvironment), false);

            if (EditorGUI.EndChangeCheck())
            {
                if (env != null)
                {
                    _simulationManager.simulationEnvironment = env;
                }
                EditorUtility.SetDirty(_simulationManager);
            }
            EditorGUILayout.EndVertical();

            if (_simulationManager.simulationEnvironment != null)
            {
                if (GUILayout.Button("Generate Scene"))
                {
                    _simulationManager.SetHolders();
                    // all environment types defined
                    var listDefined      = _simulationManager.typesDefined.Select(t => _simulationManager.typesToDefine[t]).ToList();
                    var typesEnvironment = _simulationManager.simulationEnvironment.types;
                    var allTypesDefined  = typesEnvironment.Intersect(listDefined).Count() == typesEnvironment.Count();
                    if (allTypesDefined)
                    {
                        if (!(_simulationManager.GetHolder(_simulationManager.SIM_OBJECT_HOLDER).childCount > 0))
                        {
                            _simulationManager.GenerateScene();
                        }
                    }
                    else
                    {
                        EditorApplication.Beep();
                        EditorUtility.DisplayDialog("Types Models Missing", "Please define all types Models", "Close");
                    }
                }
                if (GUILayout.Button("Save Environment"))
                {
                    _simulationManager.SaveEnvironment();
                }
            }
            else
            {
                EditorGUILayout.HelpBox("Set a simulation environment first!", MessageType.Warning);
            }

            GUILayout.Space(10);
            DrawDomainField();
            if (_simulationManager.domain == null)
            {
                return;
            }
            GUILayout.Space(15);
            DrawGenericObjectModels();
            GUILayout.Space(15);
            DrawPredicates();
        }