Exemplo n.º 1
0
 protected static void DrawListControls <V>(StructureControl <List <V> > control, Div container)
 {
     container.Clear();
     for (int i = 0; i < control.structure.Count; i++)
     {
         int index = i;
         if (control.specifiedFields.Contains(typeof(V)))
         {
             FieldControl <V> fieldControl = new FieldControl <V>(control.structure[index], control.name + "list-item", "item", false, control.world);
             fieldControl.eventManager.AddListener <FieldControlUpdated <V> >(e => {
                 control.structure[index] = e.control.value;
                 control.eventManager.Raise(new StructureControlUpdated <List <V> >(control));
             });
             ListItemImage delButton = fieldControl.AddImage(AssetDatabase.LoadAssetAtPath <Texture>("Assets/Icons/times.png")).AddToClassList("selectable", "hoverable", "icon");
             delButton.eventManager.AddListener <MouseClickEvent>(e => {
                 control.structure.RemoveAt(index);
                 control.eventManager.Raise(new StructureControlUpdated <List <V> >(control));
                 DrawListControls <V>(control, container);
             });
             container.Add(fieldControl);
         }
         else
         {
             V structure = control.structure[index];
             StructureControl <V> structureControl = new StructureControl <V>(ref structure);
             structureControl.eventManager.AddListener <StructureControlUpdated <V> >(e => {
                 control.eventManager.Raise(new StructureControlUpdated <List <V> >(control));
             });
         }
     }
 }
Exemplo n.º 2
0
 protected static void DrawSetControls <V>(StructureControl <HashSet <V> > control, Div container)
 {
     container.Clear();
     foreach (V item in control.structure)
     {
         if (control.specifiedFields.Contains(typeof(V)))
         {
             FieldControl <V> fieldControl = new FieldControl <V>(item, control.name + "list-item", "item", false, control.world);
             fieldControl.eventManager.AddListener <FieldControlUpdated <V> >(e => {
                 control.structure.Remove(item);
                 control.structure.Add(e.control.value);
                 control.eventManager.Raise(new StructureControlUpdated <HashSet <V> >(control));
             });
             ListItemImage delButton = fieldControl.AddImage(AssetDatabase.LoadAssetAtPath <Texture>("Assets/Icons/times.png")).AddToClassList("selectable", "hoverable", "icon");
             delButton.eventManager.AddListener <MouseClickEvent>(e => {
                 control.structure.Remove(item);
                 control.eventManager.Raise(new StructureControlUpdated <HashSet <V> >(control));
                 DrawSetControls <V>(control, container);
             });
             container.Add(fieldControl);
         }
         else
         {
             V structure = item;
             StructureControl <V> structureControl = new StructureControl <V>(ref structure);
             structureControl.eventManager.AddListener <StructureControlUpdated <V> >(e => {
                 control.eventManager.Raise(new StructureControlUpdated <HashSet <V> >(control));
             });
         }
     }
 }
Exemplo n.º 3
0
        protected void DrawAnimationDrawer(Div container, GameObject model)
        {
            container.Clear();
            bool     alternate     = false;
            Animator animComponent = model.GetComponent <Animator>();

            if (animComponent != null)
            {
                foreach (KeyValuePair <string, ModelAnimationData> kvp in collection[chosenKey].animationData)
                {
                    ListItem item = new ListItem(alternate);

                    KeySelectorElement keyButton = item.AddKeySelector("Animation Key", kvp.Key, Helpers.GetAllTypesFromBaseType(typeof(AnimationKey)).Select(key => key.Name).ToSet());
                    keyButton.eventManager.AddListener <MainframeKeySelection <string> >(e => {
                        if (!collection[chosenKey].animationData.ContainsKey(e.value))
                        {
                            string newKey = e.value;
                            collection[chosenKey].animationData[newKey] = collection[chosenKey].animationData[kvp.Key];
                            collection[chosenKey].animationData.Remove(kvp.Key);
                            eventManager.Raise <SetSceneDirtyEvent>(new SetSceneDirtyEvent(SceneManager.GetActiveScene()));
                            DrawAnimationDrawer(container, model);
                        }
                    });

                    item.AddLabel("State Name");
                    ListItemTextInput stateInput = item.AddTextField(kvp.Value.stateName);
                    stateInput.AddToClassList("animation-data-state-input");
                    stateInput.eventManager.AddListener <ListItemInputChange>(e => {
                        collection[chosenKey].animationData[kvp.Key].stateName = stateInput.text;
                        eventManager.Raise <SetSceneDirtyEvent>(new SetSceneDirtyEvent(SceneManager.GetActiveScene()));
                    });

                    ListItemIntInput layerInput = item.AddIntField(collection[chosenKey].animationData[kvp.Key].layer);
                    layerInput.AddToClassList("animation-data-layer-input");
                    layerInput.eventManager.AddListener <ListItemInputChange>(e => {
                        collection[chosenKey].animationData[kvp.Key].layer = layerInput.value;
                        eventManager.Raise <SetSceneDirtyEvent>(new SetSceneDirtyEvent(SceneManager.GetActiveScene()));
                    });

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

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

                    container.Add(item);
                    alternate = !alternate;
                }
            }
        }
Exemplo n.º 4
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;
            }
        }