From 4e1d9b67217bfee4dbfb518620e07698b5b38ad9 Mon Sep 17 00:00:00 2001 From: Thor Brigsted Date: Wed, 26 Jun 2019 10:13:12 +0200 Subject: [PATCH] Reformat RenamePopup.cs Was inconsistently formatted as tabs instead of spaces --- Scripts/Editor/RenamePopup.cs | 106 +++++++++++++++++----------------- 1 file changed, 53 insertions(+), 53 deletions(-) diff --git a/Scripts/Editor/RenamePopup.cs b/Scripts/Editor/RenamePopup.cs index 5a80d59..85d229f 100644 --- a/Scripts/Editor/RenamePopup.cs +++ b/Scripts/Editor/RenamePopup.cs @@ -2,65 +2,65 @@ using UnityEngine; namespace XNodeEditor { - /// Utility for renaming assets - public class RenamePopup : EditorWindow { - public static RenamePopup current { get; private set; } - public Object target; - public string input; + /// Utility for renaming assets + public class RenamePopup : EditorWindow { + public static RenamePopup current { get; private set; } + public Object target; + public string input; - private bool firstFrame = true; + private bool firstFrame = true; - /// Show a rename popup for an asset at mouse position. Will trigger reimport of the asset on apply. - public static RenamePopup Show(Object target, float width = 200) { - RenamePopup window = EditorWindow.GetWindow(true, "Rename " + target.name, true); - if (current != null) current.Close(); - current = window; - window.target = target; - window.input = target.name; - window.minSize = new Vector2(100, 44); - window.position = new Rect(0, 0, width, 44); - GUI.FocusControl("ClearAllFocus"); - window.UpdatePositionToMouse(); - return window; - } + /// Show a rename popup for an asset at mouse position. Will trigger reimport of the asset on apply. + public static RenamePopup Show(Object target, float width = 200) { + RenamePopup window = EditorWindow.GetWindow(true, "Rename " + target.name, true); + if (current != null) current.Close(); + current = window; + window.target = target; + window.input = target.name; + window.minSize = new Vector2(100, 44); + window.position = new Rect(0, 0, width, 44); + GUI.FocusControl("ClearAllFocus"); + window.UpdatePositionToMouse(); + return window; + } - private void UpdatePositionToMouse() { - if (Event.current == null) return; - Vector3 mousePoint = GUIUtility.GUIToScreenPoint(Event.current.mousePosition); - Rect pos = position; - pos.x = mousePoint.x - position.width * 0.5f; - pos.y = mousePoint.y - 10; - position = pos; - } + private void UpdatePositionToMouse() { + if (Event.current == null) return; + Vector3 mousePoint = GUIUtility.GUIToScreenPoint(Event.current.mousePosition); + Rect pos = position; + pos.x = mousePoint.x - position.width * 0.5f; + pos.y = mousePoint.y - 10; + position = pos; + } - private void OnLostFocus() { - // Make the popup close on lose focus - Close(); - } + private void OnLostFocus() { + // Make the popup close on lose focus + Close(); + } - private void OnGUI() { - if (firstFrame) { - UpdatePositionToMouse(); - firstFrame = false; - } - input = EditorGUILayout.TextField(input); - Event e = Event.current; - // If input is empty, revert name to default instead - if (input == null || input.Trim() == "") { - if (GUILayout.Button("Revert to default") || (e.isKey && e.keyCode == KeyCode.Return)) { - target.name = NodeEditorUtilities.NodeDefaultName(target.GetType()); + private void OnGUI() { + if (firstFrame) { + UpdatePositionToMouse(); + firstFrame = false; + } + input = EditorGUILayout.TextField(input); + Event e = Event.current; + // If input is empty, revert name to default instead + if (input == null || input.Trim() == "") { + if (GUILayout.Button("Revert to default") || (e.isKey && e.keyCode == KeyCode.Return)) { + target.name = NodeEditorUtilities.NodeDefaultName(target.GetType()); AssetDatabase.ImportAsset(AssetDatabase.GetAssetPath(target)); Close(); - } - } - // Rename asset to input text - else { - if (GUILayout.Button("Apply") || (e.isKey && e.keyCode == KeyCode.Return)) { - target.name = input; + } + } + // Rename asset to input text + else { + if (GUILayout.Button("Apply") || (e.isKey && e.keyCode == KeyCode.Return)) { + target.name = input; AssetDatabase.ImportAsset(AssetDatabase.GetAssetPath(target)); Close(); - } - } - } - } -} + } + } + } + } +} \ No newline at end of file