コード例 #1
0
ファイル: SystemList.cs プロジェクト: my0n/Wrecker
        public override void DrawEditor(double delta)
        {
            _selectedSystem = _selectedSystem ?? _scene.LogicSystems.First();
            if (ImGui.BeginCombo("System", _selectedSystem.ToString())) // The second parameter is the label previewed before opening the combo.
            {
                foreach (var system in _scene.LogicSystems)
                {
                    bool is_selected = system == _selectedSystem;
                    if (ImGui.Selectable(system.ToString(), is_selected))
                    {
                        _selectedSystem = system;
                    }
                    if (is_selected)
                    {
                        ImGui.SetItemDefaultFocus();
                    }
                }
                foreach (var system in _scene.RendererSystems)
                {
                    bool is_selected = system == _selectedSystem;
                    if (ImGui.Selectable(system.ToString(), is_selected))
                    {
                        _selectedSystem = system;
                    }
                    if (is_selected)
                    {
                        ImGui.SetItemDefaultFocus();
                    }
                }
                ImGui.EndCombo();
            }

            _propertyGrid.Draw(_selectedSystem);
        }
コード例 #2
0
        private void DrawComponentEditor <T>(Entity entity)
        {
            if (entity.Has <T>())
            {
                var component = entity.Get <T>();

                ImGui.PushID(component.GetType().Name);
                if (ImGui.CollapsingHeader(component.GetType().Name, ImGuiTreeNodeFlags.DefaultOpen))
                {
                    var propChanged = _propertyGrid.Draw(component);

                    if (propChanged)
                    {
                        entity.Set(component);
                    }
                }
                ImGui.PopID();
            }
        }