//----------------------------------------------------------------------------- private void DrawTransformScale() { using (new EditorGUILayout.HorizontalScope()) { bool reset = GUILayout.Button("R", this.btnSmall); GUILayoutOption option = GUILayout.MinWidth(63); if (this.IsLocal) { EditorGUILayout.PropertyField(this.scale.FindPropertyRelative("x"), option); EditorGUILayout.PropertyField(this.scale.FindPropertyRelative("y"), option); EditorGUILayout.PropertyField(this.scale.FindPropertyRelative("z"), option); } else { Vector3 scale = this.transform.lossyScale; this.FloatField("X", ref scale.x, option); this.FloatField("Y", ref scale.y, option); this.FloatField("Z", ref scale.z, option); } if (GUILayout.Button("C", this.btnSmall) && this.IsLocal) { TransformEditor.copyScale = Selection.activeTransform.localScale; } if (GUILayout.Button("V", this.btnSmall) && this.IsLocal) { if (TransformEditor.copyScale.HasValue) { ExtensionTools.RegisterUndo("Paste Scale", this.serializedObject.targetObjects); Selection.activeTransform.localScale = TransformEditor.copyScale.Value; } } if (reset) { if (this.IsLocal) { ExtensionTools.RegisterUndo("Reset Scale", this.serializedObject.targetObjects); this.scale.vector3Value = Vector3.one; } GUIUtility.keyboardControl = 0; } } }
//----------------------------------------------------------------------------- private void DrawTransformRotation() { using (new EditorGUILayout.HorizontalScope()) { bool reset = GUILayout.Button("R", this.btnSmall); GUILayoutOption option = GUILayout.MinWidth(63); Vector3 euler = this.IsLocal ? (this.serializedObject.targetObject as Transform).localRotation.eulerAngles : (this.serializedObject.targetObject as Transform).rotation.eulerAngles; euler = this.WrapAngle(euler); Axes changed = this.CheckDifference(this.rot); Axes altered = Axes.None; if (this.FloatField("X", ref euler.x, option)) { altered |= Axes.X; } if (this.FloatField("Y", ref euler.y, option)) { altered |= Axes.Y; } if (this.FloatField("Z", ref euler.z, option)) { altered |= Axes.Z; } if (GUILayout.Button("C", this.btnSmall)) { TransformEditor.copyRotation = this.IsLocal ? Selection.activeTransform.localRotation : Selection.activeTransform.rotation; } if (GUILayout.Button("V", this.btnSmall)) { if (TransformEditor.copyRotation.HasValue) { ExtensionTools.RegisterUndo("Paste Rotation", this.serializedObject.targetObjects); if (this.IsLocal) { Selection.activeTransform.localRotation = TransformEditor.copyRotation.Value; } else { Selection.activeTransform.rotation = TransformEditor.copyRotation.Value; } } } if (reset) { ExtensionTools.RegisterUndo("Reset Rotation", this.serializedObject.targetObjects); if (this.IsLocal) { this.rot.quaternionValue = Quaternion.identity; this.transform.localEulerAngles = Vector3.zero; } else { this.transform.rotation = Quaternion.identity; this.transform.eulerAngles = Vector3.zero; } GUIUtility.keyboardControl = 0; } if (altered != Axes.None) { ExtensionTools.RegisterUndo("Changed Rotation", this.serializedObject.targetObjects); foreach (UnityEngine.Object obj in this.serializedObject.targetObjects) { Transform t = obj as Transform; Vector3 v; v = this.IsLocal ? t.localEulerAngles : t.eulerAngles; if ((altered & Axes.X) != 0) { v.x = euler.x; } if ((altered & Axes.Y) != 0) { v.y = euler.y; } if ((altered & Axes.Z) != 0) { v.z = euler.z; } if (this.IsLocal) { t.localEulerAngles = v; } else { t.eulerAngles = v; } } } } }