public static TabSwitcher Create(bool selectNext) { if (trueFocusedWindow) { trueFocusedWindow.Focus(); trueFocusedWindow = null; } guids = FGCodeWindow.GetGuidHistory(); if (guids.Count == 0) { return(null); } items = new GUIContent[guids.Count]; for (var i = 0; i < items.Length; ++i) { var path = AssetDatabase.GUIDToAssetPath(guids[i]); var textBuffer = FGTextBufferManager.TryGetBuffer(path); var fileName = System.IO.Path.GetFileName(path); var name = textBuffer != null && textBuffer.IsModified ? "*" + fileName : fileName; items[i] = new GUIContent(name, AssetDatabase.GetCachedIcon(path), path); } selected = selectNext ? (items.Length > 1 ? 1 : 0) : items.Length - 1; if (!(EditorWindow.focusedWindow is FGCodeWindow)) { selected = 0; } var numRows = Mathf.Min(items.Length, 10); var height = itemHeight * numRows; var width = lastWidth; owner = EditorWindow.focusedWindow; var center = owner.position.center; Rect position = new Rect((int)(center.x - 0.5f * width), (int)(center.y - height * 0.5f), width, height); var window = CreatePopup <TabSwitcher>(); window.hideFlags = HideFlags.HideAndDontSave; #if UNITY_4_0 || UNITY_4_1 || UNITY_4_2 || UNITY_4_3 || UNITY_4_4 || UNITY_4_5 || UNITY_4_6 || UNITY_4_7 || UNITY_5_0 window.title = ""; #else window.titleContent.text = ""; #endif window.minSize = Vector2.one; window.position = position; window.wantsMouseMove = false; window.ShowPopup(); //window.Repaint(); //window.Focus(); //if (window.owner != null) // window.owner.Focus(); EditorApplication.modifierKeysChanged += window.OnModifierKeysChanged; return(window); }
public static IList <string> GetOrReadAllLinesForPath(string assetPath) { if (string.IsNullOrEmpty(assetPath)) { return(null); } string[] lines = null; try { var textBuffer = FGTextBufferManager.TryGetBuffer(assetPath); if (textBuffer != null) { return(textBuffer.lines); } lines = File.ReadAllLines(assetPath); } catch (IOException e) { Debug.LogError(e); return(null); } return(lines); }
public static IList <string> GetOrReadAllLines(string assetGuid) { string[] lines; try { var assetPath = AssetDatabase.GUIDToAssetPath(assetGuid); var textBuffer = FGTextBufferManager.TryGetBuffer(assetPath); if (textBuffer != null) { return(textBuffer.lines); } lines = File.ReadAllLines(assetPath); } catch (IOException e) { Debug.LogError(e); return(null); } return(lines); }