Esempio n. 1
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);
        }
Esempio n. 2
0
        protected override AdvancedDropdownItem BuildRoot()
        {
            var root = new AdvancedDropdownItem(string.Empty);
            var all  = TypeCache.GetTypesDerivedFrom <T>();

            foreach (var type in all)
            {
                var path   = selector(type);
                var parent = path != null?root.FindOrCreate(path) : root;

                var item = new TypeSelectorItem(type, type.Name)
                {
                    icon = type.FindUnityIcon() as Texture2D
                };
                parent.AddChild(item);
            }
            Reorder(root);
            return(root);
        }
        internal override void DrawItem(AdvancedDropdownItem item, string name, Texture2D icon, bool enabled, bool drawArrow, bool selected, bool hasSearch)
        {
            var newScriptItem = item as NewScriptDropdownItem;

            if (newScriptItem == null)
            {
                if (hasSearch && item is ComponentDropdownItem)
                {
                    name = ((ComponentDropdownItem)item).searchableName;
                }
                base.DrawItem(item, name, icon, enabled, drawArrow, selected, hasSearch);
                return;
            }

            GUILayout.Label(L10n.Tr("Name"), EditorStyles.label);

            EditorGUI.FocusTextInControl("NewScriptName");
            GUI.SetNextControlName("NewScriptName");

            newScriptItem.m_ClassName = EditorGUILayout.TextField(newScriptItem.m_ClassName);

            EditorGUILayout.Space();

            var canCreate = newScriptItem.CanCreate();

            if (!canCreate && newScriptItem.m_ClassName != "")
            {
                GUILayout.Label(newScriptItem.GetError(), EditorStyles.helpBox);
            }

            GUILayout.FlexibleSpace();

            using (new EditorGUI.DisabledScope(!canCreate))
            {
                if (GUILayout.Button(L10n.Tr("Create and Add")))
                {
                    m_OnCreateNewScript(newScriptItem);
                }
            }

            EditorGUILayout.Space();
        }
Esempio n. 4
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);
        }
Esempio n. 5
0
        /// <summary>
        /// Creates nodes if path does not exists. Supports only signle level folders.
        /// </summary>
        /// <param name="path">Path to build. Last element should be actual node name.</param>
        /// <param name="dictionary">Reference to dictionary to store references to items</param>
        /// <returns>Path to provided node in path</returns>
        protected string BuildPathIfNotExists(string[] path, ref Dictionary <string, ClassTypeDropdownItem> dictionary)
        {
            // IMPORTANT: This code supports only single level folders. Nodes can't be nested more than one level.
            if (path.Length != 2)
            {
                return("");
            }
            AdvancedDropdownItem root = dictionary[""];
            // // This code assumes the last element of path is actual name of node
            // string nodePath = String.Join("/", path, 0, path.Length-1);
            string nodePath = path[0];

            // Create path nodes if does not exists
            if (!dictionary.ContainsKey(nodePath))
            {
                ClassTypeDropdownItem node = new ClassTypeDropdownItem(nodePath);
                dictionary.Add(nodePath, node);
            }
            return(nodePath);
        }
        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;

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

            return(root);
        }
Esempio n. 7
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);
        }
        private int SortColumnProviders(AdvancedDropdownItem lhs, AdvancedDropdownItem rhs)
        {
            if (!lhs.hasChildren && rhs.hasChildren)
            {
                return(-1);
            }
            else if (lhs.hasChildren && !rhs.hasChildren)
            {
                return(1);
            }
            if (string.Equals(lhs.displayName, "Default"))
            {
                return(-1);
            }
            if (string.Equals(rhs.displayName, "Default"))
            {
                return(1);
            }

            return(lhs.displayName.CompareTo(rhs.displayName));
        }
Esempio n. 9
0
    protected override AdvancedDropdownItem BuildRoot()
    {
        var root = new AdvancedDropdownItem("选择节点");

        for (int i = 0; i < View.VaildTypes.Count; ++i)
        {
            var type = View.VaildTypes[i];
            if (type.GetCustomAttribute <HiddenInTypeCreaterAttribute>() != null || !CheckType(type))
            {
                continue;
            }
            var    dpName = type.GetCustomAttribute <DisplayNameAttribute>(false);
            string name   = dpName == null ? type.Name : string.Format("{0}({1})", dpName.Name, type.Name);
            var    item   = new AdvancedDropdownItem(name)
            {
                id = i
            };
            GetRoot(type, root).AddChild(item);
        }
        return(root);
    }
Esempio n. 10
0
        protected override AdvancedDropdownItem BuildRoot()
        {
            var rootItem = new AdvancedDropdownItem(m_Title);

            foreach (var column in m_Columns)
            {
                var path   = column.path;
                var pos    = path.LastIndexOf('/');
                var name   = pos == -1 ? column.name : path.Substring(pos + 1);
                var prefix = pos == -1 ? null : path.Substring(0, pos);

                AdvancedDropdownItem newItem = new AdvancedDropdownItem(name)
                {
                    icon        = column.content.image as Texture2D,
                    displayName = string.IsNullOrEmpty(column.content.text) ? column.content.tooltip : SearchColumn.ParseName(column.content.text),
                    tooltip     = column.content.tooltip,
                    userData    = column
                };

                m_ColumnIndexes[newItem.id] = column;

                var parent = rootItem;
                if (prefix != null)
                {
                    parent = MakeParents(prefix, column, rootItem);
                }

                if (FindItem(name, parent) == null)
                {
                    parent.AddChild(newItem);
                }
            }

            rootItem.SortChildren(SortColumnProviders);
            foreach (var c in rootItem.children)
            {
                c.SortChildren(SortColumns, true);
            }
            return(rootItem);
        }
Esempio n. 11
0
    protected override AdvancedDropdownItem BuildRoot()
    {
        var root = new AdvancedDropdownItem(name);

        if (OpenSpace.PS1.PS1GameInfo.Games.ContainsKey(mode))
        {
            if (actorIndex == 0)
            {
                actors = OpenSpace.PS1.PS1GameInfo.Games[mode].actors.Where(a => a.isSelectable && a.isSelectableActor1).Select(a => a.Actor1).ToArray();
            }
            else if (actorIndex == 1)
            {
                actors = OpenSpace.PS1.PS1GameInfo.Games[mode].actors.Where(a => a.isSelectable && a.isSelectableActor2).Select(a => a.Actor2).ToArray();
            }
            for (int i = 0; i < actors.Length; i++)
            {
                Add(root, actors[i], i);
            }
        }

        return(root);
    }
        private int SortColumns(AdvancedDropdownItem lhs, AdvancedDropdownItem rhs)
        {
            if (lhs.hasChildren && !rhs.hasChildren)
            {
                return(1);
            }
            if (!lhs.hasChildren && rhs.hasChildren)
            {
                return(-1);
            }

            if (string.Equals(lhs.displayName, k_AddlAllItemName))
            {
                return(-1);
            }
            if (string.Equals(rhs.displayName, k_AddlAllItemName))
            {
                return(1);
            }

            return(lhs.displayName.CompareTo(rhs.displayName));
        }
        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);
        }
Esempio n. 14
0
        protected override void ItemSelected(AdvancedDropdownItem item)
        {
            base.ItemSelected(item);

            if (item.name.Equals(CREATE_NEW_TEXT, StringComparison.OrdinalIgnoreCase))
            {
                ScriptableObjectCollection     collection     = collections.First();
                ScriptableObjectCollectionItem collectionItem = collection.AddNew(itemType);
                callback.Invoke(collectionItem);
                Selection.objects = new Object[] { collection };
                CollectionCustomEditor.SetLastAddedEnum(collectionItem);
                return;
            }

            if (item is CollectionItemDropdownItem dropdownItem)
            {
                callback.Invoke(dropdownItem.CollectionItem);
            }
            else
            {
                callback.Invoke(null);
            }
        }
        public MessagesUnityManager(GUIContent contentLable) : base(new AdvancedDropdownState())
        {
            _groupItems = new AdvancedDropdownItem[10];
            int index = 0;

            foreach (string item in System.Enum.GetNames(typeof(GroupMessageType)))
            {
                _groupItems[index++] = new AdvancedDropdownItem(item);
            }

            CreateMethods();

            foreach (var item in _messagesUnity)
            {
                _groupItems[item.indexGroup].AddChild(new AdvancedDropdownItem(item.lable));
            }

            _messages       = new ListView <MessageUnity>();
            _messages.lable = contentLable;

            _messages.onAddButton = OnAddButton;
            _messages.GUIItem     = GUIItem;
        }
Esempio n. 16
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,
                    };
                    parent.AddChild(newItem);
                    parent = newItem;
                }
            }

            return(parent);
        }
Esempio n. 17
0
    protected AdvancedDropdownItem AddWorlds(AdvancedDropdownItem parent, GameInfo_Volume vol)
    {
        int id = 0;

        foreach (var w in vol.Worlds.Where(x => x.Maps.Length > 0))
        {
            var worldItem = new AdvancedDropdownItem(GetName(w.Index, WorldNames?.TryGetItem(w.Index)))
            {
                id = -1
            };

            foreach (var m in w.Maps.OrderBy(x => x))
            {
                worldItem.AddChild(new MapSelectionDropdownItem(GetLevelName(w.Index, m), vol.Name, w.Index, m)
                {
                    id = id++
                });
            }

            parent.AddChild(worldItem);
        }

        return(parent);
    }
Esempio n. 18
0
 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
         });
     }
 }
        protected override AdvancedDropdownItem BuildRoot()
        {
            var root = new AdvancedDropdownItem(title);

            foreach (var item in pathToActionMap)
            {
                var splitStrings = item.Key.Split('/');
                var parent       = root;
                AdvancedDropdownItem lastItem = null;

                foreach (var str in splitStrings)
                {
                    var foundChildItem = parent.children.FirstOrDefault(item => item.name == str);

                    if (foundChildItem != null)
                    {
                        parent   = foundChildItem;
                        lastItem = foundChildItem;
                        continue;
                    }

                    var child = new AdvancedDropdownItem(str);
                    parent.AddChild(child);

                    parent   = child;
                    lastItem = child;
                }

                if (lastItem != null && !idToActionMap.ContainsKey(lastItem.id))
                {
                    idToActionMap.Add(lastItem.id, item.Value);
                }
            }

            return(root);
        }
Esempio n. 20
0
 protected AdvancedDropdownItem GetRoot(Type type, AdvancedDropdownItem root)
 {
     tmpList.Clear();
     while (type != null)
     {
         var catalog = type.GetCustomAttribute <CatalogAttribute>(false);
         if (catalog != null && !string.IsNullOrEmpty(catalog.Name))
         {
             tmpList.Add(catalog.Name);
         }
         type = type.BaseType;
     }
     for (int i = tmpList.Count - 1; i >= 0; --i)
     {
         var child = root.children.FirstOrDefault(it => it.name == tmpList[i]);
         if (child == null)
         {
             child = new AdvancedDropdownItem(tmpList[i]);
             root.AddChild(child);
         }
         root = child;
     }
     return(root);
 }
        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);
        }
Esempio n. 22
0
        internal override void DrawItem(AdvancedDropdownItem item, string name, Texture2D icon, bool enabled, bool drawArrow, bool selected, bool hasSearch)
        {
            bool isScript      = false;
            var  newScriptItem = item as NewScriptDropdownItem;

            if (newScriptItem == null)
            {
                string namespaceName = "";
                if (hasSearch && item is ComponentDropdownItem)
                {
                    var componentItem = item as ComponentDropdownItem;
                    // null check doesn't work here so comparing against "New script"
                    if (componentItem.menuPath != null && componentItem.displayName != null && !componentItem.displayName.Equals("New script") && componentItem.menuPath.StartsWith(AddComponentDataSource.kScriptHeader))
                    {
                        namespaceName = componentItem.menuPath.Substring(AddComponentDataSource.kScriptHeader.Length);
                        var last = namespaceName.LastIndexOf("/");
                        namespaceName = last != -1 ? namespaceName.Substring(0, last) : "";
                        isScript      = true;
                    }
                    else
                    {
                        name = ((ComponentDropdownItem)item).searchableNameLocalized;
                    }
                }

                if (string.IsNullOrEmpty(namespaceName))
                {
                    base.DrawItem(item, name, icon, enabled, drawArrow, selected, hasSearch);
                }
                else
                {
                    DrawSearchItem(name, namespaceName, icon, selected);
                }

                // dummy label for easy tooltips
                // this is to allow viewing full script names in cases where they are cut off
                if (Event.current.type == EventType.Repaint && isScript)
                {
                    var text        = string.IsNullOrEmpty(namespaceName) ? name : $"{name} ({namespaceName})";
                    var tooltipRect = GUILayoutUtility.GetLastRect();
                    GUI.Label(tooltipRect, new GUIContent("", text));
                }

                return;
            }

            GUILayout.Label(L10n.Tr("Name"), EditorStyles.label);

            EditorGUI.FocusTextInControl("NewScriptName");
            GUI.SetNextControlName("NewScriptName");

            newScriptItem.m_ClassName = EditorGUILayout.TextField(newScriptItem.m_ClassName);

            EditorGUILayout.Space();

            var canCreate = newScriptItem.CanCreate();

            if (!canCreate && newScriptItem.m_ClassName != "")
            {
                GUILayout.Label(newScriptItem.GetError(), EditorStyles.helpBox);
            }

            GUILayout.FlexibleSpace();

            using (new EditorGUI.DisabledScope(!canCreate))
            {
                if (GUILayout.Button(L10n.Tr("Create and Add")))
                {
                    m_OnCreateNewScript(newScriptItem);
                }
            }

            EditorGUILayout.Space();
        }
Esempio n. 23
0
        protected override AdvancedDropdownItem BuildRoot()
        {
            pathLookup.Clear();
            var root = new AdvancedDropdownItem("Serialized Property Search");


            Dictionary <string, AdvancedDropdownItem> dropdownItemsDict = new Dictionary <string, AdvancedDropdownItem>();

            foreach (var propertyPath in propertyPaths)
            {
                var path = propertyPath;
                AdvancedDropdownItem dropdownItem = root;
                string name = GetName(path);

                //If there is a path attribute
                if (!string.IsNullOrEmpty(path))
                {
                    AdvancedDropdownItem depthFirst = null;
                    string menuPath = null;
                    do
                    {
                        //Get the menu path and name---------
                        int lastSeparator = path.LastIndexOf('/');
                        if (lastSeparator < 0)
                        {
                            //If the menu path is no longer a path, add it to the root.
                            if (string.IsNullOrEmpty(menuPath))
                            {
                                menuPath = path;
                            }
                            AdvancedDropdownItem baseDropDownItem = new AdvancedDropdownItem(
                                ObjectNames.NicifyVariableName(menuPath)
                                );
                            if (propertyLookup?[propertyPath].IsInConfiguration ?? false)
                            {
                                baseDropDownItem.enabled = false;
                            }
                            if (depthFirst != null)
                            {
                                baseDropDownItem.AddChild(depthFirst);
                            }
                            else
                            {
                                pathLookup.Add(baseDropDownItem.id, path);
                                baseDropDownItem.icon = GetIcon(path);
                            }

                            root.AddChild(baseDropDownItem);
                            break;
                        }

                        menuPath = path.Substring(0, lastSeparator);
                        name     = ObjectNames.NicifyVariableName(path.Substring(lastSeparator + 1));
                        //------------------------------------

                        if (string.IsNullOrEmpty(menuPath))
                        {
                            Debug.LogError($"{path} was not a valid path for this method.");
                            break;
                        }

                        AdvancedDropdownItem newDropDownItem = new AdvancedDropdownItem(name);
                        if (propertyLookup?[propertyPath].IsInConfiguration ?? false)
                        {
                            newDropDownItem.enabled = false;
                        }

                        if (depthFirst != null)
                        {
                            newDropDownItem.AddChild(depthFirst);
                        }
                        else
                        {
                            pathLookup.Add(newDropDownItem.id, path);
                            newDropDownItem.icon = GetIcon(path);
                        }

                        depthFirst = newDropDownItem;
                        dropdownItemsDict.Add(path, newDropDownItem);
                        path = menuPath;
                    } while (!dropdownItemsDict.TryGetValue(menuPath, out dropdownItem));

                    continue;
                }

                dropdownItem.AddChild(new AdvancedDropdownItem(name));
            }

            return(root);

            Texture2D GetIcon(string p)
            {
                return(EditorGUIUtility.FindTexture("cs Script Icon"));

                /*Texture2D icon = EditorGUIUtility.ObjectContent(null, t).image as Texture2D;
                 * if(icon == null || icon.name.StartsWith("DefaultAsset"))
                 *      icon = EditorGUIUtility.FindTexture("cs Script Icon");
                 * return icon;*/
            }
        }
Esempio n. 24
0
 public bool TryGetType(AdvancedDropdownItem item, out Type type)
 {
     type = FindType(item);
     return(type != null);
 }
Esempio n. 25
0
 protected override void ItemSelected(AdvancedDropdownItem item)
 {
     onSelectNode(((AddNodeDropdownItem)item).Node);
 }
Esempio n. 26
0
 protected override void ItemSelected(AdvancedDropdownItem item)
 {
     base.ItemSelected(item);
     callBack?.Invoke(item as CustomEaseAdvancedDropdownItem);
 }
 protected override void ItemSelected(AdvancedDropdownItem item)
 {
     (item as ActionsDropdownItem)?.Callback();
 }
Esempio n. 28
0
 public static AdvancedDropdownItem FindOrCreate(this AdvancedDropdownItem root, string path)
 {
     return(FindOrCreate(root, path, n => new AdvancedDropdownItem(n)));
 }
Esempio n. 29
0
            protected override void ItemSelected(AdvancedDropdownItem item)
            {
                var elementItem = (ElementDropdownItem)item;

                _onElementSelected?.Invoke(elementItem?.Item);
            }
 protected override void ItemSelected(AdvancedDropdownItem item)
 {
     base.ItemSelected(item);
     callBack?.Invoke(item as AnimationStepAdvancedDropdownItem);
 }