Exemple #1
0
        public override void Initialize()
        {
            base.Initialize();
            ptree    = new PropertyTree(panel);
            tagStrip = new MenuStrip(panel);
            var root = tagStrip.AddItem("Add tag");

            root.Position(Gwen.Pos.Top, 0, 100);
            root.Menu.Position(Gwen.Pos.Top, 0, 20);
            root.Clicked += (sender, arguments) => { var menu = sender as MenuItem;  menu.Menu.Show(); };
            foreach (var tag in TagsContainer.allTags)
            {
                root.Menu.AddItem(tag);
            }
            root.Menu.AddDivider();
            root.Menu.AddItem("Create new tag").SetAction((Base sender, EventArgs arguments) => Console.WriteLine());
            //root.Menu.;
            tagStrip.Hide();
            ptree.ShouldDrawBackground   = false;
            Selection.OnSelectionChange += (sender, args) => {
                var entity = (sender as Func <object>)() as Entity;
                if (entity != null)
                {
                    var comps = entity.GetAllComponents();
                    ptree.RemoveAll();
                    var prop = ptree.Add("Transform");
                    prop.Add("Position:", new Gwen.Control.Property.Vector3(prop), entity.Position).ValueChanged += (o, arg) => {
                        var tmpObj = o as PropertyRow <Vector3>;
                        entity.Position = tmpObj.Value;
                    };
                    prop.Add("Rotation:", new Gwen.Control.Property.Vector3(prop), entity.Rotation).ValueChanged += (o, arg) => {
                        var tmpObj = o as PropertyRow <Vector3>;
                        entity.Rotation = tmpObj.Value;
                    };
                    prop.Add("Scale:", new Gwen.Control.Property.Vector3(prop), entity.Scale).ValueChanged += (o, arg) => {
                        var tmpObj = o as PropertyRow <Vector3>;
                        entity.Scale = tmpObj.Value;
                    };
                    foreach (var component in comps)
                    {
                        prop = ptree.Add(component.GetType().Name);
                        var inspector = new DefaultInspector();
                        inspector.properties = prop;
                        inspector.getTarget  = () => component;
                        inspector.OnInitializeGUI();
                    }
                    ptree.Show();
                    ptree.SetBounds(0, 25, 200, 200);
                    ptree.ExpandAll();
                    tagStrip.Show();
                }
                //else
                //props=Selection.assets [0].GetType ().GetProperties ().Where (p=>p.CanRead && p.CanWrite);
            };
        }
Exemple #2
0
        public void RenderComponents(Entity entity)
        {
            var prop = ptree.AddOrGet("Transform");

            DefaultInspector.mappedPropertyDrawers[typeof(OpenTK.Vector3)].Invoke(prop, "Position", entity.Position, (object val) => { entity.Position = (Vector3)val; });
            DefaultInspector.mappedPropertyDrawers[typeof(OpenTK.Vector3)].Invoke(prop, "Rotation", entity.Rotation, (object val) => { entity.Rotation = (Vector3)val; });
            DefaultInspector.mappedPropertyDrawers[typeof(OpenTK.Vector3)].Invoke(prop, "Scale", entity.Scale, (object val) => { entity.Scale = (Vector3)val; });

            var comps = entity.GetAllComponents();

            foreach (var component in comps)
            {
                prop = ptree.AddOrGet(component.GetType().Name);
                var inspector = new DefaultInspector();
                inspector.properties = prop;
                inspector.getTarget  = component;
                inspector.OnInitializeGUI();
            }
        }