public void Init() { int count = SceneNative.SceneCount(); string _name = "Scene"; if (count > 0) { _name = string.Format("Scene ({0})", count); } SceneNative.SceneCreate(_name); SceneNative.SceneHandle handle = SceneNative.SceneFindByIndex(0); Scene.Open(handle); }
public void OnGUI() { Scene curSelected = null; var _selected = Selector.GetSelected(); if (_selected?.Count > 0) { curSelected = _selected[0] as Scene; } int count = SceneNative.SceneCount(); if (ImGui.BeginPopupContextWindow("SceneMenu", ImGuiMouseButton.Right)) { OnGUI_RightMenu(null); ImGui.EndPopup(); } //if (ImGui.TreeNodeEx("Scenes##Hierachy", flagsBase)) { bool selected = false; for (int i = 0; i < count; ++i) { SceneNative.SceneHandle handle = SceneNative.SceneFindByIndex(i); string name = SceneNative.SceneGetName(handle); string label = string.Format("{0}##_Scene_{1}", name, i); SceneNative.ActiveOption active = SceneNative.SceneGetActive(handle); Scene.Open(handle); int childCount = Scene.current.root.children.Count; ImGuiTreeNodeFlags flags = flagsBase | (childCount == 0 ? ImGuiTreeNodeFlags.Leaf : ImGuiTreeNodeFlags.None); flags |= curSelected == Scene.current ? ImGuiTreeNodeFlags.Selected : ImGuiTreeNodeFlags.None; if (renameing && curSelected == Scene.current) { label = string.Format("###_{0}", label); } if (ImGui.CollapsingHeader(label, flags)) { if (renameing && curSelected == Scene.current) { neo_name = name; ImGuiInputTextFlags inputFlags = ImGuiInputTextFlags.EnterReturnsTrue | ImGuiInputTextFlags.AutoSelectAll; if (!ImGui.IsAnyItemActive() && !ImGui.IsMouseClicked(0)) { ImGui.SetKeyboardFocusHere(0); } ImGui.SameLine(ImGui.GetCursorPosX()); Vector2 padding = ImGui.GetStyle().FramePadding; padding.Y = 0; ImGui.PushStyleVar(ImGuiStyleVar.FramePadding, padding); if (ImGui.InputText(string.Format("##Scene_{0}_{1}", name, i), ref neo_name, 64, inputFlags)) { SceneNative.SceneSetName(handle, neo_name); renameing = false; } ImGui.PopStyleVar(); } OnGUI_SceneMenu(Scene.current, label, active == SceneNative.ActiveOption.Active); bool dragdroped = DragDropManager.DragDropTarget(handle.idx, DragDropWindow.Hierarchy, DragDropTree.Scenes, "_DDTreeWindow", ImGuiDragDropFlags.None, DragDropManager.OnDragDropAction); bool breakif = !OnGUI_TransformTree(Scene.current.root, i, ref selected); //ImGui.TreePop(); if (dragdroped || breakif) { break; } } else { OnGUI_SceneMenu(Scene.current, label, active == SceneNative.ActiveOption.Active); } if (!selected) { bool clicked = ImGui.IsItemClicked(); //bool focused = childCount == 0 ? ImGui.IsItemFocused() : ImGui.IsItemHovered(); if (clicked) { Selector.Select(Scene.current); selected = true; } } if (Scene.current != null) { // F2 if (ImGui.GetIO().KeysDown[113]) { neo_name = SceneNative.SceneGetName(Scene.current.handle); renameing = true; } } } //ImGui.TreePop(); } }