private void OnEnable() { s_ActiveWindows.Add(this); titleContent.text = $"{UTinyConstants.ApplicationName} Hierarchy"; UTinyEditorApplication.OnLoadProject += HandleProjectLoaded; UTinyEditorApplication.OnCloseProject += HandleProjectClosed; HandleProjectLoaded(UTinyEditorApplication.Project); if (null == m_TreeView) { m_TreeView = new HierarchyTree(EditorContext, m_TreeState); } m_Filter = new SearchField(); }
public static void ShowEntityContextMenu(this HierarchyTree tree, UTinyEntity.Reference entityRef) { if (UTinyEntity.Reference.None.Id == entityRef.Id) { return; } var menu = new GenericMenu(); menu.AddItem(new GUIContent("Create Entity"), false, () => { tree.CreateEntityFromSelection(); }); menu.AddItem(new GUIContent("Rename"), false, () => { tree.Rename(entityRef); }); menu.AddItem(new GUIContent("Duplicate"), false, () => { tree.DuplicateSelection(); }); menu.AddItem(new GUIContent("Delete"), false, () => { tree.DeleteSelection(); }); menu.AddSeparator(""); menu.AddItem(new GUIContent("New EntityGroup"), false, () => { var context = EditorContext; if (null == context) { return; } var registry = context.Registry; var project = context.Project; CreateNewEntityGroup(project.Module.Dereference(registry)); }); menu.ShowAsContext(); }
private void HandleProjectLoaded(UTinyProject project) { if (null == project) { Repaint(); return; } EntityGroupManager.OnEntityGroupLoaded += AddToTrees; EntityGroupManager.OnEntityGroupUnloaded += RemoveFromTrees; EntityGroupManager.OnEntityGroupsReordered += ReorderTrees; m_TreeView = new HierarchyTree(EditorContext, m_TreeState); foreach (var entityGroup in LoadedEntityGroups) { AddToTrees(entityGroup); } Undo.OnUndoPerformed += () => HandleDataModelChange(ChangeSource.DataModel, null); Undo.OnRedoPerformed += () => HandleDataModelChange(ChangeSource.DataModel, null); }
public static void ShowEntityGroupContextMenu(this HierarchyTree tree, UTinyEntityGroup.Reference entityGroupRef) { if (UTinyEntityGroup.Reference.None.Id == entityGroupRef.Id) { entityGroupRef = EntityGroupManager.ActiveEntityGroup; } var menu = new GenericMenu(); if (IsEntityGroupActive(entityGroupRef)) { menu.AddDisabledItem(new GUIContent("Set Active EntityGroup")); } else { menu.AddItem(new GUIContent("Set Active EntityGroup"), false, () => { SetEntityGroupActive(entityGroupRef); }); } if (EntityGroupManager.LoadedEntityGroups.IndexOf(entityGroupRef) > 0) { menu.AddItem(new GUIContent("Move EntityGroup Up"), false, () => { EntityGroupManager.MoveUp(entityGroupRef); }); } else { menu.AddDisabledItem(new GUIContent("Move EntityGroup Up")); } if (EntityGroupManager.LoadedEntityGroups.IndexOf(entityGroupRef) < EntityGroupManager.LoadedEntityGroupCount - 1) { menu.AddItem(new GUIContent("Move EntityGroup Down"), false, () => { EntityGroupManager.MoveDown(entityGroupRef); }); } else { menu.AddDisabledItem(new GUIContent("Move EntityGroup Down")); } menu.AddSeparator(""); if (EntityGroupManager.LoadedEntityGroupCount == 1) { menu.AddDisabledItem(new GUIContent("Unload EntityGroup")); menu.AddDisabledItem(new GUIContent("Unload Other EntityGroups")); } else { menu.AddItem(new GUIContent("Unload EntityGroup"), false, () => { EntityGroupManager.UnloadEntityGroup(entityGroupRef); }); menu.AddItem(new GUIContent("Unload Other EntityGroups"), false, () => { EntityGroupManager.UnloadAllEntityGroupsExcept(entityGroupRef); }); } menu.AddItem(new GUIContent("New EntityGroup"), false, () => { var context = EditorContext; if (null == context) { return; } var registry = context.Registry; var project = context.Project; CreateNewEntityGroup(project.Module.Dereference(registry)); }); menu.AddSeparator(""); menu.AddItem(new GUIContent("Create Entity"), false, () => { tree.CreateEntity(entityGroupRef); }); menu.AddItem(new GUIContent("Create Static Entity"), false, () => { tree.CreateStaticEntity(entityGroupRef); }); menu.ShowAsContext(); }