コード例 #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 void ConstructMaterial_DefaultSettings_GeneratesStandardMaterial()
        {
            MaterialConstructor materialConstructor = new MaterialConstructor();
            Material            mat = materialConstructor.ConstructMaterial();

            Assert.IsNotNull(mat);
            Assert.AreEqual(Shader.Find("Standard"), mat.shader);
            Assert.AreEqual(materialConstructor.Name, mat.name);
        }
コード例 #3
0
        public void ConstructMaterial_ShaderSet_MaterialHasShader()
        {
            MaterialConstructor materialConstructor = new MaterialConstructor();
            string shaderName = "Unlit/Color";

            materialConstructor.ShaderName = shaderName;
            Material mat = materialConstructor.ConstructMaterial();

            Assert.IsNotNull(mat);
            Assert.AreEqual(Shader.Find(shaderName), mat.shader);
        }
コード例 #4
0
        public void ConstructMaterial_ColorSet_MaterialHasColor()
        {
            MaterialConstructor materialConstructor = new MaterialConstructor();
            Color color = Random.ColorHSV();

            materialConstructor.Color = color;
            Material mat = materialConstructor.ConstructMaterial();

            Assert.IsNotNull(mat);
            Assert.AreEqual(Shader.Find("Standard"), mat.shader);
            Assert.AreEqual(color, mat.color);
        }
コード例 #5
0
        public void ConstructMaterial_NameSet_MaterialHasName()
        {
            MaterialConstructor materialConstructor = new MaterialConstructor();
            string materialName = "My Material " + Random.Range(0, 10000);

            materialConstructor.Name = materialName;
            Material mat = materialConstructor.ConstructMaterial();

            Assert.IsNotNull(mat);
            Assert.AreEqual(Shader.Find("Standard"), mat.shader);
            Assert.AreEqual(materialName, mat.name);
        }
コード例 #6
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);
        }