Beispiel #1
0
        public override void OnInspectorGUI()
        {
            Floor cp = (Floor)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);
            {
                cp.PlaneDir = (EAxisD)EConUtil.DrawEnumBtns(EConUtil.AxisDs, EConUtil.AxisDStrs, cp.PlaneDir, "Plane Normal", "the normal direction of floor plane");

                // offset
                cp.UseOffset = EditorGUILayout.Toggle(new GUIContent("Use Offset", "Add offset onto the result"), cp.UseOffset);
                if (cp.UseOffset)
                {
                    cp.Offset = EditorGUILayout.FloatField(new GUIContent("Offset", "offset along normal direction"), cp.Offset);
                }

                // raycast
                cp.UseRaycast = EditorGUILayout.Toggle(new GUIContent("Use Raycast", "use raycast to decide contact point"), cp.UseRaycast);

                EditorGUILayout.BeginHorizontal();
                {
                    EUtil.PushLabelWidth(100f);
                    EUtil.PushFieldWidth(20f);
                    cp.Sticky      = EditorGUILayout.Toggle(new GUIContent("Sticky", "Prevent sliding on plane"), cp.Sticky);
                    cp.UseRotation = EditorGUILayout.Toggle(new GUIContent("Use Rotation", "Use the rotation from target object"), cp.UseRotation);
                    EUtil.PopFieldWidth();
                    EUtil.PopLabelWidth();
                }
                EditorGUILayout.EndHorizontal();

                // 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 static void DrawAxisRange(ref Vector3 from, ref Vector3 to)
 {
     EUtil.PushFieldWidth(40f);
     for (int i = 0; i < 3; ++i)
     {
         EditorGUILayout.BeginHorizontal();
         {
             GUILayout.Label(string.Format("{0} Range: <", (char)('X' + i)));
             from[i] = EditorGUILayout.FloatField(from[i]);
             GUILayout.Label(" , ");
             to[i] = EditorGUILayout.FloatField(to[i]);
             GUILayout.Label(">");
         }
         EditorGUILayout.EndHorizontal();
     }
     EUtil.PopFieldWidth();
 }
 public static void DrawActiveLine(BaseConstraint cp)
 {
     EUtil.PushLabelWidth(50f);
     EUtil.PushFieldWidth(30f);
     EditorGUILayout.BeginHorizontal();
     {
         cp.IsActiveConstraint = EditorGUILayout.Toggle(new GUIContent("Active", "whether this constraint is active"), cp.IsActiveConstraint);
         GUILayout.FlexibleSpace();
         if (cp.HasGizmos)
         {
             cp.ShowGizmos = EditorGUILayout.Toggle(new GUIContent("Gizmos", "whether display gizmos for this constraint"), cp.ShowGizmos);
         }
         else
         {
             cp.ShowGizmos = false;
         }
     }
     EditorGUILayout.EndHorizontal();
     EUtil.PopFieldWidth();
     EUtil.PopLabelWidth();
 }
Beispiel #4
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
            }
        }