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
            }
        }
        public override void OnInspectorGUI()
        {
            CopyTransform cp = (CopyTransform)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);
            {
                m_foldoutSpace = EditorGUILayout.Foldout(m_foldoutSpace, "Space Mapping");
                if (m_foldoutSpace)
                {
                    // 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
            }
        }
        public override void OnInspectorGUI()
        {
            TransformMapping cp = (TransformMapping)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);
            {
                //mapping
                m_foldoutMapping = EditorGUILayout.Foldout(m_foldoutMapping, "Mapping");
                if (m_foldoutMapping)
                {
                    //source (from target)
                    ETransformData eSrcType = cp.SrcDataType;
                    EConUtil.DrawChooseTransformData(ref eSrcType, "Src data type", "which data of transform of target is taken as source");
                    cp.SrcDataType = eSrcType;

                    //destination (to owner)
                    ETransformData eDstType = cp.DstDataType;
                    EConUtil.DrawChooseTransformData(ref eDstType, "Dst data type", "which data of transform of target is taken as source");
                    cp.DstDataType = eDstType;

                    // XYZ mapping
                    GUILayout.Label("Source to Destination Mapping:");
                    for (int i = 0; i < 3; ++i)
                    {
                        EditorGUILayout.BeginHorizontal();
                        cp.Mapping[i] = (EAxis)EditorGUILayout.EnumPopup(cp.Mapping[i]);
                        GUILayout.Label(" >> " + (char)('X' + i));
                        EditorGUILayout.EndHorizontal();
                    }

                    // extrapolate
                    cp.Extrapolate = EditorGUILayout.Toggle(new GUIContent("Extrapolate", "will extend the range outside specified range"), cp.Extrapolate);

                    GUILayout.Space(5f);
                }

                //source data range
                m_foldoutSrcRange = EditorGUILayout.Foldout(m_foldoutSrcRange, "Source Range");
                if (m_foldoutSrcRange)
                {
                    Vector3 srcFrom = cp.SrcFrom;
                    Vector3 srcTo   = cp.SrcTo;
                    EConUtil.DrawAxisRange(ref srcFrom, ref srcTo);
                    cp.SrcFrom = srcFrom;
                    cp.SrcTo   = srcTo;
                    GUILayout.Space(5f);
                }

                //dest data range
                m_foldoutDstRange = EditorGUILayout.Foldout(m_foldoutDstRange, "Destination Range");
                if (m_foldoutDstRange)
                {
                    Vector3 dstFrom = cp.DstFrom;
                    Vector3 dstTo   = cp.DstTo;
                    EConUtil.DrawAxisRange(ref dstFrom, ref dstTo);
                    cp.DstFrom = dstFrom;
                    cp.DstTo   = dstTo;
                    GUILayout.Space(5f);
                }

                // space mapping
                m_foldoutSpace = EditorGUILayout.Foldout(m_foldoutSpace, "Space Mapping");
                if (m_foldoutSpace)
                {
                    // 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
            }
        }
示例#4
0
        public override void OnInspectorGUI()
        {
            CopyScale cp = (CopyScale)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)
                {
                    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
            }
        }