示例#1
0
        public void Test()
        {
            var results = new List <TestResult>();

            GameObjectProcessor.ProcessAllScenes
            (
                scenePathFilter: path => path.StartsWith("Assets"),
                onProcess: gameObject =>
            {
                var com = gameObject.GetComponent <PrefabOverrideTestComponent>();

                if (com == null)
                {
                    return(GameObjectProcessResult.NOT_CHANGE);
                }

                var hasOverrides = PrefabUtility.HasPrefabInstanceAnyOverrides
                                   (
                    instanceRoot: gameObject,
                    includeDefaultOverrides: false
                                   );

                if (!hasOverrides)
                {
                    return(GameObjectProcessResult.NOT_CHANGE);
                }

                var result = new TestResult(gameObject);

                results.Add(result);

                return(GameObjectProcessResult.NOT_CHANGE);
            }
            );

            if (results.Count <= 0)
            {
                return;
            }

            var builder = new StringBuilder();

            foreach (var result in results)
            {
                result.WriteTo(builder);
            }

            Assert.Fail(builder.ToString().TrimEnd());
        }
示例#2
0
        public void Test()
        {
            var results = new List <TestResult>();

            GameObjectProcessor.ProcessAllPrefabs
            (
                prefabPathFilter: path => path.StartsWith("Assets"),
                onProcess: gameObject =>
            {
                var layoutGroup       = gameObject.GetComponent <LayoutGroup>();
                var contentSizeFitter = gameObject.GetComponent <ContentSizeFitter>();

                if (layoutGroup == null)
                {
                    return(GameObjectProcessResult.NOT_CHANGE);
                }
                if (contentSizeFitter == null)
                {
                    return(GameObjectProcessResult.NOT_CHANGE);
                }
                if (!layoutGroup.enabled && !contentSizeFitter.enabled)
                {
                    return(GameObjectProcessResult.NOT_CHANGE);
                }

                var result = new TestResult(gameObject);

                results.Add(result);

                return(GameObjectProcessResult.NOT_CHANGE);
            }
            );

            if (results.Count <= 0)
            {
                return;
            }

            var builder = new StringBuilder();

            foreach (var result in results)
            {
                result.WriteTo(builder);
            }

            Assert.Fail(builder.ToString().TrimEnd());
        }