예제 #1
0
        void CheckExpressionNames(string[] names, BatchExpressionGroup group, object a)
        {
            if (group != null)
            {
                if (group.expressions.Count > 0)
                {
                    for (int i = group.expressions.Count - 1; i >= 0; --i)
                    {
                        bool remove = true;
                        for (int j = 0; j < names.Length; ++j)
                        {
                            if (group.expressions[i].name == names[j])
                            {
                                group.expressions[i].index = j;
                                remove = false;
                                break;
                            }
                        }

                        if (remove)
                        {
                            group.expressions.RemoveAt(i);
                        }
                    }
                }

                for (int i = 0; i < group.subGroups.Count; ++i)
                {
                    CheckExpressionNames(names, group.subGroups[i], null);
                }
            }
        }
예제 #2
0
 protected void RemoveGroup(BatchExpressionGroup group)
 {
     if (group.parent != null)
     {
         group.parent.subGroups.Remove(group);
     }
 }
예제 #3
0
 void CreateRoot(BatchExpressionGroup.GroupType type)
 {
     if (m_Root == null || m_Root.type != type)
     {
         m_Root      = new BatchExpressionGroup();
         m_Root.type = type;
     }
 }
예제 #4
0
        protected void AddSubGroupToGroup(BatchExpressionGroup group, BatchExpressionGroup.GroupType subType)
        {
            BatchExpressionGroup subGroup = new BatchExpressionGroup();

            subGroup.type   = subType;
            subGroup.parent = group;
            group.subGroups.Add(subGroup);
        }
예제 #5
0
        protected void AddExpressionToGroup(BatchExpressionGroup group)
        {
            BatchExpression expr = new BatchExpression();

            ChangeExpression(expr, group.expressions.Count, "");
            expr.parent = group;
            group.expressions.Add(expr);
        }
예제 #6
0
        public virtual void DrawGroup(BatchExpressionGroup group, int deep)
        {
            if (group != null)
            {
                YHEditorTools.PushIndentLevel(deep);

                EditorGUILayout.BeginHorizontal();

                EditorGUILayout.LabelField(group.type.ToString());

                if (GUILayout.Button("+", GUILayout.Width(100)))
                {
                    AddExpressionToGroup(group);
                }

                if (GUILayout.Button("And", GUILayout.Width(100)))
                {
                    AddSubGroupToGroup(group, BatchExpressionGroup.GroupType.And);
                }

                if (GUILayout.Button("Or", GUILayout.Width(100)))
                {
                    AddSubGroupToGroup(group, BatchExpressionGroup.GroupType.Or);
                }

                if (GUILayout.Button("-", GUILayout.Width(100)))
                {
                    RemoveGroup(group);
                }

                EditorGUILayout.EndHorizontal();

                YHEditorTools.PushIndentLevel(deep + 1);
                if (group.expressions.Count > 0)
                {
                    for (int i = 0; i < group.expressions.Count; ++i)
                    {
                        DrawExpression(group.expressions[i]);
                    }
                }

                YHEditorTools.PopIndentLevel();

                if (group.subGroups.Count > 0)
                {
                    for (int i = 0; i < group.subGroups.Count; ++i)
                    {
                        DrawGroup(group.subGroups[i], deep + 1);
                    }
                }

                YHEditorTools.PopIndentLevel();
            }
        }
예제 #7
0
        void FixExpressionsValue(ClassInfo classInfo, BatchExpressionGroup group)
        {
            if (group != null)
            {
                FixExpressionsValue(classInfo, group.expressions);

                for (int j = 0; j < group.subGroups.Count; ++j)
                {
                    FixExpressionsValue(classInfo, group);
                }
            }
        }
예제 #8
0
        bool CheckConditions(ClassInfo classInfo, object obj, BatchExpressionGroup group)
        {
            bool pass = true;

            if (group != null && group.expressions.Count > 0)
            {
                pass = CheckConditions(classInfo, obj, group.expressions, group.type == BatchExpressionGroup.GroupType.Or);

                if (group.type == BatchExpressionGroup.GroupType.And)
                {
                    if (!pass)
                    {
                        return(false);
                    }
                }
                else if (group.type == BatchExpressionGroup.GroupType.Or)
                {
                    if (pass)
                    {
                        return(true);
                    }
                }

                for (int i = 0; i < group.subGroups.Count; ++i)
                {
                    pass = CheckConditions(classInfo, obj, group.subGroups[i]);

                    if (group.type == BatchExpressionGroup.GroupType.And)
                    {
                        if (!pass)
                        {
                            return(false);
                        }
                    }
                    else if (group.type == BatchExpressionGroup.GroupType.Or)
                    {
                        if (pass)
                        {
                            return(true);
                        }
                    }
                }
            }
            return(pass);
        }
예제 #9
0
        public List <FindResult> FindResources(string searchPath, string filter, ClassInfo classInfo, BatchExpressionGroup root)
        {
            List <FindResult> results = new List <FindResult>();

            List <string> assets = FindAsset.FindAllAssets(searchPath, filter);

            FixExpressionsValue(classInfo, root);

            for (int i = 0; i < assets.Count; ++i)
            {
                UnityEngine.Object obj = AssetDatabase.LoadAssetAtPath(assets[i], classInfo.type);

                if (obj != null)
                {
                    if (CheckConditions(classInfo, obj, root))
                    {
                        results.Add(new FindResult(assets[i], obj));
                    }
                }
            }

            return(results);
        }
예제 #10
0
        public List <FindResult> FindComponents(string searchPath, string filter, ClassInfo classInfo, BatchExpressionGroup root)
        {
            List <FindResult> results = new List <FindResult>();

            List <string> assets = FindAsset.FindAllAssets(searchPath, filter);

            FixExpressionsValue(classInfo, root);

            for (int i = 0; i < assets.Count; ++i)
            {
                GameObject gameObj = AssetDatabase.LoadAssetAtPath <GameObject>(assets[i]);

                if (gameObj != null)
                {
                    Component[] insts = gameObj.GetComponentsInChildren(classInfo.type);
                    if (insts != null && insts.Length > 0)
                    {
                        for (int j = 0; j < insts.Length; ++j)
                        {
                            if (CheckConditions(classInfo, insts[i], root))
                            {
                                results.Add(new FindResult(assets[i] + ":" + HierarchyUtil.FullPath(insts[j].transform), insts[j]));
                            }
                        }
                    }
                }
            }

            return(results);
        }
예제 #11
0
        public override void Init(ClassInfo classInfo)
        {
            base.Init(classInfo);

            m_Root = new BatchExpressionGroup();
        }