コード例 #1
0
        public override void OnInspectorGUI()
        {
            ChildOf cp = (ChildOf)target;

            EditorGUI.BeginChangeCheck();

            EConUtil.DrawActiveLine(cp);

            //constraint target
            cp.Target = (Transform)EditorGUILayout.ObjectField("Target Obj", cp.Target, typeof(Transform), true);

            if (cp.Target && !ConstraintEditorUtil.IsTargetHasAllUniformScaleInHierarchy(cp.Target))
            {
                ConstraintEditorUtil.NonUniformScaleWarning(cp.Target);
            }

            EUtil.DrawSplitter();

            EUtil.PushGUIEnable(cp.IsActiveConstraint && cp.Target);
            {
                //affect X/Y/Z
                m_foldoutAffect.val = EditorGUILayout.Foldout(m_foldoutAffect.val, "Affect");
                if (m_foldoutAffect.val)
                {
                    cp.AffectPos = EConUtil.DrawAxisBtnMask(new GUIContent("Position", "which fields of position are affected"), cp.AffectPos);
                    cp.AffectRot = EConUtil.DrawAxisBtnMask(new GUIContent("Rotation", "which fields of rotation are affected"), cp.AffectRot);
                    cp.AffectSca = EConUtil.DrawAxisBtnMask(new GUIContent("Scale", "which fields of scale are affected"), cp.AffectSca);

                    GUILayout.Space(5f);
                }

                // influence
                cp.Influence = EUtil.ProgressBar(cp.Influence, 0, 1f, "Influence: {0:F2}");
            }
            EUtil.PopGUIEnable();

            var pseuLocTr = cp.PseudoLocTr;

            pseuLocTr.pos   = EUtil.DrawV3P(new GUIContent("position", "the pseudo local position"), pseuLocTr.pos);
            pseuLocTr.rot   = Quaternion.Euler(EUtil.DrawV3P(new GUIContent("rotation", "the pseudo local rotation"), pseuLocTr.rot.eulerAngles));
            pseuLocTr.scale = EUtil.DrawV3P(new GUIContent("scale", "the pseudo local scale"), pseuLocTr.scale);
            EditorGUILayout.BeginHorizontal();
            {
                GUILayout.Space(50f);
                if (GUILayout.Button(new GUIContent("Sample Data", "Use current transform data to calculate the pseudo local transform's data"), EditorStyles.toolbarButton))
                {
                    cp.RecalcPseudoLocalTransformData();
                }
                GUILayout.Space(50f);
            }
            EditorGUILayout.EndHorizontal();

            if (EditorGUI.EndChangeCheck())
            {
                EditorUtility.SetDirty(cp); //so ConstraintStack.Update can be called in edit-mode
            }
        }
コード例 #2
0
        public override void OnInspectorGUI()
        {
            ClampTo cp = (ClampTo)target;

            EditorGUI.BeginChangeCheck();

            EConUtil.DrawActiveLine(cp);

            //constraint target
            cp.Spline = (BaseSplineBehaviour)EditorGUILayout.ObjectField("Target Spline", cp.Spline, typeof(BaseSplineBehaviour), true);

            EUtil.DrawSplitter();

            EUtil.PushGUIEnable(cp.IsActiveConstraint && cp.Spline);
            {
                //axis and offset
                m_foldoutAxis = EditorGUILayout.Foldout(m_foldoutAxis, "Affect");
                if (m_foldoutAxis)
                {
                    cp.MainAxis = (EAxis)EConUtil.DrawEnumBtns(AllAxis, AllAxisStr, cp.MainAxis, "Main Axis", "Choose the axis used to decide the parameter t for evaluate spline");

                    // offset
                    cp.UseOffset = EditorGUILayout.Toggle(new GUIContent("Use Offset", "Add offset onto the result"), cp.UseOffset);
                    if (cp.UseOffset)
                    {
                        cp.Offset = EUtil.DrawV3P(new GUIContent("Offset", "Offset in world space"), cp.Offset);
                    }

                    cp.Cyclic = EditorGUILayout.Toggle(new GUIContent("Cyclic", "the object will revert to the beginning of spline when exceed the dimension"), cp.Cyclic);

                    GUILayout.Space(5f);
                }

                // dimension and startVal
                m_foldoutPos = EditorGUILayout.Foldout(m_foldoutPos, "Pos Define");
                if (m_foldoutPos)
                {
                    cp.Dimension = EditorGUILayout.FloatField(new GUIContent("Dimension", "the projection length on mainAxis"), cp.Dimension);
                    cp.StartVal  = EditorGUILayout.FloatField(new GUIContent("StartVal", "the low value on mainAxis"), cp.StartVal);
                    if (GUILayout.Button(new GUIContent("Recalculate Dimension", "Recalculate dimension & startVal based on spline")))
                    {
                        var    behaviour = cp.Spline;
                        Bounds bd        = behaviour.CalculateTransformedBounds();
                        _SetDimensionByBounds(cp, bd);
                    }
                }

                // influence
                cp.Influence = EUtil.ProgressBar(cp.Influence, 0, 1f, "Influence: {0:F2}");
            }
            EUtil.PopGUIEnable();

            if (EditorGUI.EndChangeCheck())
            {
                EditorUtility.SetDirty(cp); //so ConstraintStack.Update can be called in edit-mode
            }
        }
コード例 #3
0
        public override void OnInspectorGUI()
        {
            if (targets.Length > 1)
            {
                EditorGUILayout.HelpBox("Cannot edit multiple spline together", MessageType.Info, true);
                ms_isMultiEdit = true;
                return;
            }
            else
            {
                ms_isMultiEdit = false;
            }

            CatmullRomCentripetalBehaviour behaviour = (CatmullRomCentripetalBehaviour)target;
            CatmullRomCentripetal          spline    = (CatmullRomCentripetal)behaviour.Spline;

            GUILayout.Space(5f);
            EditorGUILayout.BeginHorizontal();
            {
                if (GUILayout.Button(new GUIContent("Add Point", "hotkey: I"), EditorStyles.toolbarButton))
                {
                    _AddPoint(spline);
                }
                if (GUILayout.Button(new GUIContent("Del Point", "hotkey: X"), EditorStyles.toolbarButton))
                {
                    _DelPoint(spline);
                }
                if (GUILayout.Button(spline.Cycle ? "Break Cycle" : "Make Cycle", EditorStyles.toolbarButton))
                {
                    _ToggleCycle(spline);
                }
            }
            EditorGUILayout.EndHorizontal();
            GUILayout.Space(5f);

            if (m_curPtIdx >= 0)
            {
                EditorGUILayout.BeginHorizontal();
                {
                    MUndo.RecordObject(this, "change current point");
                    GUILayout.Label("Current Point");
                    if (GUILayout.Button("<<"))
                    {
                        m_curPtIdx = Mathf.Max(0, m_curPtIdx - 1);
                    }

                    EditorGUI.BeginChangeCheck();
                    m_curPtIdx = EditorGUILayout.IntField(m_curPtIdx);
                    if (EditorGUI.EndChangeCheck())
                    {
                        m_curPtIdx = Mathf.Clamp(m_curPtIdx, 0, spline.PointCount);
                    }

                    GUILayout.Label(" / " + (spline.PointCount - 1));
                    if (GUILayout.Button(">>"))
                    {
                        m_curPtIdx = Mathf.Min(m_curPtIdx + 1, spline.PointCount - 1);
                    }
                }
                EditorGUILayout.EndHorizontal();

                MUndo.RecordObject(target, "modify control point");
                EUtil.PushLabelWidth(80f);
                spline[m_curPtIdx] = EUtil.DrawV3P(new GUIContent("Position"), spline[m_curPtIdx]);
                spline.SetTilt(m_curPtIdx, EditorGUILayout.FloatField("Tilt", spline.GetTilt(m_curPtIdx)));
                EUtil.PopLabelWidth();
            }

            ms_foldoutSettings = EditorGUILayout.Foldout(ms_foldoutSettings, "Settings");
            if (ms_foldoutSettings)
            {
                MUndo.RecordObject(this, "change setting");
                spline.Resolution = EditorGUILayout.IntField("Point/Seg", spline.Resolution);
                spline.TwistMtd   = (ETwistMethod)EditorGUILayout.EnumPopup(new GUIContent("Twist Method", "Decide how to calculate the base-up direction before applying tilt"), spline.TwistMtd);
                ms_drawArrow      = EditorGUILayout.Toggle("Draw Arrow", ms_drawArrow);
                ms_drawUp         = EditorGUILayout.Toggle("Draw Up", ms_drawUp);
                ms_arrowLineLen   = EditorGUILayout.FloatField("Arrow LineLen", ms_arrowLineLen);

                ms_drawPts = EditorGUILayout.Toggle("Draw points", ms_drawPts);
                ms_ptSize  = EditorGUILayout.FloatField("Point size", ms_ptSize);

                ms_lookAtDist = EditorGUILayout.FloatField(new GUIContent("LookAt dist", "the distance from camera to target point when camera in follow mode"), ms_lookAtDist);
            }

            ms_foldoutTSlider = EditorGUILayout.Foldout(ms_foldoutTSlider, "T slider");
            if (ms_foldoutTSlider)
            {
                EditorGUI.BeginChangeCheck();
                EUtil.PushLabelWidth(20f);
                m_tSlider = EditorGUILayout.Slider("T", m_tSlider, 0, 1f);
                EUtil.PopLabelWidth();
                if (EditorGUI.EndChangeCheck())
                {
                    //Transform tr = behaviour.transform;
                    EUtil.SceneViewLookAt(
                        behaviour.GetTransformedPosition(m_tSlider),
                        Quaternion.LookRotation(behaviour.GetTransformedTangent(m_tSlider), behaviour.GetTransformedUp(m_tSlider)),
                        ms_lookAtDist);
                }
            }

            if (GUI.changed)
            {
                EUtil.RepaintSceneView();
            }
        }
コード例 #4
0
        public override void OnInspectorGUI()
        {
            AngleConstraintMB mb = (AngleConstraintMB)target;

            mb.enabled = EditorGUILayout.Toggle("Enabled", mb.enabled);

            EditorGUI.BeginChangeCheck();
            mb.nextJoint = EditorGUILayout.ObjectField("nextJoint", mb.nextJoint, typeof(Transform), true) as Transform;
            if (EditorGUI.EndChangeCheck())
            {
                EUtil.SetDirty(mb);
                EUtil.RepaintSceneView();
            }

            if (mb.nextJoint == null)
            {
                EditorGUILayout.LabelField("Set the nextJoint first...");
                return;
            }
            else
            {
                EUtil.PushGUIEnable(mb.enabled);

                GUILayout.BeginHorizontal();
                {
                    GUILayout.Space(30f);
                    if (EUtil.Button("ReInit", "decide all the parameters with default method", Color.green))
                    {
                        Undo.RecordObject(mb, "ReInit");
                        mb.AutoSetParameters();
                        EUtil.SetDirty(mb);
                        EUtil.RepaintSceneView();
                    }
                    GUILayout.Space(30f);
                }
                GUILayout.EndHorizontal();

                // min/max limit
                float min = mb.minLimit;
                float max = mb.maxLimit;
                EditorGUI.BeginChangeCheck();
                EUtil.DrawMinMaxSlider("Angle Limits", ref min, ref max, -180f, 180f);
                if (EditorGUI.EndChangeCheck())
                {
                    Undo.RecordObject(mb, "Modify Angle limits");
                    mb.minLimit = min;
                    mb.maxLimit = max;
                    EUtil.SetDirty(mb);
                    EUtil.RepaintSceneView();
                }

                EditorGUI.BeginChangeCheck();
                Vector3 newRotAxis  = EUtil.DrawV3P(new GUIContent("Rotation Axis", "in parent space, in world space if no parent joint"), mb.rotAxis);
                Vector3 newPrimAxis = EUtil.DrawV3P(new GUIContent("Primary Axis", "in parent space, in world space if no parent joint"), mb.primAxis);
                if (EditorGUI.EndChangeCheck())
                {
                    Undo.RecordObject(mb, "Modify Constraint parameters");
                    mb.rotAxis  = newRotAxis;
                    mb.primAxis = newPrimAxis;
                    mb.CalcInitData(); //!! recalc the startLocalRot
                    EUtil.SetDirty(mb);
                    EUtil.RepaintSceneView();
                }

                ms_showDisplaySetting = EditorGUILayout.Foldout(ms_showDisplaySetting, "Display Settings:");
                if (ms_showDisplaySetting)
                {
                    EditorGUI.BeginChangeCheck();
                    ms_markerSize = EditorGUILayout.FloatField("ArcSize", ms_markerSize);
                    ms_arcColor   = EditorGUILayout.ColorField("ArcColor", ms_arcColor);
                    if (EditorGUI.EndChangeCheck())
                    {
                        EUtil.RepaintSceneView();
                    }
                }

                EUtil.PopGUIEnable();
            }
        }
コード例 #5
0
        public override void OnInspectorGUI()
        {
            ConeConstraintMB mb = (ConeConstraintMB)target;

            mb.enabled = EditorGUILayout.Toggle("Enabled", mb.enabled);

            EditorGUI.BeginChangeCheck();
            mb.nextJoint = EditorGUILayout.ObjectField("nextJoint", mb.nextJoint, typeof(Transform), true) as Transform;
            if (EditorGUI.EndChangeCheck())
            {
                EUtil.RepaintSceneView();
            }

            if (mb.nextJoint == null)
            {
                EditorGUILayout.LabelField("Set the nextJoint first...");
                return;
            }
            else
            {
                EUtil.PushGUIEnable(mb.enabled);

                EditorGUILayout.BeginHorizontal();
                {
                    GUILayout.Space(30f);
                    if (EUtil.Button("ReInit", "decide all the parameters with default method", Color.green))
                    {
                        Undo.RecordObject(mb, "AutoInit");
                        mb._AutoSetParameters();
                        EUtil.RepaintSceneView();
                    }
                    GUILayout.Space(30f);
                }
                EditorGUILayout.EndHorizontal();

                // angle limit
                EditorGUI.BeginChangeCheck();
                float newAngleLimit = EditorGUILayout.Slider(CONT_AngleLimit, mb.angleLimit, 0, 180f);
                if (EditorGUI.EndChangeCheck())
                {
                    Undo.RecordObject(mb, "Modify Angle Limit");
                    mb.angleLimit = newAngleLimit;
                    EUtil.RepaintSceneView();
                }

                // ref-Axis
                EditorGUI.BeginChangeCheck();
                Vector3 newRefAxis = EUtil.DrawV3P(CONT_RefAxis, mb.refAxis);
                if (EditorGUI.EndChangeCheck())
                {
                    Undo.RecordObject(mb, "Modify ref axis");
                    mb.refAxis = newRefAxis;
                    mb.CalcInitData(); //!! recalc the startTwistRot
                    EUtil.RepaintSceneView();
                }

                mb.limitTwist = EditorGUILayout.Toggle(CONT_LimitTwist, mb.limitTwist);
                if (mb.limitTwist)
                {
                    float min = mb.minTwistLimit;
                    float max = mb.maxTwistLimit;
                    EditorGUI.BeginChangeCheck();
                    EUtil.DrawMinMaxSlider("Twist Limits", ref min, ref max, -180f, 180f);
                    if (EditorGUI.EndChangeCheck())
                    {
                        Undo.RecordObject(mb, "Modify twist limits");
                        mb.minTwistLimit = min;
                        mb.maxTwistLimit = max;
                        EUtil.RepaintSceneView();
                    }

                    EditorGUILayout.LabelField("Current twist: " + mb.CalcTwist());
                }

                ms_showDisplaySetting = EditorGUILayout.Foldout(ms_showDisplaySetting, "Display Settings:");
                if (ms_showDisplaySetting)
                {
                    EditorGUI.BeginChangeCheck();
                    ms_markerSize  = EditorGUILayout.FloatField("Marker size", ms_markerSize);
                    ms_markerColor = EditorGUILayout.ColorField("Marker color", ms_markerColor);
                    if (EditorGUI.EndChangeCheck())
                    {
                        EUtil.RepaintSceneView();
                    }
                }

                EUtil.PopGUIEnable();
            }
        }
コード例 #6
0
        public override void OnInspectorGUI()
        {
            CopyRotation cp = (CopyRotation)target;

            EditorGUI.BeginChangeCheck();

            EConUtil.DrawActiveLine(cp);

            //constraint target
            cp.Target = (Transform)EditorGUILayout.ObjectField("Target Obj", cp.Target, typeof(Transform), true);

            EUtil.DrawSplitter();

            EUtil.PushGUIEnable(cp.IsActiveConstraint && cp.Target);
            {
                //affect X/Y/Z
                m_foldoutAffect.val = EditorGUILayout.Foldout(m_foldoutAffect.val, "Affect");
                if (m_foldoutAffect.val)
                {
                    EUtil.PushLabelWidth(12f);
                    EUtil.PushFieldWidth(16f);
                    EditorGUILayout.BeginHorizontal();
                    {
                        EAxisD eAffect = cp.Affect;

                        eAffect = EConUtil.DrawAffectField(eAffect, "+X", "apply X from target to owner", EAxisD.X, EAxisD.InvX);
                        eAffect = EConUtil.DrawAffectField(eAffect, "-X", "apply -X from target to owner", EAxisD.InvX, EAxisD.X);
                        eAffect = EConUtil.DrawAffectField(eAffect, "+Y", "apply Y from target to owner", EAxisD.Y, EAxisD.InvY);
                        eAffect = EConUtil.DrawAffectField(eAffect, "-Y", "apply -Y from target to owner", EAxisD.InvY, EAxisD.Y);
                        eAffect = EConUtil.DrawAffectField(eAffect, "+Z", "apply Z from target to owner", EAxisD.Z, EAxisD.InvZ);
                        eAffect = EConUtil.DrawAffectField(eAffect, "-Z", "apply -Z from target to owner", EAxisD.InvZ, EAxisD.Z);

                        cp.Affect = eAffect;
                    }
                    EditorGUILayout.EndHorizontal();
                    EUtil.PopFieldWidth();
                    EUtil.PopLabelWidth();

                    // offset
                    cp.UseOffset = EditorGUILayout.Toggle(new GUIContent("Use Offset", "Add offset onto the result"), cp.UseOffset);
                    if (cp.UseOffset)
                    {
                        cp.Offset = EUtil.DrawV3P(new GUIContent("Offset", "Offset in owner space"), cp.Offset);
                    }

                    GUILayout.Space(5f);
                }


                m_foldoutSpace.val = EditorGUILayout.Foldout(m_foldoutSpace.val, "Space Mapping");
                if (m_foldoutSpace.val)
                {
                    // target space
                    cp.TargetSpace = (ESpace)EditorGUILayout.EnumPopup("Target Space", cp.TargetSpace);

                    // owner space
                    cp.OwnerSpace = (ESpace)EditorGUILayout.EnumPopup("Owner Space", cp.OwnerSpace);
                    GUILayout.Space(5f);
                }

                // influence
                cp.Influence = EUtil.ProgressBar(cp.Influence, 0, 1f, "Influence: {0:F2}");
            }
            EUtil.PopGUIEnable();

            if (EditorGUI.EndChangeCheck())
            {
                EditorUtility.SetDirty(cp); //so ConstraintStack.Update can be called in edit-mode
            }
        }