Example #1
0
        static void CreateShaderMetaData()
        {
            string path = "";

            foreach (Shader shader in Selection.objects)
            {
                z_AttributeLayout[] attributes = new z_AttributeLayout[]
                {
                    new z_AttributeLayout(z_MeshChannel.Color, z_ComponentIndex.R, Vector2.up, 0, "_Texture1"),
                    new z_AttributeLayout(z_MeshChannel.Color, z_ComponentIndex.G, Vector2.up, 0, "_Texture2"),
                    new z_AttributeLayout(z_MeshChannel.Color, z_ComponentIndex.B, Vector2.up, 0, "_Texture3"),
                    new z_AttributeLayout(z_MeshChannel.Color, z_ComponentIndex.A, Vector2.up, 0, "_Texture4"),
                };

                path = z_EditorUtility.SaveMeshAttributesData(shader, attributes, true);
            }

            AssetDatabase.Refresh();

            TextAsset asset = AssetDatabase.LoadAssetAtPath <TextAsset>(path);

            if (asset != null)
            {
                EditorGUIUtility.PingObject(asset);
            }
        }
Example #2
0
        // legacy route (define Z_TEXTURE_CHANNELS X)
        // doesn't support masks or different ranges.
        public static bool GetMeshAttributes_Legacy(Material material, out z_AttributeLayout[] attributes)
        {
            attributes = null;

            string src = GetSource(material);

            if (string.IsNullOrEmpty(src))
            {
                return(false);
            }

            int expectedTextureCount = GetTextureChannelCount(src);

            if (expectedTextureCount < 1)
            {
                return(false);
            }

            z_MeshChannel[] channels = GetUsedMeshAttributes(src);

            if (channels == null)
            {
                return(false);
            }

            string[] textureProperties;

            Texture2D[] textures;

            GetBlendTextures(material, src, expectedTextureCount, out textures, out textureProperties);

            attributes = new z_AttributeLayout[expectedTextureCount];

            //Debug.LogError("ExpectedTex:"+expectedTextureCount+":"+channels.Length+":"+MyLib.Util.printer.PrintObject(channels)+":"+src);
            for (int i = 0; i < expectedTextureCount; i++)
            {
                attributes[i] = new z_AttributeLayout(
                    channels[i / 4],
                    (z_ComponentIndex)(i % 4),
                    z_AttributeLayout.NormalizedRange,
                    z_AttributeLayout.DefaultMask,
                    textureProperties[i],
                    textures[i]);
            }

            return(true);
        }
 public float this[z_AttributeLayout attribute]
 {
     get { return(GetAttributeValue(attribute)); }
     set { SetAttributeValue(attribute, value); }
 }
 public void SetAttributeValue(z_AttributeLayout attrib, float value)
 {
     values[map[attrib.channel] * 4 + (int)attrib.index] = value;
 }
 public float GetAttributeValue(z_AttributeLayout attrib)
 {
     return(values[map[attrib.channel] * 4 + (int)attrib.index]);
 }