Exemplo n.º 1
0
 public void addSubcategory(TaskList.CategoryList category)
 {
     if (this.mSubcategories == null)
     {
         this.mSubcategories = new List <TaskList.CategoryList>();
     }
     this.mSubcategories.Add(category);
 }
Exemplo n.º 2
0
 private void DrawCategory(BehaviorDesignerWindow window, TaskList.CategoryList category)
 {
     if (category.Visible)
     {
         category.Expanded = EditorGUILayout.Foldout(category.Expanded, category.Name, BehaviorDesignerUtility.TaskFoldoutGUIStyle);
         this.SetExpanded(category.ID, category.Expanded);
         if (category.Expanded)
         {
             EditorGUI.indentLevel = (EditorGUI.indentLevel + 1);
             if (category.Tasks != null)
             {
                 for (int i = 0; i < category.Tasks.Count; i++)
                 {
                     if (category.Tasks[i].Visible)
                     {
                         GUILayout.BeginHorizontal(new GUILayoutOption[0]);
                         GUILayout.Space((float)(EditorGUI.indentLevel * 16));
                         TaskNameAttribute[] array;
                         string name;
                         if ((array = (category.Tasks[i].Type.GetCustomAttributes(typeof(TaskNameAttribute), false) as TaskNameAttribute[])).Length > 0)
                         {
                             name = array[0].Name;
                         }
                         else
                         {
                             name = category.Tasks[i].Name;
                         }
                         if (GUILayout.Button(name, EditorStyles.toolbarButton, new GUILayoutOption[]
                         {
                             GUILayout.MaxWidth((float)(300 - EditorGUI.indentLevel * 16 - 24))
                         }))
                         {
                             window.AddTask(category.Tasks[i].Type, false);
                         }
                         GUILayout.Space(3f);
                         GUILayout.EndHorizontal();
                     }
                 }
             }
             if (category.Subcategories != null)
             {
                 this.DrawCategoryTaskList(window, category.Subcategories);
             }
             EditorGUI.indentLevel = (EditorGUI.indentLevel - 1);
         }
     }
 }
Exemplo n.º 3
0
        public void Init()
        {
            this.mCategoryList = new List <TaskList.CategoryList>();
            List <Type> list = new List <Type>();

            Assembly[] assemblies = AppDomain.CurrentDomain.GetAssemblies();
            for (int i = 0; i < assemblies.Length; i++)
            {
                Type[] types = assemblies[i].GetTypes();
                for (int j = 0; j < types.Length; j++)
                {
                    if (!types[j].Equals(typeof(BehaviorReference)) && !types[j].IsAbstract)
                    {
                        if (types[j].IsSubclassOf(typeof(BehaviorDesigner.Runtime.Tasks.Action)) || types[j].IsSubclassOf(typeof(Composite)) || types[j].IsSubclassOf(typeof(Conditional)) || types[j].IsSubclassOf(typeof(Decorator)))
                        {
                            list.Add(types[j]);
                        }
                    }
                }
            }
            list.Sort(new AlphanumComparator <Type>());
            Dictionary <string, TaskList.CategoryList> dictionary = new Dictionary <string, TaskList.CategoryList>();
            string text = string.Empty;
            int    id   = 0;

            for (int k = 0; k < list.Count; k++)
            {
                if (list[k].IsSubclassOf(typeof(BehaviorDesigner.Runtime.Tasks.Action)))
                {
                    text = "Actions";
                }
                else if (list[k].IsSubclassOf(typeof(Composite)))
                {
                    text = "Composites";
                }
                else if (list[k].IsSubclassOf(typeof(Conditional)))
                {
                    text = "Conditionals";
                }
                else
                {
                    text = "Decorators";
                }
                TaskCategoryAttribute[] array;
                if ((array = (list[k].GetCustomAttributes(typeof(TaskCategoryAttribute), false) as TaskCategoryAttribute[])).Length > 0)
                {
                    text = text + "/" + array[0].Category;
                }
                string   text2  = string.Empty;
                string[] array2 = text.Split(new char[]
                {
                    '/'
                });
                TaskList.CategoryList categoryList = null;
                TaskList.CategoryList categoryList2;
                for (int l = 0; l < array2.Length; l++)
                {
                    if (l > 0)
                    {
                        text2 += "/";
                    }
                    text2 += array2[l];
                    if (!dictionary.ContainsKey(text2))
                    {
                        categoryList2 = new TaskList.CategoryList(array2[l], text2, this.PreviouslyExpanded(id), id++);
                        if (categoryList == null)
                        {
                            this.mCategoryList.Add(categoryList2);
                        }
                        else
                        {
                            categoryList.addSubcategory(categoryList2);
                        }
                        dictionary.Add(text2, categoryList2);
                    }
                    else
                    {
                        categoryList2 = dictionary[text2];
                    }
                    categoryList = categoryList2;
                }
                categoryList2 = dictionary[text2];
                categoryList2.addTask(list[k]);
            }
            this.Search(BehaviorDesignerUtility.SplitCamelCase(this.mSearchString).ToLower().Replace(" ", string.Empty), this.mCategoryList);
        }