static void CreateShaderMetaData() { string path = ""; foreach (Shader shader in Selection.objects) { 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"), }; #pragma warning disable 0618 path = ShaderMetaDataUtility.SaveMeshAttributesData(shader, attributes, true); #pragma warning restore 0618 } AssetDatabase.Refresh(); TextAsset asset = AssetDatabase.LoadAssetAtPath <TextAsset>(path); if (asset != null) { EditorGUIUtility.PingObject(asset); } }
public override void OnInspectorGUI() { TextAsset asset = target as TextAsset; if (asset == null || !asset.name.EndsWith(".pbs")) { // sfor whatever reason this doesn't work // DrawDefaultInspector(); DrawTextAssetInspector(); return; } if (editor == null) { #pragma warning disable 0618 ShaderMetaDataUtility.TryReadAttributeLayoutsFromJson(asset.text, out container); #pragma warning disable 0618 editor = Editor.CreateEditor(container); } GUI.enabled = true; EditorGUI.BeginChangeCheck(); editor.OnInspectorGUI(); if (EditorGUI.EndChangeCheck()) { modified = true; } GUILayout.BeginHorizontal(); GUILayout.FlexibleSpace(); GUI.enabled = modified; if (GUILayout.Button("Revert")) { ReloadJson(); } if (GUILayout.Button("Apply")) { ShaderMetaDataUtility.SaveMeshAttributesData(container, true); ReloadJson(); } GUILayout.EndHorizontal(); GUI.enabled = false; }