예제 #1
0
        public void ConstructMaterial_TexturesNotFetched_GivesWarning()
        {
            MaterialConstructor materialConstructor = new MaterialConstructor();

            materialConstructor.SetTexture("_MainTex", A.Fake <ITextureConstructor>());
            Material mat = materialConstructor.ConstructMaterial();

            LogAssert.Expect(LogType.Warning, new Regex(@"\w*Constructed material which has unfetched textures.\w*"));
        }
예제 #2
0
        public IEnumerator FetchDependencies_TextureFetchFail_ReturnsFalse()
        {
            MaterialConstructor materialConstructor        = new MaterialConstructor();
            ITextureConstructor fakeTextureConstructorFail = A.Fake <ITextureConstructor>();

            A.CallTo(() => fakeTextureConstructorFail.FetchTextureAsync()).Returns(Task.FromResult <Texture2D>(null));
            materialConstructor.SetTexture("tex", fakeTextureConstructorFail);

            Task <bool> task = materialConstructor.FetchDependencies();

            yield return(AsyncTest.WaitForTask(task));

            bool success = task.Result;

            Assert.False(success);
        }
예제 #3
0
        public IEnumerator ConstructMaterial_FetchedTexture_TextureSetInMaterial()
        {
            MaterialConstructor materialConstructor    = new MaterialConstructor();
            Texture2D           expectedTexture        = new Texture2D(2, 2);
            ITextureConstructor fakeTextureConstructor = A.Fake <ITextureConstructor>();

            A.CallTo(() => fakeTextureConstructor.FetchTextureAsync()).Returns(Task.FromResult(expectedTexture));
            materialConstructor.SetTexture("_MainTex", fakeTextureConstructor);
            Task <bool> task = materialConstructor.FetchDependencies();

            yield return(AsyncTest.WaitForTask(task));

            bool success = task.Result;

            Assert.True(success);

            Material mat = materialConstructor.ConstructMaterial();

            Assert.NotNull(mat.mainTexture);
            Assert.AreEqual(expectedTexture.imageContentsHash, mat.mainTexture.imageContentsHash);
        }