Пример #1
0
        public override void OnInspectorGUI()
        {
            if (actor.ropeBlueprint != null && pathEditor == null)
            {
                pathEditor = new ObiPathEditor(actor.ropeBlueprint, actor.ropeBlueprint.path, false);
            }

            if (editLabelStyle == null)
            {
                editLabelStyle           = new GUIStyle(GUI.skin.label);
                editLabelStyle.alignment = TextAnchor.MiddleLeft;
            }

            serializedObject.UpdateIfRequiredOrScript();

            if (pathEditor != null)
            {
                pathEditor.ResizeCPArrays();
            }

            using (new EditorGUI.DisabledScope(editMode))
            {
                EditorGUI.BeginChangeCheck();
                EditorGUILayout.PropertyField(ropeBlueprint, new GUIContent("Blueprint"));
                if (EditorGUI.EndChangeCheck())
                {
                    foreach (var t in targets)
                    {
                        (t as ObiRope).RemoveFromSolver();
                        (t as ObiRope).ClearState();
                    }
                    serializedObject.ApplyModifiedProperties();
                    foreach (var t in targets)
                    {
                        (t as ObiRope).AddToSolver();
                    }
                }
            }

            DoEditButton();


            if (actor.sourceBlueprint != null && actor.ropeBlueprint.path.ControlPointCount < 2)
            {
                actor.ropeBlueprint.GenerateImmediate();
            }

            EditorGUILayout.Space();
            EditorGUILayout.LabelField("Collisions", EditorStyles.boldLabel);
            EditorGUILayout.PropertyField(collisionMaterial, new GUIContent("Collision material"));
            EditorGUILayout.PropertyField(selfCollisions, new GUIContent("Self collisions"));

            EditorGUILayout.Space();
            ObiEditorUtils.DoToggleablePropertyGroup(tearingEnabled, new GUIContent("Tearing"),
                                                     () =>
            {
                EditorGUILayout.PropertyField(tearResistanceMultiplier, new GUIContent("Tear resistance"));
                EditorGUILayout.PropertyField(tearRate, new GUIContent("Tear rate"));
            });
            ObiEditorUtils.DoToggleablePropertyGroup(distanceConstraintsEnabled, new GUIContent("Distance Constraints", Resources.Load <Texture2D>("Icons/ObiDistanceConstraints Icon")),
                                                     () =>
            {
                EditorGUILayout.PropertyField(stretchingScale, new GUIContent("Stretching scale"));
                EditorGUILayout.PropertyField(stretchCompliance, new GUIContent("Stretch compliance"));
                EditorGUILayout.PropertyField(maxCompression, new GUIContent("Max compression"));
            });

            ObiEditorUtils.DoToggleablePropertyGroup(bendConstraintsEnabled, new GUIContent("Bend Constraints", Resources.Load <Texture2D>("Icons/ObiBendConstraints Icon")),
                                                     () =>
            {
                EditorGUILayout.PropertyField(bendCompliance, new GUIContent("Bend compliance"));
                EditorGUILayout.PropertyField(maxBending, new GUIContent("Max bending"));
            });


            if (GUI.changed)
            {
                serializedObject.ApplyModifiedProperties();
            }
        }
Пример #2
0
        public override void OnInspectorGUI()
        {
            if (actor.rodBlueprint != null && pathEditor == null)
            {
                pathEditor = new ObiPathEditor(actor.rodBlueprint, actor.rodBlueprint.path, true);
            }

            if (editLabelStyle == null)
            {
                editLabelStyle           = new GUIStyle(GUI.skin.label);
                editLabelStyle.alignment = TextAnchor.MiddleLeft;
            }

            serializedObject.UpdateIfRequiredOrScript();

            if (pathEditor != null)
            {
                pathEditor.ResizeCPArrays();
            }

            using (new EditorGUI.DisabledScope(editMode))
            {
                EditorGUI.BeginChangeCheck();
                EditorGUILayout.PropertyField(rodBlueprint, new GUIContent("Blueprint"));
                if (EditorGUI.EndChangeCheck())
                {
                    foreach (var t in targets)
                    {
                        (t as ObiRod).RemoveFromSolver();
                        (t as ObiRod).ClearState();
                    }
                    serializedObject.ApplyModifiedProperties();
                    foreach (var t in targets)
                    {
                        (t as ObiRod).AddToSolver();
                    }
                }
            }

            DoEditButton();


            if (actor.rodBlueprint != null && actor.rodBlueprint.path.ControlPointCount < 2)
            {
                actor.rodBlueprint.GenerateImmediate();
            }

            EditorGUILayout.Space();
            EditorGUILayout.LabelField("Collisions", EditorStyles.boldLabel);
            EditorGUILayout.PropertyField(collisionMaterial, new GUIContent("Collision material"));
            EditorGUILayout.PropertyField(selfCollisions, new GUIContent("Self collisions"));
            EditorGUILayout.PropertyField(surfaceCollisions, new GUIContent("Surface-based collisions"));

            EditorGUILayout.Space();
            ObiEditorUtils.DoToggleablePropertyGroup(stretchShearConstraintsEnabled, new GUIContent("StretchShear Constraints", Resources.Load <Texture2D>("Icons/ObiStretchShearConstraints Icon")),
                                                     () => {
                EditorGUILayout.PropertyField(stretchCompliance, new GUIContent("Stretch compliance"));
                EditorGUILayout.PropertyField(shear1Compliance, new GUIContent("Shear compliance 1"));
                EditorGUILayout.PropertyField(shear2Compliance, new GUIContent("Shear compliance 2"));
            });

            ObiEditorUtils.DoToggleablePropertyGroup(bendTwistConstraintsEnabled, new GUIContent("Bend Twist Constraints", Resources.Load <Texture2D>("Icons/ObiBendTwistConstraints Icon")),
                                                     () => {
                EditorGUILayout.PropertyField(torsionCompliance, new GUIContent("Torsion compliance"));
                EditorGUILayout.PropertyField(bend1Compliance, new GUIContent("Bend compliance 1"));
                EditorGUILayout.PropertyField(bend2Compliance, new GUIContent("Bend compliance 2"));
                EditorGUILayout.PropertyField(plasticYield, new GUIContent("Plastic yield"));
                EditorGUILayout.PropertyField(plasticCreep, new GUIContent("Plastic creep"));
            });

            ObiEditorUtils.DoToggleablePropertyGroup(chainConstraintsEnabled, new GUIContent("Chain Constraints", Resources.Load <Texture2D>("Icons/ObiChainConstraints Icon")),
                                                     () => {
                EditorGUILayout.PropertyField(tightness, new GUIContent("Tightness"));
            });


            if (GUI.changed)
            {
                serializedObject.ApplyModifiedProperties();
            }
        }
        public override void OnInspectorGUI()
        {
            if (actor.rodBlueprint != null && pathEditor == null)
            {
                pathEditor = new ObiPathEditor(actor.rodBlueprint, actor.rodBlueprint.path, true);
            }

            if (editLabelStyle == null)
            {
                editLabelStyle           = new GUIStyle(GUI.skin.label);
                editLabelStyle.alignment = TextAnchor.MiddleLeft;
            }

            serializedObject.UpdateIfRequiredOrScript();

            if (pathEditor != null)
            {
                pathEditor.ResizeCPArrays();
            }

            EditorGUI.BeginChangeCheck();
            EditorGUILayout.PropertyField(rodBlueprint, new GUIContent("Blueprint"));
            if (EditorGUI.EndChangeCheck())
            {
                foreach (var t in targets)
                {
                    (t as ObiRod).RemoveFromSolver();
                    (t as ObiRod).ClearState();
                }
                serializedObject.ApplyModifiedProperties();
                foreach (var t in targets)
                {
                    (t as ObiRod).AddToSolver();
                }
            }

            EditorGUILayout.BeginHorizontal();
            GUILayout.Space(EditorGUIUtility.labelWidth);
            EditorGUI.BeginChangeCheck();
            Tools.hidden = editMode = GUILayout.Toggle(editMode, new GUIContent(Resources.Load <Texture2D>("EditCurves")), "Button", GUILayout.MaxWidth(36), GUILayout.MaxHeight(24));
            EditorGUILayout.LabelField("Edit path", editLabelStyle, GUILayout.ExpandHeight(true), GUILayout.MaxHeight(24));
            if (EditorGUI.EndChangeCheck())
            {
                SceneView.RepaintAll();
            }
            EditorGUILayout.EndHorizontal();


            if (actor.rodBlueprint != null && actor.rodBlueprint.path.ControlPointCount < 2)
            {
                actor.rodBlueprint.GenerateImmediate();
            }

            EditorGUILayout.Space();
            EditorGUILayout.LabelField("Collisions", EditorStyles.boldLabel);
            EditorGUILayout.PropertyField(collisionMaterial, new GUIContent("Collision material"));
            EditorGUILayout.PropertyField(selfCollisions, new GUIContent("Self collisions"));

            EditorGUILayout.Space();
            ObiEditorUtils.DoToggleablePropertyGroup(stretchShearConstraintsEnabled, new GUIContent("StretchShear Constraints", Resources.Load <Texture2D>("Icons/ObiStretchShearConstraints Icon")),
                                                     () => {
                EditorGUILayout.PropertyField(stretchCompliance, new GUIContent("Stretch compliance"));
                EditorGUILayout.PropertyField(shear1Compliance, new GUIContent("Shear compliance 1"));
                EditorGUILayout.PropertyField(shear2Compliance, new GUIContent("Shear compliance 2"));
            });

            ObiEditorUtils.DoToggleablePropertyGroup(bendTwistConstraintsEnabled, new GUIContent("Bend Twist Constraints", Resources.Load <Texture2D>("Icons/ObiBendTwistConstraints Icon")),
                                                     () => {
                EditorGUILayout.PropertyField(torsionCompliance, new GUIContent("Torsion compliance"));
                EditorGUILayout.PropertyField(bend1Compliance, new GUIContent("Bend compliance 1"));
                EditorGUILayout.PropertyField(bend2Compliance, new GUIContent("Bend compliance 2"));
            });

            ObiEditorUtils.DoToggleablePropertyGroup(chainConstraintsEnabled, new GUIContent("Chain Constraints", Resources.Load <Texture2D>("Icons/ObiChainConstraints Icon")),
                                                     () => {
                EditorGUILayout.PropertyField(tightness, new GUIContent("Tightness"));
            });


            if (GUI.changed)
            {
                serializedObject.ApplyModifiedProperties();
            }
        }