public static void DoEditModeInspectorModeButton(EditMode.SceneViewEditMode mode, string label, GUIContent icon, Bounds bounds, Editor caller) { if (EditorUtility.IsPersistent(caller.target)) { return; } EditMode.DetectMainToolChange(); if (EditMode.s_EditColliderButtonStyle == null) { EditMode.s_EditColliderButtonStyle = new GUIStyle("Button"); EditMode.s_EditColliderButtonStyle.padding = new RectOffset(0, 0, 0, 0); EditMode.s_EditColliderButtonStyle.margin = new RectOffset(0, 0, 0, 0); } Rect controlRect = EditorGUILayout.GetControlRect(true, 23f, new GUILayoutOption[0]); Rect position = new Rect(controlRect.xMin + EditorGUIUtility.labelWidth, controlRect.yMin, 33f, 23f); GUIContent content = new GUIContent(label); Vector2 vector = GUI.skin.label.CalcSize(content); Rect position2 = new Rect(position.xMax + 5f, controlRect.yMin + (controlRect.height - vector.y) * 0.5f, vector.x, controlRect.height); int instanceID = caller.GetInstanceID(); bool value = EditMode.editMode == mode && EditMode.ownerID == instanceID; EditorGUI.BeginChangeCheck(); bool flag = GUI.Toggle(position, value, icon, EditMode.s_EditColliderButtonStyle); GUI.Label(position2, label); if (EditorGUI.EndChangeCheck()) { EditMode.ChangeEditMode((!flag) ? EditMode.SceneViewEditMode.None : mode, bounds, caller); } }
public static void DoInspectorToolbar(EditMode.SceneViewEditMode[] modes, GUIContent[] guiContents, Bounds bounds, Editor caller) { if (EditorUtility.IsPersistent(caller.target)) { return; } EditMode.DetectMainToolChange(); if (EditMode.s_ToolbarBaseStyle == null) { EditMode.s_ToolbarBaseStyle = "Command"; } int instanceID = caller.GetInstanceID(); int num = ArrayUtility.IndexOf <EditMode.SceneViewEditMode>(modes, EditMode.editMode); if (EditMode.ownerID != instanceID) { num = -1; } EditorGUI.BeginChangeCheck(); int num2 = GUILayout.Toolbar(num, guiContents, EditMode.s_ToolbarBaseStyle, new GUILayoutOption[0]); if (EditorGUI.EndChangeCheck()) { EditMode.SceneViewEditMode mode = (num2 != num) ? modes[num2] : EditMode.SceneViewEditMode.None; EditMode.ChangeEditMode(mode, bounds, caller); } }
public static void DoInspectorToolbar(EditMode.SceneViewEditMode[] modes, GUIContent[] guiContents, Bounds bounds, Editor caller) { if (EditorUtility.IsPersistent(caller.target)) { return; } EditMode.DetectMainToolChange(); if (EditMode.s_ToolbarBaseStyle == null) { EditMode.s_ToolbarBaseStyle = (GUIStyle)"Command"; } int instanceId = caller.GetInstanceID(); int selected = ArrayUtility.IndexOf <EditMode.SceneViewEditMode>(modes, EditMode.editMode); if (EditMode.ownerID != instanceId) { selected = -1; } EditorGUI.BeginChangeCheck(); int index = GUILayout.Toolbar(selected, guiContents, EditMode.s_ToolbarBaseStyle, new GUILayoutOption[0]); if (!EditorGUI.EndChangeCheck()) { return; } EditMode.ChangeEditMode(index != selected ? modes[index] : EditMode.SceneViewEditMode.None, bounds, caller); }
private static void DoInspectorToolbar(EditMode.SceneViewEditMode[] modes, GUIContent[] guiContents, Func <Bounds> getBoundsOfTargets, IToolModeOwner owner) { EditMode.DetectMainToolChange(); int instanceID = owner.GetInstanceID(); int num = ArrayUtility.IndexOf <EditMode.SceneViewEditMode>(modes, EditMode.editMode); if (EditMode.ownerID != instanceID) { num = -1; } EditorGUI.BeginChangeCheck(); int num2 = num; using (new EditorGUI.DisabledScope(!owner.areToolModesAvailable)) { num2 = GUILayout.Toolbar(num, guiContents, EditMode.Styles.multiButtonStyle, new GUILayoutOption[0]); } if (EditorGUI.EndChangeCheck()) { EditMode.SceneViewEditMode mode = (num2 != num) ? modes[num2] : EditMode.SceneViewEditMode.None; EditMode.ChangeEditMode(mode, (getBoundsOfTargets != null) ? getBoundsOfTargets() : owner.GetWorldBoundsOfTargets(), owner); } }
private static void DoEditModeInspectorModeButton(EditMode.SceneViewEditMode mode, string label, GUIContent icon, Func <Bounds> getBoundsOfTargets, IToolModeOwner owner) { EditMode.DetectMainToolChange(); Rect controlRect = EditorGUILayout.GetControlRect(true, 23f, EditMode.Styles.singleButtonStyle, new GUILayoutOption[0]); Rect position = new Rect(controlRect.xMin + EditorGUIUtility.labelWidth, controlRect.yMin, 33f, 23f); GUIContent content = new GUIContent(label); Vector2 vector = GUI.skin.label.CalcSize(content); Rect position2 = new Rect(position.xMax + 5f, controlRect.yMin + (controlRect.height - vector.y) * 0.5f, vector.x, controlRect.height); int instanceID = owner.GetInstanceID(); bool value = EditMode.editMode == mode && EditMode.ownerID == instanceID; EditorGUI.BeginChangeCheck(); bool flag = false; using (new EditorGUI.DisabledScope(!owner.areToolModesAvailable)) { flag = GUI.Toggle(position, value, icon, EditMode.Styles.singleButtonStyle); GUI.Label(position2, label); } if (EditorGUI.EndChangeCheck()) { EditMode.ChangeEditMode((!flag) ? EditMode.SceneViewEditMode.None : mode, (getBoundsOfTargets != null) ? getBoundsOfTargets() : owner.GetWorldBoundsOfTargets(), owner); } }