void OnDestroy() { if (m_bundleManager != null) { m_bundleManager.Dispose(); m_bundleManager = null; } }
public static lhBundleBuilder GetInstance() { if (m_instance != null) { return(null); } return(m_instance = new lhBundleBuilder()); }
void OnGUI() { if (m_bundleManager == null) { m_GUIStyles = lhGUIStyles.GetInstance(); m_bundleManager = lhBundleBuilder.GetInstance(); m_dragHandler = new lhDragHandler(); m_selectList = new List <lhBundleBuilder.BundleGroup.DependenceNode>(); } Rect curRectWindow = EditorGUILayout.BeginVertical(lhGUIStyles.GetStyle("OL Box")); { EditorGUILayout.BeginHorizontal(EditorStyles.toolbar, GUILayout.ExpandWidth(true)); { Rect createRect = GUILayoutUtility.GetRect(new GUIContent("Create"), EditorStyles.toolbarDropDown, GUILayout.ExpandWidth(false)); if (GUI.Button(createRect, "Create", EditorStyles.toolbarButton)) { m_bundleManager.CreateGroup(); GUI.FocusControl("GroupRename"); } Rect buildRect = GUILayoutUtility.GetRect(new GUIContent("Build"), EditorStyles.toolbarDropDown, GUILayout.ExpandWidth(false)); if (GUI.Button(buildRect, "Build", EditorStyles.toolbarButton)) { if (EditorUtility.DisplayDialog("Information", "Are you sure BuildAll", "Ok", "Cancel")) { m_bundleManager.BuildAll(); } } GUILayout.FlexibleSpace(); if (GUILayout.Button("Revert", EditorStyles.toolbarButton)) { if (EditorUtility.DisplayDialog("Information", "Are you sure Revert", "Ok", "Cancel")) { m_bundleManager.Revert(); } } if (GUILayout.Button("Apply", EditorStyles.toolbarButton)) { if (EditorUtility.DisplayDialog("Information", "Are you sure Save", "Ok", "Cancel")) { m_bundleManager.Apply(); } } if (GUILayout.Button("Settings", EditorStyles.toolbarButton)) { lhSettingEditor.Show(); } } EditorGUILayout.EndHorizontal(); GUI.SetNextControlName("ScrollPosition"); m_scrollPosition = EditorGUILayout.BeginScrollView(m_scrollPosition); { foreach (var group in lhBundleBuilder.bundleGroup) { Rect itemRect = EditorGUILayout.BeginHorizontal(EditorStyles.toolbarButton, GUILayout.ExpandWidth(true)); { if (group.treeList.Count != 0) { GUIContent content = group.editorOpen ? new GUIContent("▲") : new GUIContent("▼"); Rect dropButton = GUILayoutUtility.GetRect(content, EditorStyles.miniLabel, GUILayout.ExpandWidth(false)); if (GUI.Button(dropButton, content, EditorStyles.miniLabel)) { group.editorOpen = !group.editorOpen; } } if (group.renaming) { GUIContent cancelContent = new GUIContent("×"); if (GUI.Button(GUILayoutUtility.GetRect(cancelContent, EditorStyles.miniButton, GUILayout.ExpandWidth(false)), cancelContent)) { group.renaming = false; GUI.FocusControl("ScrollPosition"); } GUIContent certainContent = new GUIContent("√"); if (GUI.Button(GUILayoutUtility.GetRect(certainContent, EditorStyles.miniButton, GUILayout.ExpandWidth(false)), certainContent)) { if (m_bundleManager.HasSameGroupName(group, group.oldGroupName)) { EditorUtility.DisplayDialog("Error", "Has the same groupName,please rename the groupname", "Ok"); } else { group.renaming = false; group.groupName = group.oldGroupName; GUI.FocusControl("ScrollPosition"); } } group.oldGroupName = EditorGUILayout.TextField(group.oldGroupName); } else { //GUIContent renameContent = new GUIContent(" Q "); //if (GUI.Button(GUILayoutUtility.GetRect(renameContent, EditorStyles.miniLabel, GUILayout.ExpandWidth(false)),renameContent, EditorStyles.miniLabel)) //{ // group.renaming = true; // group.oldGroupName = group.groupName; // Repaint(); //} GUILayout.Label(group.groupName); } GUILayout.FlexibleSpace(); Rect createRect = GUILayoutUtility.GetRect(new GUIContent("Create"), EditorStyles.miniLabel, GUILayout.ExpandWidth(false)); if (GUI.Button(createRect, "Create", EditorStyles.miniLabel)) { group.CreateBundle(); } Rect buildRect = GUILayoutUtility.GetRect(new GUIContent("Build"), EditorStyles.toolbarDropDown, GUILayout.ExpandWidth(false)); if (GUI.Button(buildRect, "Build", EditorStyles.toolbarDropDown)) { GenericMenu menu = new GenericMenu(); menu.AddItem(new GUIContent("Build All"), false, group.BuildAll); menu.AddItem(new GUIContent("Build Selected"), false, group.BuildSelected); menu.AddItem(new GUIContent("Clear All"), false, group.Clear); menu.DropDown(buildRect); } GUIContent deleteContent = new GUIContent("x"); if (GUI.Button(GUILayoutUtility.GetRect(deleteContent, EditorStyles.toolbarButton, GUILayout.ExpandWidth(false)), deleteContent, EditorStyles.toolbarButton)) { if (EditorUtility.DisplayDialog("Information", "Are you sure delete group?", "Ok", "Cancel")) { m_bundleManager.DeleteGroup(group); Repaint(); return; } } } GUILayout.EndHorizontal(); if (group.editorOpen) { EditorGUILayout.BeginVertical(); { TreeLayout(group.treeList); } EditorGUILayout.EndVertical(); } if (IsMouseOn(itemRect)) { if (Event.current.keyCode == KeyCode.F2) { group.renaming = true; group.oldGroupName = group.groupName; Repaint(); } if (Event.current.keyCode == KeyCode.Return) { if (m_bundleManager.HasSameGroupName(group, group.oldGroupName)) { EditorUtility.DisplayDialog("Error", "Has the same groupName,please rename the groupname", "Ok"); } else { group.renaming = false; group.groupName = group.oldGroupName; Repaint(); GUI.FocusControl("ScrollPosition"); } } if (Event.current.type == EventType.DragUpdated) { m_dragHandler.SetVisualMode(DragAndDropVisualMode.Move); } if (Event.current.type == EventType.DragPerform) { var movedNode = (lhBundleBuilder.BundleGroup.DependenceNode)m_dragHandler.GetGenericData("DependenceNode"); if (!group.treeList.Contains(movedNode)) { movedNode.DeleteOwn(); group.AddTree(movedNode); m_dragHandler.AcceptDrag(); } } } } } EditorGUILayout.EndScrollView(); } EditorGUILayout.EndVertical(); }
public void Dispose() { m_instance = null; }