Beispiel #1
0
        // INITIALIZERS: --------------------------------------------------------------------------

        private void OnEnable()
        {
            if (target == null || serializedObject == null)
            {
                return;
            }

            this.condition           = (ICondition)target;
            this.condition.hideFlags = HideFlags.HideInHierarchy | HideFlags.HideInInspector;
            this.condition.OnEnableEditor(this.condition);

            Type   conditionType = this.condition.GetType();
            string conditionName = (string)conditionType.GetField("NAME", BINDING_FLAGS).GetValue(null);

            FieldInfo customIconsFieldInfo = conditionType.GetField(
                SelectTypePanel.CUSTOM_ICON_PATH_VARIABLE,
                BINDING_FLAGS
                );

            string iconsPath = SelectTypePanel.ICONS_CONDITIONS_PATH;

            if (customIconsFieldInfo != null)
            {
                string customIconsPath = (string)customIconsFieldInfo.GetValue(null);
                if (!string.IsNullOrEmpty(customIconsPath))
                {
                    iconsPath = customIconsPath;
                }
            }

            string conditionIconPath = Path.Combine(
                iconsPath,
                SelectTypePanel.GetName(conditionName) + ".png"
                );

            this.icon = AssetDatabase.LoadAssetAtPath <Texture2D>(conditionIconPath);
            if (icon == null)
            {
                icon = AssetDatabase.LoadAssetAtPath <Texture2D>(Path.Combine(iconsPath, "Default.png"));
            }
            if (icon == null)
            {
                icon = EditorGUIUtility.FindTexture("GameObject Icon");
            }
        }
Beispiel #2
0
        private void CreateList()
        {
            NodeData rootData = new NodeData(this.rootName);

            this.categorizedTree   = new TreeNode <NodeData>(this.rootName, rootData);
            this.uncategorizedList = new List <TreeNode <NodeData> >(new TreeNode <NodeData>(this.rootName, rootData));

            List <Type> types     = this.GetAllClassTypesOf(this.baseType);
            int         typesSize = types.Count;

            for (int i = 0; i < typesSize; ++i)
            {
                string   actionDescription = (string)types[i].GetField("NAME").GetValue(null);
                string[] categories        = SelectTypePanel.GetCategories(actionDescription);
                string   name = SelectTypePanel.GetName(actionDescription);

                TreeNode <NodeData> node = this.categorizedTree;
                for (int j = 0; j < categories.Length; ++j)
                {
                    if (node.HasChild(categories[j]))
                    {
                        node = node.GetChild(categories[j]);
                    }
                    else
                    {
                        NodeData            nodeData = new NodeData(categories[j]);
                        TreeNode <NodeData> treeNode = new TreeNode <NodeData>(categories[j], nodeData);
                        node = node.AddChild(treeNode);
                    }
                }

                NodeData leafData = new NodeData(name, types[i]);
                node.AddChild(new TreeNode <NodeData>(name, leafData));
                this.uncategorizedList.Add(new TreeNode <NodeData>(name, leafData));
            }

            this.currentBranch = this.categorizedTree;
            this.pathTrace     = new Stack <TreeNode <NodeData> >();
        }