static void setCurrentSystem(MWB_System system)
    {
        s_CurrSystem = system;

        if (s_CurrSystem != null)
        {
            s_SimulatedObjects     = s_CurrSystem.GetObjectList();
            s_SimulatedObjectsName = new List <string>();
            foreach (var obj in s_SimulatedObjects.MWB_Objects)
            {
                s_SimulatedObjectsName.Add(obj.gameObject.name);
            }

            s_CurrSystem.OnSystemBegin          += Instance.onSystemBegin;
            s_CurrSystem.OnSystemUpdateProgress += Instance.onSystemUpdateProgress;
            s_CurrSystem.OnSystemComplete       += Instance.onSystemComplete;

            s_CurrSystem.OnSystemForcedTerminate += Instance.onSystemtTerminate;
        }
        else
        {
            s_SimulatedObjects = null;
            s_SimulatedObjectsName.Clear();
        }

        initAnimationView();
    }
    public static bool EnableMWBEditorMode(MWB_System system)
    {
        if (!EditorApplication.isPlaying)
        {
            SceneView.lastActiveSceneView.ShowNotification(new GUIContent("You can only use MWB Editor Mode in play mode."));
            return(s_IsEnabled);
        }

        Selection.activeGameObject = null;

        //Debug.Log("Enter Editor Mode");

        s_SelectionQuery = MWB_SelectionQuery.Instance;
        s_SelectionQuery.SetCamera(SceneView.lastActiveSceneView.camera);

        SceneView.onSceneGUIDelegate += onSceneGUIDelegate;
        SceneView.lastActiveSceneView.ShowNotification(new GUIContent("Enter MWB Editor Mode"));
        EditorApplication.playModeStateChanged += onPlayModeStateChanged;

        setCurrentSystem(system);

        s_IsEnabled = true;

        SceneView.lastActiveSceneView.Repaint();

        return(s_IsEnabled);
    }
示例#3
0
    public override void OnInspectorGUI()
    {
        MWB_System system = (MWB_System)target;

        GUILayout.BeginVertical();
        {
            //system.TimeStepPerFrame = EditorGUILayout.FloatField(new GUIContent("TimeStepPerFrame"), system.TimeStepPerFrame);
            EditorGUILayout.PropertyField(serializedObject.FindProperty("SimulateFrameCount"), new GUIContent("FrameCount"));
            EditorGUILayout.PropertyField(serializedObject.FindProperty("WorldForkedOnCollision"), new GUIContent("WorldForkedOnCollision"));

            //system.SimulateFrameCount = EditorGUILayout.IntField(new GUIContent("FrameCount"), system.SimulateFrameCount);
            //system.WorldForkedOnCollision = EditorGUILayout.IntField(new GUIContent("WorldForkedOnCollision"), system.WorldForkedOnCollision);

            m_IsInternalFolderShown =
                EditorGUILayout.Foldout(m_IsInternalFolderShown, "Physics Setup", true);

            EditorGUI.indentLevel++;
            if (m_IsInternalFolderShown)
            {
                EditorGUILayout.PropertyField(serializedObject.FindProperty("m_CollisionThresholdCoef"), new GUIContent("Threshold Coefficient"));

                /*serializedObject.FindProperty("m_CollisionThresholdCoef").floatValue =
                 *  EditorGUILayout.FloatField(new GUIContent("Threshold Coefficient"), system.CollisionThresholdCoef);*/
            }
            EditorGUI.indentLevel--;

            if (!Application.isPlaying)
            {
                EditorGUILayout.HelpBox("You can only simulate in play mode.", MessageType.Warning);
            }

            GUILayout.BeginHorizontal();
            {
                GUILayout.FlexibleSpace();

                if (!Application.isPlaying)
                {
                    EditorGUI.BeginDisabledGroup(true);
                }

                if (GUILayout.Button(new GUIContent("Simulate"), GUILayout.Width(150)))
                {
                    system.Simulate();
                }

                if (!Application.isPlaying)
                {
                    EditorGUI.EndDisabledGroup();
                }

                GUILayout.FlexibleSpace();
            }
            GUILayout.EndHorizontal();

            var bgStyle = new GUIStyle();
            bgStyle.normal.background = MakeTex(1, 1, new Color(0.8f, 0.8f, 0.8f));

            GUILayout.BeginVertical(bgStyle);
            {
                drawMWBObjPad();
            }
            GUILayout.EndVertical();
        }
        GUILayout.EndVertical();

        // Apply changes to the serializedProperty - always do this at the end of OnInspectorGUI.
        serializedObject.ApplyModifiedProperties();
    }