Last active
December 20, 2015 01:19
-
-
Save CapnRat/6048145 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using UnityEngine; | |
public class CompiledShaderBehaviour : MonoBehaviour | |
{ | |
public Shader shader; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using UnityEngine; | |
using UnityEditor; | |
[CustomEditor(typeof(CompiledShaderBehaviour))] | |
public class CompiledShaderBehaviourEditor : Editor | |
{ | |
SerializedProperty shaderProperty; | |
public void OnEnable () | |
{ | |
shaderProperty = serializedObject.FindProperty ("shader"); | |
} | |
public override void OnInspectorGUI () | |
{ | |
serializedObject.Update (); | |
EditorGUILayout.PropertyField (shaderProperty); | |
Shader shader = shaderProperty.objectReferenceValue as Shader; | |
if (shader) | |
{ | |
string compiledShaderString = (new SerializedObject(shader)).FindProperty("m_Script").stringValue; | |
EditorGUILayout.TextArea (compiledShaderString); | |
} | |
serializedObject.ApplyModifiedProperties (); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment