// Window Methods public static void Show(EntityHandle entityHandle) { EntityEditor[] windows = Resources.FindObjectsOfTypeAll <EntityEditor>(); for (int i = 0; i < windows.Length; i++) { if (windows[i].CompareWindow(entityHandle)) { windows[i].Focus(); return; } } EntityEditor window = CreateWindow <EntityEditor>(); window.titleContent = new GUIContent(entityHandle.entity.ToString()); window.windowID = "entity-editor-" + System.Guid.NewGuid().ToString(); window.eventManager.Raise <SelectKey <EntityHandle> >(new SelectKey <EntityHandle>(entityHandle)); }
protected void DrawEntityList() { ColumnScroller scroller = root.Q <ColumnScroller>("world-editor-entity-scroller"); scroller.Clear(); bool alternate = false; DropDownMenu contextMenu = root.Q <DropDownMenu>("entity-list-context-menu"); foreach (EntityHandle entityHandle in chosenKey.LookUpAllEntities()) { ListItem item = new ListItem(alternate, true, true); item.AddIndent(); item.AddImage(entityIcon).AddToClassList("icon"); ComponentHandle <Name> nameHandle = entityHandle.GetComponent <Name>(); if (nameHandle != null) { item.AddTextDisplay(nameHandle.component.name); } else { item.AddTextDisplay(entityHandle.entity.ToString()); } item.eventManager.AddListener <MouseClickEvent>(e => { switch (e.button) { case 0: ComponentHandle <UnityGameObject> objectHandle = entityHandle.GetComponent <UnityGameObject>(); GameObject entityGO = objectHandle != null ? objectHandle.component.gameObject : null; if (entityGO != null) { Selection.objects = new Object[] { entityGO }; } if (item.ClassListContains("selected")) { EntityEditor.Show(entityHandle); } else { ListItem selected = scroller.Q <ListItem>(null, "selected"); if (selected != null) { selected.RemoveFromClassList("selected"); } item.AddToClassList("selected"); } break; case 1: contextMenu.Show(root, e, true); ListItemText duplicateButton = root.Q <ListItemText>("entity-list-context-menu-duplicate-button"); duplicateButton.eventManager.ClearListeners(); duplicateButton.eventManager.AddListener <MouseClickEvent>(ev => { if (ev.button != 0) { return; } DuplicateEntity(entityHandle); contextMenu.style.display = DisplayStyle.None; }); ListItemText removeButton = root.Q <ListItemText>("entity-list-context-menu-remove-button"); removeButton.eventManager.ClearListeners(); removeButton.eventManager.AddListener <MouseClickEvent>(ev => { if (ev.button != 0) { return; } RemoveEntity(entityHandle); contextMenu.style.display = DisplayStyle.None; }); break; } }); scroller.Add(item); alternate = !alternate; } }