// 左侧脚本列表 bool DrawScriptList() { GUILayout.BeginArea(new Rect(_margin, _margin, _scriptTreeWidth, _currentWindow.position.height - _margin * 2), GUI.skin.GetStyle("AS TextArea")); _scriptListScrollPos = EditorGUILayout.BeginScrollView(_scriptListScrollPos); if (GUILayout.Button("添加脚本", GUILayout.ExpandWidth(true))) { EditorAddTutorialScript.Open(this, new Vector2(_scriptTreeWidth, _margin), _buttonWidth); } EditorGUILayout.Space(); // 所有脚本列表 foreach (var pair in _scriptGroupFileInfos) { var key = pair.Key; var list = pair.Value; bool foldout = _scriptGroupOpen[key]; if (list.Count > 0) { _scriptGroupOpen[key] = EditorGUILayout.Foldout(_scriptGroupOpen[key], key.Trim('/')); } else { _scriptGroupOpen[key] = false; } if (_scriptGroupOpen[key]) { if (foldout == false) { _selectedScriptIndex = 0; _currentScript = null; } SetCurrentKey(key); var files = new string[list.Count]; for (int i = 0; i < list.Count; ++i) { files[i] = list[i].FullName.Replace("\\", "/").Replace(Application.dataPath.Replace("\\", "/") + "/", "") .Replace(".json", "").Replace(key, "").Replace(TutorialManager.TutorialScriptPath, "").Trim('/'); } var oldIndex = _selectedScriptIndex; _selectedScriptIndex = GUILayout.SelectionGrid(_selectedScriptIndex, files, 1); if (oldIndex != _selectedScriptIndex) { _currentScript = null; } } } PrepareCurrentScript(); EditorGUILayout.EndScrollView(); GUILayout.EndArea(); return(false); }
public static void Open(EditorTutorialScripts owner, Vector2 position, float buttonWidth) { var rect = new Rect(position, new Vector2(300, 200)); if (_eventWindow == null) { _eventWindow = EditorWindow.GetWindowWithRect <EditorAddTutorialScript>(rect, true, "添加教学脚本"); } else { _eventWindow.position = rect; } _eventWindow._owner = owner; _eventWindow._buttonWidth = buttonWidth; _eventWindow.Show(); }