예제 #1
0
        /// <summary>
        /// Draws the inspector
        /// </summary>
        protected override void OnDrawInspectorGUI()
        {
            //base.OnDrawInspectorGUI();

            base.serializedObject.Update();
            //Draw the inputs
            DrawPositionElement();
            DrawRotationElement();
            DrawScaleElement();
            DrawChildrenInfo();

            //Draw the Utilities
            msShowUtilities = LokiEditorStyles.DrawHeader("Transform Utilities");
            if (msShowUtilities)
            {
                DrawUtilities();
            }
            //Validate the transform of this object
            if (!ValidatePosition(((Transform)this.target).position))
            {
                EditorGUILayout.HelpBox(msPositionWarningText, MessageType.Warning);
            }
            //Apply the settings to the object
            this.serializedObject.ApplyModifiedProperties();
            EditorGUIUtility.labelWidth = 0;
        }
예제 #2
0
        private void RotationPropertyField(SerializedProperty rotationProperty, GUIContent content)
        {
            Transform  transform     = (Transform)this.targets[0];
            Quaternion localRotation = transform.localRotation;

            foreach (UnityEngine.Object t in (UnityEngine.Object[]) this.targets)
            {
                if (!SameRotation(localRotation, ((Transform)t).localRotation))
                {
                    EditorGUI.showMixedValue = true;
                    break;
                }
            }

            EditorGUI.BeginChangeCheck();

            Vector3 eulerAngles = LokiEditorStyles.Vector3InputField(content.text, localRotation.eulerAngles);

            //Vector3 eulerAngles = EditorGUILayout.Vector3Field(content, localRotation.eulerAngles);

            if (EditorGUI.EndChangeCheck())
            {
                Undo.RecordObjects(this.targets, "Rotation Changed");
                foreach (UnityEngine.Object obj in this.targets)
                {
                    Transform t = (Transform)obj;
                    t.localEulerAngles = eulerAngles;
                }
                rotationProperty.serializedObject.SetIsDifferentCacheDirty();
            }

            EditorGUI.showMixedValue = false;
        }
예제 #3
0
        /// <summary>
        /// Draws the input for the scale
        /// </summary>
        private void DrawScaleElement()
        {
            if (thinInspectorMode)
            {
                GUILayout.BeginHorizontal();
                EditorGUILayout.LabelField("Scale");
                DrawScaleReset();
                GUILayout.EndHorizontal();
            }
            string label = thinInspectorMode ? "" : "Scale";

            //Scale Layout
            GUILayout.BeginHorizontal();
            EditorGUIUtility.labelWidth      = EditorGUIUtility.currentViewWidth - LokiTransformEditor.FIELD_WIDTH - 64;        // align field to right of inspector
            this.mScaleProperty.vector3Value = LokiEditorStyles.Vector3InputField(label, this.mScaleProperty.vector3Value, false, uniformScaling, uniformScaling);
            if (!thinInspectorMode)
            {
                DrawScaleReset();
            }
            GUILayout.EndHorizontal();
            EditorGUIUtility.labelWidth = 0;
        }
예제 #4
0
        /// <summary>
        /// Draws the input for the position
        /// </summary>
        private void DrawPositionElement()
        {
            if (thinInspectorMode)
            {
                GUILayout.BeginHorizontal();
                EditorGUILayout.LabelField("Position");
                DrawPositionReset();
                GUILayout.EndHorizontal();
            }

            string label = thinInspectorMode ? "" : "Position";

            GUILayout.BeginHorizontal();
            EditorGUIUtility.labelWidth         = EditorGUIUtility.currentViewWidth - LokiTransformEditor.FIELD_WIDTH - 64;     // align field to right of inspector
            this.mPositionProperty.vector3Value = LokiEditorStyles.Vector3InputField(label, this.mPositionProperty.vector3Value);
            if (!thinInspectorMode)
            {
                DrawPositionReset();
            }
            GUILayout.EndHorizontal();
            EditorGUIUtility.labelWidth = 0;
        }