コード例 #1
0
 public void IsValidShader_ArgumentNull_ThrowException()
 {
     Assert.Throws <ArgumentNullException>(() =>
     {
         ShaderMetaDataUtility.IsValidShader(null);
     });
 }
コード例 #2
0
        public void IsValidShader_ArgumentShaderFromBuiltinResources_ReturnsFalse()
        {
            Shader s = Shader.Find("Standard");

            Assume.That(s, Is.Not.Null);

            Assert.IsFalse(ShaderMetaDataUtility.IsValidShader(s));
        }
コード例 #3
0
        public void LoadShaderMetaData_ValidShaderWithoutMeta_ReturnsAttributes()
        {
            Shader shaderWithMeta = Shader.Find(k_PathToShaderWithNoMeta);

            Assume.That(shaderWithMeta != null);

            AttributeLayoutContainer attributes = ShaderMetaDataUtility.LoadShaderMetaData(shaderWithMeta);

            Assert.IsNotNull(attributes);
            Assert.IsNull(attributes.attributes);
        }
コード例 #4
0
        public static string CreateShaderMetadataTest(string shaderName)
        {
            //load a polybrush shader
            Shader shaderToTest = Shader.Find(shaderName);

            Assert.IsNotNull(shaderToTest);

            //create base meta data
            AttributeLayout[] attributes = new AttributeLayout[]
            {
                new AttributeLayout(MeshChannel.Color, ComponentIndex.R, Vector2.up, 0, "_Texture1"),
                new AttributeLayout(MeshChannel.Color, ComponentIndex.G, Vector2.up, 0, "_Texture2"),
                new AttributeLayout(MeshChannel.Color, ComponentIndex.B, Vector2.up, 0, "_Texture3"),
                new AttributeLayout(MeshChannel.Color, ComponentIndex.A, Vector2.up, 0, "_Texture4"),
            };

            //call the function that will create the asset containing meta data
            string path = ShaderMetaDataUtility.SaveMeshAttributesData(shaderToTest, attributes, true);

            return(path);
        }
コード例 #5
0
        public void ConvertMetaDataToNewFormat_ArgumentValid_NoException()
        {
            if (!Directory.Exists(k_AssetShaderFolder))
            {
                Directory.CreateDirectory(k_AssetShaderFolder);
            }

            // Setup environment for this specific tests.
            FileUtil.CopyFileOrDirectory(k_FilePathToShaderWithOldMetaFormat, k_DestFilePathToShaderWithOldMetaFormat);
            FileUtil.CopyFileOrDirectory(k_FilePathToShaderWithOldMetaFormatPBS, k_DestFilePathToShaderWithOldMetaFormatPBS);
            AssetDatabase.Refresh();

            Shader shader = Shader.Find(k_PathToShaderWithOldMetaFormat);

            Assume.That(shader != null);

#pragma warning disable 0618
            // We should find a .pbs.json file for the shader.
            Assert.IsFalse(String.IsNullOrEmpty(ShaderMetaDataUtility.FindPolybrushMetaDataForShader(shader)));

            // Convert the data from .pbs.json to meta data.
            ShaderMetaDataUtility.ConvertMetaDataToNewFormat(shader);

            // After conversion, we shouldn't find a .pbs.json file for the shader.
            Assert.IsTrue(String.IsNullOrEmpty(ShaderMetaDataUtility.FindPolybrushMetaDataForShader(shader)));
#pragma warning restore 0618
            // Check tha
            AttributeLayoutContainer attributes = ShaderMetaDataUtility.LoadShaderMetaData(shader);
            Assert.IsNotNull(attributes);
            Assert.IsNotNull(attributes.attributes);

            // Clean up
            FileUtil.DeleteFileOrDirectory(k_DestFilePathToShaderWithOldMetaFormat);
            FileUtil.DeleteFileOrDirectory(k_DestFilePathToShaderWithOldMetaFormat + ".meta");
            FileUtil.DeleteFileOrDirectory(k_DestFilePathToShaderWithOldMetaFormatPBS);
            FileUtil.DeleteFileOrDirectory(k_DestFilePathToShaderWithOldMetaFormatPBS + ".meta");

            AssetDatabase.Refresh();
        }
コード例 #6
0
 public void LoadShaderMetaData_ArgumentNull_ThrowException()
 {
     Assert.Throws <ArgumentNullException>(() => ShaderMetaDataUtility.LoadShaderMetaData(null));
 }