/// <inheritdoc /> protected override void BuildContextMenu(ref Menu menu, bool extendedMenu) { if (BuildContextMenuItemsStartingFromBaseClass) { base.BuildContextMenu(ref menu, extendedMenu); } if (!ReadOnly && !IsPrefab) { menu.AddSeparatorIfNotRedundant(); menu.Add("Align With NavMesh", AlignWithNavMesh); menu.Add("Align With Ground", AlignWithGround); } menu.AddSeparatorIfNotRedundant(); menu.Add("Snapping", () => SetSnapToGrid(!UsingSnapping), UsingSnapping); menu.Add("Edit Snap Settings...", () => DrawGUI.ExecuteMenuItem("Edit/Snap Settings...")); menu.Add("Use World Space", () => SetUsingLocalSpace(!UsingLocalSpace), !UsingLocalSpace); if (!BuildContextMenuItemsStartingFromBaseClass) { base.BuildContextMenu(ref menu, extendedMenu); } var resetIndex = menu.IndexOf("Reset"); if (resetIndex != -1) { menu.Insert(resetIndex + 1, "Reset Without Affecting Children", ResetWithoutAffectingChildren); } }
private void OnToggleSnapToGridIconRightClicked(IUnityObjectDrawer containingDrawer, Rect buttonRect, Event inputEvent) { var menu = Menu.Create(); menu.Insert(0, "Edit Snap Settings...", () => DrawGUI.ExecuteMenuItem("Edit/Snap Settings...")); ContextMenuUtility.OpenAt(menu, buttonRect, this, (Part)TransformHeaderPart.ToggleSnapToGridButton); }
private static void ShowWelcomeScreen() { showWelcomeScreenErrorsEncountered = false; UnityEngine.Application.logMessageReceived += OnMessageLoggedToConsole; try { DrawGUI.ExecuteMenuItem(PowerInspectorMenuItemPaths.WelcomeScreen); } #if DEV_MODE catch (System.Exception e) { UnityEngine.Debug.LogError(e); #else catch { #endif showWelcomeScreenErrorsEncountered = true; } UnityEngine.Application.logMessageReceived -= OnMessageLoggedToConsole; // if any errors possibly prevented welcome screen from being shown, then don't set WelcomeScreenShown true if (!showWelcomeScreenErrorsEncountered) { EditorPrefs.SetBool("PI.WelcomeScreenShown", true); } }
private static void OpenCreateScriptWizard() { Platform.Active.SetPrefs("PI.CreateScriptWizard/Namespace", InspectorUtility.Preferences.defaultNamespace); Platform.Active.SetPrefs("PI.CreateScriptWizard/SaveIn", InspectorUtility.Preferences.defaultScriptPath); Platform.Active.SetPrefs("PI.CreateScriptWizard/Template", "MonoBehaviour"); Platform.Active.DeletePrefs("PI.CreateScriptWizard/AttachTo"); DrawGUI.ExecuteMenuItem(PowerInspectorMenuItemPaths.CreateScriptWizardFromCreateMenu); }
/// <inheritdoc /> public override bool OnRightClick(Event inputEvent) { if (MouseoveredHeaderPart == (HeaderPart)TransformHeaderPart.ToggleSnapToGridButton) { var menu = Menu.Create(); menu.Insert(0, "Edit Snap Settings...", () => DrawGUI.ExecuteMenuItem("Edit/Snap Settings...")); ContextMenuUtility.OpenAt(menu, ToggleSnapToGridIconPosition, this, (Part)TransformHeaderPart.ToggleSnapToGridButton); return(true); } return(base.OnRightClick(inputEvent)); }
private void OnToggleSnapToGridIconClicked(IUnityObjectDrawer containingDrawer, Rect buttonRect, Event inputEvent) { DrawGUI.Use(inputEvent); if (inputEvent.control) { DrawGUI.ExecuteMenuItem("Edit/Snap Settings..."); } else { SetSnapToGrid(!UsingSnapping); } GUI.changed = true; }
private void OnToggleSnapToGridIconClicked(Event inputEvent) { DrawGUI.Use(inputEvent); if (inputEvent.control) { DrawGUI.ExecuteMenuItem("Edit/Snap Settings..."); } else { SetSnapToGrid(!UsingSnapping); } GUI.changed = true; SelectHeaderPart((HeaderPart)TransformHeaderPart.ToggleSnapToGridButton); }
protected override void BuildContextMenu(ref Menu menu, bool extendedMenu) { if (BuildContextMenuItemsStartingFromBaseClass) { base.BuildContextMenu(ref menu, extendedMenu); } menu.AddSeparatorIfNotRedundant(); menu.Add("Align With Scene View", () => DrawGUI.ExecuteMenuItem("GameObject/Align With View")); if (!BuildContextMenuItemsStartingFromBaseClass) { base.BuildContextMenu(ref menu, extendedMenu); } }
/// <inheritdoc /> public sealed override bool DrawPrefix(Rect position) { bool dirty = base.DrawPrefix(position); if (DrawSnapIcon) { var snapButtonRect = SnappingIconPosition; var settings = InspectorUtility.Preferences; var graphics = settings.graphics; if (Event.current.type == EventType.Repaint) { if (SnappingEnabled) { GUI.DrawTexture(snapButtonRect, graphics.SnappingOnIcon, ScaleMode.StretchToFill); } else { var guiColorWas = GUI.color; var setGuiColor = guiColorWas; setGuiColor.a = 0.5f; GUI.color = setGuiColor; GUI.DrawTexture(snapButtonRect, graphics.SnappingOffIcon, ScaleMode.StretchToFill); GUI.color = guiColorWas; } } if (GUI.Button(snapButtonRect, GUIContent.none, DrawGUI.prefixLabel)) { if (Event.current.button == 0) { ToggleSnapping(); return(true); } if (Event.current.button == 1) { var menu = Menu.Create(); menu.Insert(0, "Edit Snap Settings...", () => DrawGUI.ExecuteMenuItem("Edit/Snap Settings...")); ContextMenuUtility.OpenAt(menu, snapButtonRect, this, (Part)TransformHeaderPart.ToggleSnapToGridButton); return(true); } } } return(dirty); }
/// <inheritdoc/> public override bool Draw(Rect position) { if (!IsOpenInPreferencesInspector) { var buttonRect = position; buttonRect.x += 10f; buttonRect.y += 10f; buttonRect.width = 130f; buttonRect.height = 30f; if (GUI.Button(buttonRect, "Edit Preferences")) { DrawGUI.ExecuteMenuItem(PowerInspectorMenuItemPaths.Preferences); return(true); } return(false); } return(base.Draw(position)); }
/// <inheritdoc /> protected override void BuildContextMenu(ref Menu menu, bool extendedMenu) { if (BuildContextMenuItemsStartingFromBaseClass) { base.BuildContextMenu(ref menu, extendedMenu); } #if UNITY_EDITOR menu.AddSeparatorIfNotRedundant(); #if UNITY_2018_3_OR_NEWER menu.Add("Script Execution Order", () => DrawGUI.ExecuteMenuItem("Edit/Project Settings...")); #else menu.Add("Script Execution Order", () => DrawGUI.ExecuteMenuItem("Edit/Project Settings/Script Execution Order")); #endif menu.Add("Default References", () => editDefaultReferences = !editDefaultReferences); #endif if (!BuildContextMenuItemsStartingFromBaseClass) { base.BuildContextMenu(ref menu, extendedMenu); } }
private static void AddMenuItems(FieldContextMenuItems enabledItems, ref GenericMenu menu, string targetName, [NotNull] Type type, bool editable, [NotNull] GenericMenu.MenuFunction copy, [NotNull] GenericMenu.MenuFunction paste, [CanBeNull] GenericMenu.MenuFunction reset) { bool addSeparator = false; if (enabledItems.HasFlag(FieldContextMenuItems.Reset) && reset != null) { if (editable) { #if DEV_MODE && DEBUG_ADD_MENU_ITEM Debug.Log("Adding Reset to context menu for property \"" + targetName + "\" of type " + type.Name); #endif menu.AddItem(GUIContentPool.Create("Reset"), false, () => { reset(); DrawerUtility.SendResetMessage(StringUtils.SplitPascalCaseToWords(targetName)); }); } else { menu.AddDisabledItem(GUIContentPool.Create("Reset")); } addSeparator = true; } if (enabledItems.HasFlag(FieldContextMenuItems.CopyPaste)) { if (addSeparator) { menu.AddSeparator(""); } addSeparator = true; #if DEV_MODE && DEBUG_ADD_MENU_ITEM Debug.Log("Adding Copy and Paste to context menu for property \"" + targetName + "\" of type " + type.Name); #endif menu.AddItem(GUIContentPool.Create("Copy"), false, () => { copy(); Clipboard.SendCopyToClipboardMessage(targetName); }); if (editable) { if (type.IsUnityObject()) { if (Clipboard.HasObjectReference()) { menu.AddItem(GUIContentPool.Create("Paste"), false, () => { paste(); Clipboard.SendPasteFromClipboardMessage(targetName); }); } else { menu.AddDisabledItem(GUIContentPool.Create("Paste")); } } else if (Clipboard.Content.Length > 0 && Clipboard.CanPasteAs(type)) { menu.AddItem(GUIContentPool.Create("Paste"), false, () => { paste(); Clipboard.SendPasteFromClipboardMessage(targetName); }); } else { menu.AddDisabledItem(GUIContentPool.Create("Paste")); } } } if (enabledItems.HasFlag(FieldContextMenuItems.InspectStaticMembers)) { if (addSeparator) { menu.AddSeparator(""); } menu.AddItem(GUIContentPool.Create("Inspect " + StringUtils.ToStringSansNamespace(type) + " Static Members"), false, () => { var inspector = InspectorUtility.ActiveManager.LastSelectedActiveOrDefaultInspector(); if (inspector == null) { DrawGUI.ExecuteMenuItem(PowerInspectorMenuItemPaths.NewWindow); inspector = InspectorUtility.ActiveManager.LastSelectedActiveOrDefaultInspector(); } inspector.RebuildDrawers(null, type); }); } }
/// <inheritdoc/> protected override void FindReferencesInScene() { DrawGUI.ExecuteMenuItem("CONTEXT/Component/Find References In Scene"); }
/// <inheritdoc/> protected override void FindReferencesInScene() { DrawGUI.ExecuteMenuItem("CONTEXT/Component/Find References In Scene", ArrayPool <Component> .Cast <Object>(targets)); }
public static void OpenNewWindow() { DrawGUI.ExecuteMenuItem(PowerInspectorMenuItemPaths.NewWindow); }
private void OnGUI() { if (!setupDone) { Setup(); } GUILayout.Space(17f); GUILayout.Label("Thank you for choosing", titleStyle); GUILayout.Space(13f); GUILayout.Label(InspectorUtility.Preferences.graphics.PowerInspectorLogo, textStyle); // 326 x 68 was: 346 x 102 -> 34 diff var rect = GUILayoutUtility.GetLastRect(); rect.y += 63f; GUI.Label(rect, "Let's help you get started...", textStyle); GUILayout.Space(58f); GUILayout.BeginHorizontal(); { GUILayout.Space(50f); if (GUILayout.Button(openLabel, largestButtonStyle, GUILayout.Height(40f))) { DrawGUI.ExecuteMenuItem(PowerInspectorMenuItemPaths.NewWindow); GUIUtility.ExitGUI(); } GUILayout.Space(50f); } GUILayout.EndHorizontal(); GUILayout.Space(15f); GUILayout.BeginHorizontal(); { GUILayout.Space(50f); if (GUILayout.Button(documentationLabel, largestButtonStyle, GUILayout.Height(60f))) { DrawGUI.ExecuteMenuItem(PowerInspectorMenuItemPaths.Documentation); GUIUtility.ExitGUI(); } GUILayout.Space(50f); } GUILayout.EndHorizontal(); GUILayout.Space(15f); GUILayout.BeginHorizontal(); { GUILayout.Space(50f); if (GUILayout.Button(preferencesLabel, largerButtonStyle, GUILayout.Height(40f))) { DrawGUI.ExecuteMenuItem(PowerInspectorMenuItemPaths.Preferences); GUIUtility.ExitGUI(); } GUILayout.Space(50f); } GUILayout.EndHorizontal(); GUILayout.Space(15f); GUILayout.BeginHorizontal(); { GUILayout.Space(50f); if (GUILayout.Button(storePageLabel, buttonStyle, GUILayout.Width(90f), GUILayout.Height(50f))) { Application.OpenURL("http://u3d.as/1sNc"); GUIUtility.ExitGUI(); } GUILayout.Space(15f); if (GUILayout.Button(forumsLabel, buttonStyle, GUILayout.Width(90f), GUILayout.Height(50f))) { DrawGUI.ExecuteMenuItem(PowerInspectorMenuItemPaths.Forums); GUIUtility.ExitGUI(); } GUILayout.Space(15f); if (GUILayout.Button(demoSceneLabel, buttonStyle, GUILayout.Width(90f), GUILayout.Height(50f))) { DrawGUI.ExecuteMenuItem(PowerInspectorMenuItemPaths.DemoScene); GUIUtility.ExitGUI(); } GUILayout.Space(50f); } GUILayout.EndHorizontal(); GUILayout.Space(12f); GUILayout.BeginHorizontal(); { GUILayout.FlexibleSpace(); GUILayout.Label(versionNumberLabel, versionNumberStyle); GUILayout.FlexibleSpace(); } GUILayout.EndHorizontal(); }
public bool OnGUI(ref bool addedComponent) { bool dirty = false; var e = Event.current; var eventType = e.type; switch (eventType) { case EventType.KeyDown: if (OnKeyboardInputGiven(e)) { return(true); } break; case EventType.MouseDown: case EventType.MouseMove: dirty = true; break; case EventType.Layout: if (goBackLevelNextLayout) { goBackLevelNextLayout = false; GoBackLevel(); } #if UNITY_EDITOR else if (openCreateNewScriptViewNextLayout) { openCreateNewScriptViewNextLayout = false; string inNamespace = null; string saveIn = null; if (activeItem != null) { var type = activeItem.TypeOrAnyChildType(); if (type != null) { var existingScript = FileUtility.FindScriptFile(type); if (existingScript != null) { inNamespace = type.Namespace; saveIn = FileUtility.GetParentDirectory(UnityEditor.AssetDatabase.GetAssetPath(existingScript)); } } } if (inNamespace == null) { inNamespace = InspectorUtility.Preferences.defaultNamespace; } if (saveIn == null) { saveIn = InspectorUtility.Preferences.defaultScriptPath; } if (filter.Length > 0) { Platform.Active.SetPrefs("PI.CreateScriptWizard/Name", filter); } Platform.Active.SetPrefs("PI.CreateScriptWizard/Namespace", inNamespace); Platform.Active.SetPrefs("PI.CreateScriptWizard/SaveIn", saveIn); Platform.Active.SetPrefs("PI.CreateScriptWizard/Template", "MonoBehaviour"); Platform.Active.SetPrefs("PI.CreateScriptWizard/AttachTo", target.UnityObject.GetInstanceID()); inspector.OnNextLayout(() => DrawGUI.ExecuteMenuItem(PowerInspectorMenuItemPaths.CreateScriptWizardFromCreateMenu)); Close(); return(true); } #endif else if (clearTextNextLayout) { clearTextNextLayout = false; ClearText(); } break; } if (Draw(ref addedComponent)) { dirty = true; } return(dirty); }
/// <inheritdoc/> protected override void FindReferencesInScene() { DrawGUI.ExecuteMenuItem("Assets/Find References In Scene"); }