public static void HandleFrame(IFrame frame, GUISkin skin, float numPixelsIndentation = 0.0f, bool includeFrameToolIfPresent = true) { bool guiWasEnabled = UnityEngine.GUI.enabled; using (new Indent(numPixelsIndentation)) { UnityEngine.GUI.enabled = true; GameObject newParent = (GameObject)EditorGUILayout.ObjectField(MakeLabel("Parent"), frame.Parent, typeof(GameObject), true); UnityEngine.GUI.enabled = guiWasEnabled; if (newParent != frame.Parent) { frame.SetParent(newParent); } frame.LocalPosition = Vector3Field(MakeLabel("Local position"), frame.LocalPosition, skin.label); // Converting from quaternions to Euler - make sure the actual Euler values has // changed before updating local rotation to not mess up the undo stack. Vector3 inputEuler = frame.LocalRotation.eulerAngles; Vector3 outputEuler = Vector3Field(MakeLabel("Local rotation"), inputEuler, skin.label); if (!ValueType.Equals(inputEuler, outputEuler)) { frame.LocalRotation = Quaternion.Euler(outputEuler); } Separator(); Tools.FrameTool frameTool = null; if (includeFrameToolIfPresent && (frameTool = Tools.FrameTool.FindActive(frame)) != null) { using (new Indent(12)) frameTool.OnPreTargetMembersGUI(skin); } } }
public static void HandleFrames(IFrame[] frames, float numPixelsIndentation = 0.0f, bool includeFrameToolIfPresent = true) { var skin = InspectorEditor.Skin; bool guiWasEnabled = UnityEngine.GUI.enabled; var refFrame = frames[0]; using (new Indent(numPixelsIndentation)) { UnityEngine.GUI.enabled = true; EditorGUI.showMixedValue = frames.Any(frame => !Equals(refFrame.Parent, frame.Parent)); GameObject newParent = (GameObject)EditorGUILayout.ObjectField(MakeLabel("Parent"), refFrame.Parent, typeof(GameObject), true); EditorGUI.showMixedValue = false; UnityEngine.GUI.enabled = guiWasEnabled; if (newParent != refFrame.Parent) { foreach (var frame in frames) { frame.SetParent(newParent); } } UnityEngine.GUI.changed = false; EditorGUI.showMixedValue = frames.Any(frame => !Equals(refFrame.LocalPosition, frame.LocalPosition)); var localPosition = Vector3Field(MakeLabel("Local position"), refFrame.LocalPosition, skin.label); if (UnityEngine.GUI.changed) { foreach (var frame in frames) { frame.LocalPosition = localPosition; } UnityEngine.GUI.changed = false; } EditorGUI.showMixedValue = false; // Converting from quaternions to Euler - make sure the actual Euler values has // changed before updating local rotation to not mess up the undo stack. Vector3 inputEuler = refFrame.LocalRotation.eulerAngles; EditorGUI.showMixedValue = frames.Any(frame => !Equals(refFrame.LocalRotation, frame.LocalRotation)); Vector3 outputEuler = Vector3Field(MakeLabel("Local rotation"), inputEuler, skin.label); if (!Equals(inputEuler, outputEuler)) { foreach (var frame in frames) { frame.LocalRotation = Quaternion.Euler(outputEuler); } UnityEngine.GUI.changed = false; } EditorGUI.showMixedValue = false; Separator(); Tools.FrameTool frameTool = frames.Length == 1 && includeFrameToolIfPresent? Tools.FrameTool.FindActive(refFrame) : null; if (frameTool != null) { using (new Indent(12)) frameTool.OnPreTargetMembersGUI(); } } }