Exemplo n.º 1
0
        public HierarchySelectorElement AddHierarchySelector(string labelText, GameObject root, GameObject objectValue = null, bool alternate = false, bool secondAlternate = false, bool thirdAlternate = false)
        {
            HierarchySelectorElement hierarchySelector = new HierarchySelectorElement(labelText, root, objectValue);

            hierarchySelector.eventManager.AddListener <MainframeKeySelection <int[]> >(e => {
                this.eventManager.Raise <MainframeKeySelection <int[]> >(e);
            });
            AddAlternates(hierarchySelector, alternate, secondAlternate, thirdAlternate);
            this.Add(hierarchySelector);
            return(hierarchySelector);
        }
Exemplo n.º 2
0
        protected void DrawAnchorList(Div container, GameObject model)
        {
            container.Clear();
            bool alternate = false;

            foreach (KeyValuePair <string, ModelAnchorData> kvp in collection[chosenKey].anchors)
            {
                ListItem anchorItem = new ListItem(alternate);
                anchorItem.AddToClassList("search-list-item");
                anchorItem.userData = kvp.Key;
                anchorItem.AddToClassList("anchor-list-item");

                KeySelectorElement keyInput = anchorItem.AddKeySelector("Anchor Name", kvp.Key, ModelAnchorKeys.keys);

                keyInput.eventManager.AddListener <MainframeKeySelection <string> >(e => {
                    string newKey = e.value;
                    if (collection[chosenKey].anchors.ContainsKey(newKey))
                    {
                        return;
                    }
                    collection[chosenKey].anchors[newKey] = collection[chosenKey].anchors[kvp.Key];
                    collection[chosenKey].anchors.Remove(kvp.Key);
                    eventManager.Raise <SetSceneDirtyEvent>(new SetSceneDirtyEvent(SceneManager.GetActiveScene()));
                    DrawAnchorList(container, model);
                });

                HierarchySelectorElement hierarchyInput = anchorItem.AddHierarchySelector("Object", model, ModelBank.GetChildByHierarhcy(model, kvp.Value.hierarchy.ToArray()));
                hierarchyInput.eventManager.AddListener <MainframeKeySelection <int[]> >(e => {
                    collection[chosenKey].anchors[kvp.Key] = new ModelAnchorData(hierarchyInput.objectDisplay.value.name, hierarchyInput.value);
                    eventManager.Raise <SetSceneDirtyEvent>(new SetSceneDirtyEvent(SceneManager.GetActiveScene()));
                    DrawAnchorList(container, model);
                });

                ListItemImage delButton = anchorItem.AddImage(delIcon);
                delButton.AddToClassList("selectable", "hoverable", "icon");

                delButton.eventManager.AddListener <MouseClickEvent>(e => {
                    collection[chosenKey].anchors.Remove(kvp.Key);
                    eventManager.Raise <SetSceneDirtyEvent>(new SetSceneDirtyEvent(SceneManager.GetActiveScene()));
                    DrawAnchorList(container, model);
                });

                container.Add(anchorItem);
                alternate = !alternate;
            }
        }