Exemplo n.º 1
0
        private string MakeDropDownGroup(ScriptableObject scriptableObject, ScriptableObjectGrouping grouping)
        {
            string path = FindScriptableObjectFolderPath(scriptableObject);

            switch (grouping)
            {
            default:
            case ScriptableObjectGrouping.None:
                path = path.Replace("/", " > ");
                return(path);

            case ScriptableObjectGrouping.ByFolder:
                return(path);

            case ScriptableObjectGrouping.ByFolderFlat:
                int    last  = path.LastIndexOf('/');
                string part1 = path.Substring(0, last);
                string part2 = path.Substring(last);
                path = part1.Replace("/", " > ") + part2;
                return(path);
            }
        }
Exemplo n.º 2
0
        private void DisplayDropDown(Rect position, ScriptableObject selectedScriptableObject, ScriptableObjectGrouping grouping)
        {
            var menu = new GenericMenu();

            menu.AddItem(new GUIContent("Nothing"), selectedScriptableObject == null, _onSelectedScriptableObject, null);
            menu.AddSeparator("");

            for (int i = 0; i < _scriptableObjects.Count; ++i)
            {
                var scriptableObject = _scriptableObjects[i];

                string menuLabel = MakeDropDownGroup(scriptableObject, grouping);
                if (string.IsNullOrEmpty(menuLabel))
                {
                    continue;
                }

                var content = new GUIContent(menuLabel);
                menu.AddItem(content, scriptableObject == selectedScriptableObject, _onSelectedScriptableObject, scriptableObject);
            }

            menu.DropDown(position);
        }
Exemplo n.º 3
0
        private void DisplayDropDown(Rect position, ScriptableObject[] selectedScriptableObject, ScriptableObjectGrouping grouping)
        {
            var menu = new GenericMenu();

            menu.AddItem(new GUIContent("Nothing"), selectedScriptableObject.Length == 0, _onSelectedScriptableObject, null);
            menu.AddItem(new GUIContent("Everything"),
                         (_scriptableObjects.Count != 0 && selectedScriptableObject.Length == _scriptableObjects.Count),
                         _onSelectedScriptableObject, _scriptableObjects.ToArray());

            for (int i = 0; i < _scriptableObjects.Count; ++i)
            {
                var scriptableObject = _scriptableObjects[i];

                string menuLabel = MakeDropDownGroup(scriptableObject, grouping);
                if (string.IsNullOrEmpty(menuLabel))
                {
                    continue;
                }

                var content = new GUIContent(menuLabel);
                menu.AddItem(content, ResolveSelectedScriptableObject(scriptableObject), _onSelectedScriptableObject, scriptableObject);
            }

            menu.DropDown(position);
        }
 public ScriptableObjectDropdownAttribute(ScriptableObjectGrouping grouping)
 {
     this.grouping = grouping;
 }