Exemplo n.º 1
0
        public static void Open(World world, ProvenceDelegate <MainframeKeySelection <Entity> > callback)
        {
            EntitySelector.Close <EntitySelector>();
            EntitySelector window = MainframeSelectorWindow <Entity> .Open <EntitySelector>("Entity Selector", callback);

            window.eventManager.Raise <SetSelectorParameters <World> >(new SetSelectorParameters <World>(world));
        }
Exemplo n.º 2
0
        public ListItemText AddEntitySelector(World world, Entity value = null)
        {
            ListItemText el = new ListItemText();

            el.AddToClassList("list-item-text-display");
            el.AddToClassList("hoverable");
            el.AddToClassList("selectable");
            if (value != null)
            {
                el.text = value.ToString();
            }

            EntityHandle handle = world.LookUpEntity((Entity)el.text);

            if (handle == null)
            {
                el.text = "";
                eventManager.Raise <ListItemInputChange>(new ListItemInputChange(el));
            }
            el.eventManager.AddListener <MouseClickEvent>(e => {
                handle = world.LookUpEntity((Entity)el.text);
                if (handle != null)
                {
                    ComponentHandle <UnityGameObject> objectHandle = handle.GetComponent <UnityGameObject>();
                    GameObject go = objectHandle != null ? objectHandle.component.gameObject : null;
                    if (go != null)
                    {
                        Selection.objects = new UnityEngine.Object[] { go }
                    }
                    ;
                }
            });

            ListItemImage button = new ListItemImage("Assets/Icons/caret-down.png");

            button.AddToClassList("hoverable");
            button.AddToClassList("selectable");
            button.eventManager.AddListener <MouseClickEvent>(e => {
                EntitySelector.Open(world, args => {
                    el.text = args.value.ToString();
                    eventManager.Raise <ListItemInputChange>(new ListItemInputChange(el));
                });
            });

            ListItemImage clearButton = new ListItemImage("Assets/Icons/times.png");

            clearButton.AddToClassList("hoverable");
            clearButton.AddToClassList("selectable");
            clearButton.eventManager.AddListener <MouseClickEvent>(e => {
                if (el.text.Equals(""))
                {
                    return;
                }
                el.text = "";
                eventManager.Raise <ListItemInputChange>(new ListItemInputChange(el));
            });

            this.Add(el);
            this.Add(button);
            this.Add(clearButton);
            return(el);
        }