Skip to content

Instantly share code, notes, and snippets.

@CapnRat
Last active December 20, 2015 01:19
Show Gist options
  • Save CapnRat/6048145 to your computer and use it in GitHub Desktop.
Save CapnRat/6048145 to your computer and use it in GitHub Desktop.
using UnityEngine;
public class CompiledShaderBehaviour : MonoBehaviour
{
public Shader shader;
}
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