Esempio n. 1
0
        void DrawPlaybackControls()
        {
            //-------------------------------
            //Playback functions
            //-------------------------------

            GUI.enabled = !EditorApplication.isPlaying;

            GUILayout.BeginHorizontal();

            if (GUILayout.Button(new GUIContent(EditorGUIUtility.Load("Obi/RewindButton.psd") as Texture2D, "Rewind"), GUILayout.MaxHeight(24), GUILayout.Width(42)))
            {
                actor.ResetActor();
                if (actor.InSolver)
                {
                    actor.RemoveFromSolver(null);
                }
                accumulatedTime = 0;
            }

            if (GUILayout.Button(new GUIContent(EditorGUIUtility.Load("Obi/StopButton.psd") as Texture2D, "Stop"), GUILayout.MaxHeight(24), GUILayout.Width(42)))
            {
                isPlaying = false;
            }

            if (GUILayout.Button(new GUIContent(EditorGUIUtility.Load("Obi/PlayButton.psd") as Texture2D, "Play"), GUILayout.MaxHeight(24), GUILayout.Width(42)))
            {
                if (!actor.InSolver)
                {
                    actor.AddToSolver(null);
                }

                lastFrameTime = Time.realtimeSinceStartup;
                isPlaying     = true;
            }

            if (GUILayout.Button(new GUIContent(EditorGUIUtility.Load("Obi/StepButton.psd") as Texture2D, "Step forward"), GUILayout.MaxHeight(24), GUILayout.Width(42)))
            {
                isPlaying = false;

                if (!actor.InSolver)
                {
                    actor.AddToSolver(null);
                }

                if (actor.InSolver)
                {
                    actor.Solver.AccumulateSimulationTime(Time.fixedDeltaTime);
                    actor.Solver.SimulateStep(Time.fixedDeltaTime);
                    actor.Solver.EndFrame(Time.fixedDeltaTime);
                }
            }

            GUILayout.EndHorizontal();

            GUI.enabled = true;
        }
Esempio n. 2
0
        /**
         * Draws a window with cloth tools:
         */
        void DrawUIWindow(int windowID)
        {
            //-------------------------------
            // Visualization options
            //-------------------------------
            GUILayout.BeginHorizontal();
            backfaces = GUILayout.Toggle(backfaces, "backfaces");
            GUILayout.EndHorizontal();

            GUILayout.Box("", separatorLine);

            //-------------------------------
            // Tools
            //-------------------------------
            bool customMenu = (CustomUIName() != null);

            GUILayout.BeginHorizontal();
            if (GUILayout.Toggle(tool == EditionTool.SELECT, "Select", GUI.skin.FindStyle("ButtonLeft")) && tool != EditionTool.SELECT)
            {
                tool = EditionTool.SELECT;
                ForceWindowRelayout();
            }
            if (GUILayout.Toggle(tool == EditionTool.SELECTBRUSH, "Brush", GUI.skin.FindStyle("ButtonMid")) && tool != EditionTool.SELECTBRUSH)
            {
                tool = EditionTool.SELECTBRUSH;
                ForceWindowRelayout();
            }
            if (GUILayout.Toggle(tool == EditionTool.PAINT, "Paint", customMenu? GUI.skin.FindStyle("ButtonMid"):GUI.skin.FindStyle("ButtonRight")) && tool != EditionTool.PAINT)
            {
                tool = EditionTool.PAINT;
                ForceWindowRelayout();
            }
            if (customMenu)
            {
                if (GUILayout.Toggle(tool == EditionTool.CUSTOM, CustomUIName(), GUI.skin.FindStyle("ButtonRight")) && tool != EditionTool.CUSTOM)
                {
                    tool = EditionTool.CUSTOM;
                    ForceWindowRelayout();
                }
            }
            GUILayout.EndHorizontal();

            EditorGUI.BeginChangeCheck();
            currentProperty = (ParticleProperty)EditorGUILayout.EnumPopup(currentProperty, GUI.skin.FindStyle("DropDown"));
            if (EditorGUI.EndChangeCheck())
            {
                ParticlePropertyChanged();
            }

            switch (tool)
            {
            case EditionTool.SELECT:
                DrawSelectionToolUI();
                break;

            case EditionTool.SELECTBRUSH:
                GUILayout.BeginHorizontal();
                GUILayout.Label("Radius");
                brushRadius = EditorGUILayout.Slider(brushRadius, 5, 200);
                GUILayout.EndHorizontal();
                DrawSelectionToolUI();
                break;

            case EditionTool.PAINT:
                DrawPaintToolUI();
                break;

            case EditionTool.CUSTOM:
                DrawCustomUI();
                break;
            }

            //-------------------------------
            //Playback functions
            //-------------------------------
            GUILayout.Box("", separatorLine);

            GUILayout.BeginHorizontal();

            GUI.enabled = !EditorApplication.isPlaying;

            if (GUILayout.Button(EditorGUIUtility.Load("RewindButton.psd") as Texture2D, GUILayout.MaxHeight(24), GUILayout.Width(42)))
            {
                actor.ResetActor();
                if (actor.InSolver)
                {
                    actor.RemoveFromSolver(null);
                }
                accumulatedTime = 0;
            }

            if (GUILayout.Button(EditorGUIUtility.Load("StopButton.psd") as Texture2D, GUILayout.MaxHeight(24), GUILayout.Width(42)))
            {
                isPlaying = false;
            }

            if (GUILayout.Button(EditorGUIUtility.Load("PlayButton.psd") as Texture2D, GUILayout.MaxHeight(24), GUILayout.Width(42)))
            {
                if (!actor.InSolver)
                {
                    actor.AddToSolver(null);
                }

                lastFrameTime = Time.realtimeSinceStartup;
                isPlaying     = true;
            }

            if (GUILayout.Button(EditorGUIUtility.Load("StepButton.psd") as Texture2D, GUILayout.MaxHeight(24), GUILayout.Width(42)))
            {
                isPlaying = false;

                if (!actor.InSolver)
                {
                    actor.AddToSolver(null);
                }

                if (actor.InSolver)
                {
                    actor.solver.AccumulateSimulationTime(Time.fixedDeltaTime);
                    actor.solver.SimulateStep(Time.fixedDeltaTime);
                    actor.solver.EndFrame(Time.fixedDeltaTime);
                }
            }

            GUI.enabled = true;

            GUILayout.EndHorizontal();
        }