コード例 #1
0
        protected override AdvancedDropdownItem Search(string searchString)
        {
            if (string.IsNullOrEmpty(searchString) || m_SearchableElements == null)
            {
                return(null);
            }

            // Support multiple search words separated by spaces.
            var searchWords = searchString.ToLower().Split(' ');

            // We keep two lists. Matches that matches the start of an item always get first priority.
            var matchesStart  = new List <AdvancedDropdownItem>();
            var matchesWithin = new List <AdvancedDropdownItem>();

            foreach (var e in m_SearchableElements)
            {
                var addComponentItem = (PresetTypeDropdownItem)e;
                var name             = addComponentItem.searchableName.ToLower().Replace(" ", "");
                AddMatchItem(e, name, searchWords, matchesStart, matchesWithin);
            }

            var searchTree = new AdvancedDropdownItem(kSearchHeader);

            matchesStart.Sort();
            foreach (var element in matchesStart)
            {
                searchTree.AddChild(element);
            }
            matchesWithin.Sort();
            foreach (var element in matchesWithin)
            {
                searchTree.AddChild(element);
            }
            return(searchTree);
        }
コード例 #2
0
        protected override AdvancedDropdownItem BuildRoot()
        {
            AdvancedDropdownItem root = new AdvancedDropdownItem(itemType.Name);

            root.AddChild(new AdvancedDropdownItem("None"));
            root.AddSeparator();

            AdvancedDropdownItem targetParent = root;
            bool multipleCollections          = collections.Count > 1;

            for (int i = 0; i < collections.Count; i++)
            {
                ScriptableObjectCollection collection = collections[i];

                if (multipleCollections)
                {
                    AdvancedDropdownItem collectionParent = new AdvancedDropdownItem(collection.name);
                    root.AddChild(collectionParent);
                    targetParent = collectionParent;
                }

                for (int j = 0; j < collection.Count; j++)
                {
                    ScriptableObjectCollectionItem collectionItem = collection[j];
                    targetParent.AddChild(new CollectionItemDropdownItem(collectionItem));
                }
            }

            if (!multipleCollections)
            {
                root.AddSeparator();
                root.AddChild(new AdvancedDropdownItem(CREATE_NEW_TEXT));
            }
            return(root);
        }
コード例 #3
0
    protected override AdvancedDropdownItem BuildRoot()
    {
        var root = new AdvancedDropdownItem(title);
        Dictionary <string, AdvancedDropdownItem> groups = new Dictionary <string, AdvancedDropdownItem>();

        foreach (var value in values)
        {
            AdvancedDropdownItem parent = root;
            string groupStr             = groupGetter?.Invoke(value);
            if (!string.IsNullOrEmpty(groupStr))
            {
                string[] groupContent = groupStr.Split('/');
                foreach (var groupName in groupContent)
                {
                    if (!string.IsNullOrEmpty(groupName))
                    {
                        if (!groups.TryGetValue(groupName, out var group))
                        {
                            group = new AdvancedDropdownItem(groupName);
                            groups.Add(groupName, group);
                            parent.AddChild(group);
                        }
                        parent = group;
                    }
                }
            }
            parent.AddChild(new AdvancedDropdownItem <T>(nameGetter(value), value)
            {
                icon = iconGetter?.Invoke(value)
            });
        }
        return(root);
    }
コード例 #4
0
        protected override AdvancedDropdownItem Search(string searchString)
        {
            if (string.IsNullOrEmpty(searchString) || m_SearchableElements == null)
            {
                return(null);
            }

            // Support multiple search words separated by spaces.
            var searchWords = searchString.ToLower().Split(' ');

            // We keep two lists. Matches that matches the start of an item always get first priority.
            var matchesStart  = new List <AdvancedDropdownItem>();
            var matchesWithin = new List <AdvancedDropdownItem>();

            bool found = false;

            foreach (var e in m_SearchableElements)
            {
                var addComponentItem = (ComponentDropdownItem)e;
                var name             = addComponentItem.searchableName.ToLower().Replace(" ", "");
                if (AddMatchItem(e, name, searchWords, matchesStart, matchesWithin))
                {
                    found = true;
                }
            }
            if (!found)
            {
                foreach (var e in m_SearchableElements)
                {
                    var addComponentItem = (ComponentDropdownItem)e;
                    var name             = addComponentItem.searchableNameLocalized.Replace(" ", "");
                    AddMatchItem(e, name, searchWords, matchesStart, matchesWithin);
                }
            }

            var searchTree = new AdvancedDropdownItem(kSearchHeader);

            matchesStart.Sort();
            foreach (var element in matchesStart)
            {
                searchTree.AddChild(element);
            }
            matchesWithin.Sort();
            foreach (var element in matchesWithin)
            {
                searchTree.AddChild(element);
            }
            if (searchTree != null)
            {
                var addNewScriptGroup = new ComponentDropdownItem("New script");
                addNewScriptGroup.name = L10n.Tr("New script");
                m_State.SetSelectedIndex(addNewScriptGroup, 0);
                var addNewScript = new NewScriptDropdownItem();
                addNewScript.className = searchString;
                addNewScriptGroup.AddChild(addNewScript);
                searchTree.AddChild(addNewScriptGroup);
            }
            return(searchTree);
        }
コード例 #5
0
        protected override AdvancedDropdownItem BuildRoot()
        {
            var root          = new AdvancedDropdownItem("Known Traits");
            var traitsRoot    = new AdvancedDropdownItem("Trait");
            var semanticsRoot = new AdvancedDropdownItem("Semantic Tag");

            root.AddChild(traitsRoot);
            root.AddChild(semanticsRoot);

            var knownTraits = new List <TraitDefinition>();

            var marsSession = MARSSession.Instance;

            if (marsSession != null && marsSession.requirements != null)
            {
                var requiredNames = marsSession.requirements.TraitRequirements;
                knownTraits.AddRange(requiredNames.Select(k => k.Definition));
            }

            var defaultTraitNames = typeof(TraitDefinitions)
                                    .GetFields(BindingFlags.Static | BindingFlags.Public | BindingFlags.FlattenHierarchy)
                                    .Select(k => k.GetValue(null) as TraitDefinition)
                                    .Where(k => (k != null));

            knownTraits.AddRange(defaultTraitNames);

            var finalList = knownTraits
                            .Distinct()
                            .OrderBy(k => !IsSemanticTrait(k))
                            .ThenBy(k => k.TraitName)
                            .ToList();

            foreach (var tagInfo in finalList)
            {
                var displayName = tagInfo.TraitName;
                var tagName     = tagInfo.TraitName;

                var item = new KnownTraitDropdownItem(displayName, () =>
                {
                    var st = m_SemanticTagCondition;
                    Undo.RecordObject(st, "Set trait name");
                    st.SetTraitName(tagName);
                    m_DoTraitNameChanged();
                });

                if (!IsSemanticTrait(tagInfo))
                {
                    item.name += " (" + tagInfo.Type.Name + ")";
                    traitsRoot.AddChild(item);
                }
                else
                {
                    semanticsRoot.AddChild(item);
                }
            }

            return(root);
        }
コード例 #6
0
            protected override AdvancedDropdownItem BuildRoot()
            {
                var node     = new AdvancedDropdownItem(_title);
                var elements = _tableComponent.GetComponentsInChildren(_type);

                node.AddChild(new ElementDropdownItem(null));
                foreach (var element in elements)
                {
                    node.AddChild(new ElementDropdownItem(element));
                }
                return(node);
            }
コード例 #7
0
        protected override AdvancedDropdownItem BuildRoot()
        {
            var root = new AdvancedDropdownItem(k_ContentActionsLabel);

            root.AddChild(new ActionsDropdownItem(
                              k_ApplyForcesLabel, CreateActionObject <ApplyForces>));
            root.AddChild(new ActionsDropdownItem(
                              k_RandomizeTransformLabel, CreateActionObject <RandomizeTransform>));
            root.AddChild(new ActionsDropdownItem(
                              k_ScatterLabel, CreateActionObject <Scatter>));

            return(root);
        }
コード例 #8
0
        protected override AdvancedDropdownItem BuildRoot()
        {
            var node     = new AdvancedDropdownItem(_title);
            var elements = _filter == null
                                ? _tableComponent.GetComponentsInChildren <T>()
                                : _tableComponent.GetComponentsInChildren <T>().Where(_filter);

            node.AddChild(new ElementDropdownItem <T>(null));
            foreach (var element in elements)
            {
                node.AddChild(new ElementDropdownItem <T>(element));
            }
            return(node);
        }
コード例 #9
0
        public static void AddTo(AdvancedDropdownItem root, IEnumerable <Type> types)
        {
            int itemCount = 0;

            // Add null item.
            var nullItem = new AdvancedTypePopupItem(null, TypeMenuUtility.k_NullDisplayName)
            {
                id = itemCount++
            };

            root.AddChild(nullItem);

            // Add type items.
            foreach (Type type in types.OrderByType())
            {
                string[] splittedTypePath = TypeMenuUtility.GetSplittedTypePath(type);
                if (splittedTypePath.Length == 0)
                {
                    continue;
                }

                AdvancedDropdownItem parent = root;

                // Add namespace items.
                for (int k = 0; (splittedTypePath.Length - 1) > k; k++)
                {
                    AdvancedDropdownItem foundItem = GetItem(parent, splittedTypePath[k]);
                    if (foundItem != null)
                    {
                        parent = foundItem;
                    }
                    else
                    {
                        var newItem = new AdvancedDropdownItem(splittedTypePath[k])
                        {
                            id = itemCount++,
                        };
                        parent.AddChild(newItem);
                        parent = newItem;
                    }
                }

                // Add type item.
                var item = new AdvancedTypePopupItem(type, ObjectNames.NicifyVariableName(splittedTypePath[splittedTypePath.Length - 1]))
                {
                    id = itemCount++
                };
                parent.AddChild(item);
            }
        }
コード例 #10
0
            public AdvancedDropdownItem GetDropdownItem(AdvancedDropdownItem parent)
            {
                // Draw all the subnamespaces of this namespace level.
                if (namespaceLevels.Count > 0)
                {
                    parent.AddChild(new AdvancedDropdownItem("Namespaces")
                    {
                        enabled = false
                    });
                    foreach (KeyValuePair <string, NamespaceLevel> namespaceLevel in namespaceLevels)
                    {
                        var groupItem = new AdvancedDropdownItem(namespaceLevel.Key);
                        groupItem = namespaceLevel.Value.GetDropdownItem(groupItem);

                        parent.AddChild(groupItem);
                    }
                }

                // Draw all the types of this namespace level.
                idTypePairs.Clear();
                if (types.Any())
                {
                    if (namespaceLevels.Count > 0)
                    {
                        parent.AddSeparator();
                    }

                    parent.AddChild(new AdvancedDropdownItem("Types")
                    {
                        enabled = false
                    });
                    foreach (Type type in types)
                    {
                        var name = type.FullName.Substring(type.FullName.LastIndexOf('.') + 1);
                        if (!type.IsUnitySerializable())
                        {
                            name += " (Not Serializable)";
                        }

                        var dropdownItem = new AdvancedDropdownItem(name);
                        parent.AddChild(dropdownItem);

                        // Use Hash instead of id! If 2 AdvancedDropdownItems have the same name, they will generate the same id (stupid, I know). To ensure searching for a unique identifier, we use the hash instead.
                        idTypePairs.Add(dropdownItem.GetHashCode(), type);
                    }
                }

                return(parent);
            }
コード例 #11
0
    protected override AdvancedDropdownItem BuildRoot()
    {
        var modes = EnumHelpers.GetValues <GameModeSelection>().Select(x => new
        {
            Mode = x,
            Attr = x.GetAttribute <GameModeAttribute>()
        }).GroupBy(x => x.Attr.MajorEngineVersion);

        var root = new AdvancedDropdownItem("Game");

        foreach (var mode in modes)
        {
            var group = new AdvancedDropdownItem(mode.Key.ToString())
            {
                id = -1
            };

            foreach (var selectionGroup in mode.GroupBy(x => x.Attr.EngineVersion))
            {
                foreach (var selection in selectionGroup)
                {
                    group.AddChild(new AdvancedDropdownItem(selection.Attr.DisplayName)
                    {
                        id = (int)selection.Mode
                    });
                }

                group.AddSeparator();
            }

            root.AddChild(group);
        }

        return(root);
    }
コード例 #12
0
        private AdvancedDropdownItem MakeParents(string prefix, SearchColumn desc, AdvancedDropdownItem parent)
        {
            var parts = prefix.Split('/');

            foreach (var p in parts)
            {
                var f = FindItem(p, parent);
                if (f != null)
                {
                    parent = f;
                }
                else
                {
                    AdvancedDropdownItem newItem = new AdvancedDropdownItem(p)
                    {
                        icon = desc.content.image as Texture2D, tooltip = desc.content.tooltip
                    };
                    newItem.AddChild(new AdvancedDropdownItem(k_AddlAllItemName)
                    {
                        userData = newItem
                    });
                    parent.AddChild(newItem);
                    parent = newItem;
                }
            }

            return(parent);
        }
コード例 #13
0
 protected void Add(AdvancedDropdownItem parent, string actorName, int id)
 {
     parent.AddChild(new AdvancedDropdownItem(actorName)
     {
         id = id
     });
 }
コード例 #14
0
    protected override AdvancedDropdownItem BuildRoot()
    {
        var modes = EnumHelpers.GetValues <Settings.Mode>().Select(x => new {
            Mode     = x,
            Settings = Settings.GetSettings(x)
        }).GroupBy(x => x.Settings.engineVersion);

        var root = new AdvancedDropdownItem("Game");

        foreach (var mode in modes)
        {
            var group = new AdvancedDropdownItem(mode.Key.ToString())
            {
                id = -1
            };

            foreach (var selectionGroup in mode.GroupBy(x => x.Settings.game))
            {
                foreach (var selection in selectionGroup)
                {
                    group.AddChild(new AdvancedDropdownItem(selection.Settings.DisplayName)
                    {
                        id = (int)selection.Mode
                    });
                }

                group.AddSeparator();
            }

            root.AddChild(group);
        }

        return(root);
    }
        protected override AdvancedDropdownItem BuildRoot()
        {
            AdvancedDropdownItem root = new AdvancedDropdownItem("Animation Step");

            List <Type> availableTypesOfAnimationStep = TypeUtility.GetAllSubclasses(typeof(AnimationStepBase));

            foreach (Type animatedItemType in availableTypesOfAnimationStep)
            {
                if (animatedItemType.IsAbstract)
                {
                    continue;
                }

                AnimationStepBase animationStepBase = Activator.CreateInstance(animatedItemType) as AnimationStepBase;

                string displayName = animationStepBase.GetType().Name;
                if (!string.IsNullOrEmpty(animationStepBase.DisplayName))
                {
                    displayName = animationStepBase.DisplayName;
                }

                root.AddChild(new AnimationStepAdvancedDropdownItem(animationStepBase, displayName));
            }

            return(root);
        }
コード例 #16
0
        protected override AdvancedDropdownItem BuildRoot()
        {
            var root = new AdvancedDropdownItem(k_GroupActionsLabel);

            root.AddChild(new ActionsDropdownItem(
                              k_GroupActionsLabel, () =>
                              Debug.LogError(k_NotImplementedErrorMessage)));

            return(root);
        }
コード例 #17
0
        protected override AdvancedDropdownItem BuildRoot()
        {
            AdvancedDropdownItem root = new AdvancedDropdownItem("DOTween Actions");

            foreach (var typeToDisplayGUI in DOTweenActionEditorGUIUtility.TypeToDisplayName)
            {
                Type baseDOTweenActionType = typeToDisplayGUI.Key;

                AdvancedDropdownItem targetFolder = root;

                if (DOTweenActionEditorGUIUtility.TypeToParentDisplay.TryGetValue(baseDOTweenActionType, out GUIContent parent))
                {
                    AdvancedDropdownItem item = targetFolder.children.FirstOrDefault(dropdownItem =>
                                                                                     dropdownItem.name.Equals(parent.text, StringComparison.Ordinal));

                    if (item == null)
                    {
                        item = new AdvancedDropdownItem(parent.text)
                        {
                            icon = (Texture2D)parent.image
                        };
                        targetFolder.AddChild(item);
                    }

                    targetFolder = item;
                }

                DOTweenActionAdvancedDropdownItem doTweenActionAdvancedDropdownItem =
                    new DOTweenActionAdvancedDropdownItem(baseDOTweenActionType, typeToDisplayGUI.Value.text)
                {
                    enabled = !IsTypeAlreadyInUse(actionsList, baseDOTweenActionType) && DOTweenActionEditorGUIUtility.CanActionBeAppliedToTarget(baseDOTweenActionType, targetGameObject)
                };

                if (typeToDisplayGUI.Value.image != null)
                {
                    doTweenActionAdvancedDropdownItem.icon = (Texture2D)typeToDisplayGUI.Value.image;
                }

                targetFolder.AddChild(doTweenActionAdvancedDropdownItem);
            }

            return(root);
        }
コード例 #18
0
        protected override AdvancedDropdownItem BuildRoot()
        {
            AdvancedDropdownItem root = new AdvancedDropdownItem("Easing Modes");

            string[] names = Enum.GetNames(typeof(Ease));
            for (int i = 0; i < names.Length; i++)
            {
                string name = names[i];
                if (string.Equals(name, "INTERNAL_Zero", StringComparison.Ordinal) ||
                    string.Equals(name, "INTERNAL_Custom", StringComparison.Ordinal))
                {
                    continue;
                }

                root.AddChild(new CustomEaseAdvancedDropdownItem(i, name));
            }

            root.AddChild(new CustomEaseAdvancedDropdownItem((int)Ease.INTERNAL_Custom, "Custom"));
            return(root);
        }
コード例 #19
0
        protected override AdvancedDropdownItem BuildRoot()
        {
            AdvancedDropdownItem result = new AdvancedDropdownItem("Messages");

            foreach (var item in _groupItems)
            {
                result.AddChild(item);
            }

            return(result);
        }
コード例 #20
0
        protected override AdvancedDropdownItem BuildRoot()
        {
            var node     = new AdvancedDropdownItem(_title);
            var elements = _tableAuthoring.GetComponentsInChildren <T>();

            foreach (var element in elements)
            {
                node.AddChild(new ElementDropdownItem <T>(element));
            }
            return(node);
        }
コード例 #21
0
        protected override AdvancedDropdownItem BuildRoot()
        {
            var root = new AdvancedDropdownItem("Nodes");

            foreach (var node in manifest.Types.NodeTypes)
            {
                var item = new AddNodeDropdownItem(node.Key);
                root.AddChild(item);
            }

            return(root);
        }
コード例 #22
0
        protected override AdvancedDropdownItem BuildRoot()
        {
            Type collectableType      = collection.GetCollectionType();
            AdvancedDropdownItem root = new AdvancedDropdownItem(collectableType.Name);

            root.AddChild(new AdvancedDropdownItem("None"));
            for (int i = 0; i < collection.Count; i++)
            {
                CollectableScriptableObject collectionItem = collection[i];
                if (collectionItem.GetType() == collectableType)
                {
                    root.AddChild(new CollectableDropdownItem(collectionItem));
                }
                else
                {
                    AdvancedDropdownItem parent = GetOrCreateDropdownItemForType(root, collectionItem);
                    parent.AddChild(new CollectableDropdownItem(collectionItem));
                }
            }
            return(root);
        }
        protected override AdvancedDropdownItem BuildRoot()
        {
            var root = new AdvancedDropdownItem("Components");

            var firstHalf  = new AdvancedDropdownItem("First half");
            var secondHalf = new AdvancedDropdownItem("Second half");
            var weekend    = new AdvancedDropdownItem("Component");

            firstHalf.AddChild(new AdvancedDropdownItem("Component 1"));
            firstHalf.AddChild(new AdvancedDropdownItem("Component 2"));
            secondHalf.AddChild(new AdvancedDropdownItem("Component 3"));
            secondHalf.AddChild(new AdvancedDropdownItem("Component 4"));
            weekend.AddChild(new AdvancedDropdownItem("Component 5"));
            weekend.AddChild(new AdvancedDropdownItem("Component 6"));
            weekend.AddChild(new AdvancedDropdownItem("Component 7"));

            root.AddChild(firstHalf);
            root.AddChild(secondHalf);
            root.AddChild(weekend);

            return(root);
        }
コード例 #24
0
        protected override AdvancedDropdownItem BuildRoot()
        {
            AdvancedDropdownItem root = new AdvancedDropdownItem("Unity Objects");

            foreach (World world in World.All)
            {
                foreach (ComponentSystemBase componentSystemBase in world.Systems)
                {
                    root.AddChild(new ECSSystemDropdownItem(componentSystemBase));
                }
            }

            return(root);
        }
コード例 #25
0
        private AdvancedDropdownItem GetOrCreateDropdownItemForType(AdvancedDropdownItem root,
                                                                    CollectableScriptableObject collectionItem)
        {
            AdvancedDropdownItem item = root.children.FirstOrDefault(dropdownItem =>
                                                                     dropdownItem.name.Equals(collectionItem.GetType().Name, StringComparison.Ordinal));

            if (item == null)
            {
                item = new AdvancedDropdownItem(collectionItem.GetType().Name);
                root.AddChild(item);
            }

            return(item);
        }
コード例 #26
0
ファイル: MapSelectionDropdown.cs プロジェクト: Zax37/raymap
 protected void Add(AdvancedDropdownItem parent, string path, string fullPath, int id)
 {
     if (path.Contains("/"))
     {
         // Folder
         string folder = path.Substring(0, path.IndexOf("/"));
         string rest   = path.Substring(path.IndexOf("/") + 1);
         AdvancedDropdownItem folderNode = parent.children.FirstOrDefault(c => c.name == folder);
         if (folderNode == null)
         {
             folderNode = new AdvancedDropdownItem(folder);
             parent.AddChild(folderNode);
         }
         Add(folderNode, rest, fullPath, id);
     }
     else
     {
         // File
         parent.AddChild(new AdvancedDropdownItem(path)
         {
             id = id
         });
     }
 }
コード例 #27
0
        protected override AdvancedDropdownItem BuildRoot()
        {
            var root = new AdvancedDropdownItem(k_ProxyActionsLabel);

            root.AddChild(new ActionsDropdownItem(k_SpawnObjectLabel, () =>
            {
                RulesModule.Pick <GameObject>(obj =>
                {
                    if (obj == null)
                    {
                        return;
                    }

                    var go = UnityObject.Instantiate(obj);
                    Undo.RegisterCreatedObjectUndo(go, $"Add content: {go.name}");

                    RulesModule.NewObject = go.transform;
                });
            }));

            root.AddChild(new ActionsDropdownItem(k_MaterialLabel, () =>
            {
                RulesModule.Pick <Material>(mat =>
                {
                    if (mat == null)
                    {
                        return;
                    }

                    var buildSurfaceObject = RulesModule.CreateBuildSurfaceObject(mat);
                    RulesModule.NewObject  = buildSurfaceObject.transform;
                });
            }));

            return(root);
        }
コード例 #28
0
        protected override AdvancedDropdownItem BuildRoot()
        {
            var root = new AdvancedDropdownItem("Select Product");

            if (ProductsToDisplay != null)
            {
                foreach (var currentProduct in ProductsToDisplay)
                {
                    root.AddChild(new ProductDropdownItem(currentProduct.DisplayName, currentProduct)
                    {
                        icon = currentProduct.Icon
                    });
                }
            }

            return(root);
        }
コード例 #29
0
    protected override AdvancedDropdownItem BuildRoot()
    {
        var root = new AdvancedDropdownItem("Map");

        if (HasVolumes)
        {
            foreach (var vol in GameVolumes)
            {
                root.AddChild(AddWorlds(new AdvancedDropdownItem(vol.Name), vol));
            }
        }
        else
        {
            AddWorlds(root, GameVolumes.First());
        }

        return(root);
    }
コード例 #30
0
        protected override AdvancedDropdownItem BuildRoot()
        {
            var root = new AdvancedDropdownItem(Name);

            foreach (var m in items)
            {
                if (m == null)
                {
                    root.AddSeparator();
                }
                else
                {
                    root.AddChild(m);
                }
            }

            return(root);
        }