예제 #1
0
 public NoInactiveBehaviours(
     ViolationLevel level      = ViolationLevel.Warning,
     ViolationScope scope      = ViolationScope.Both,
     List <Type> excludedTypes = null) : base(level, scope)
 {
     this.excludedTypes = excludedTypes ?? new List <Type>();
 }
예제 #2
0
        private Rule ConstructRule(Type ruleClass, ViolationLevel level, ViolationScope scope, List <Type> excludedTypes)
        {
            if (excludedTypes == null || excludedTypes.Count == 0)
            {
                ConstructorInfo ctor = ruleClass.GetConstructor(new[] {
                    typeof(ViolationLevel),
                    typeof(ViolationScope)
                });
                return((Rule)ctor.Invoke(new object[] { level, scope }));
            }
            else
            {
                ConstructorInfo ctor = ruleClass.GetConstructor(new[] {
                    typeof(ViolationLevel),
                    typeof(ViolationScope),
                    typeof(List <Type>)
                });

                if (ctor == null)
                {
                    Log.Debug("Could not find constructor for " + ruleClass +
                              " that takes list of excluded types. Using default constructor.");
                    ctor = ruleClass.GetConstructor(new[] { typeof(ViolationLevel), typeof(ViolationScope) });
                    return((Rule)ctor.Invoke(new object[] { level, scope }));
                }

                return((Rule)ctor.Invoke(new object[] { level, scope, excludedTypes }));
            }
        }
예제 #3
0
        public Dictionary <Rule, List <IViolation> > Analyze(ViolationScope scope, GameObject root)
        {
            var violations = new Dictionary <Rule, List <IViolation> >();

            if (root == null)
            {
                return(violations);
            }

            for (var j = 0; j < this.gameObjectRules.Count; j++)
            {
                var rule = this.gameObjectRules[j];
                if (!rule.ValidForScope(scope))
                {
                    continue;
                }

                violations[rule] = rule.Handle(root);
            }

            foreach (var componentRuleSet in this.componentRules)
            {
                var rules = componentRuleSet.Value;

                for (var j = 0; j < rules.Count; j++)
                {
                    var rule = rules[j];
                    if (!rule.ValidForScope(scope))
                    {
                        continue;
                    }

                    var components = root.GetComponents(componentRuleSet.Key);
                    violations[rule] = new List <IViolation>();

                    for (var i = 0; i < components.Length; i++)
                    {
                        var component = components[i];
                        violations[rule].AddRange(rule.Handle(component));
                    }
                }
            }

            foreach (Transform child in root.transform)
            {
                var moreViolations = this.Analyze(scope, child.gameObject);

                violations = MergeRuleViolationDictionary(violations, moreViolations);
            }

            return(violations);
        }
예제 #4
0
 public NoDuplicateComponents(
     ViolationLevel level = ViolationLevel.Warning,
     ViolationScope scope = ViolationScope.Both) : base(level, scope)
 {
 }
예제 #5
0
 public NoMissingComponents(
     ViolationLevel level = ViolationLevel.Error,
     ViolationScope scope = ViolationScope.Both) : base(level, scope)
 {
 }
예제 #6
0
파일: Rule.cs 프로젝트: elmoeleven/mooble
 protected Rule(ViolationLevel level, ViolationScope scope)
 {
     this.Level = level;
     this.Scope = scope;
 }
예제 #7
0
파일: Rule.cs 프로젝트: elmoeleven/mooble
 public bool ValidForScope(ViolationScope scope)
 {
     return(this.Scope == ViolationScope.Both || this.Scope == scope);
 }
 public NoMissingObjectReferences(
     ViolationLevel level = ViolationLevel.Warning,
     ViolationScope scope = ViolationScope.Both) : base(level, scope)
 {
 }
예제 #9
0
 public NoImageWithMissingSprite(
     ViolationLevel level = ViolationLevel.Warning,
     ViolationScope scope = ViolationScope.Both) : base(level, scope)
 {
 }