MatEdit Doc
How To Start
Manual
In order to support you taking your first steps with MatEdit we provide this "How to Start" guide.

Simply follow the given steps in order to create your custom material inspectors:

  1. Right-click the shader you want to enhance with a custom material inspector and select "Create > MatEdit > Create ShaderGUI"
  2. Open the editor script generated in the folder "Editor" relative to the shader file.
  3. Select the presented method under the SetScope() method call.
  4. Use any MatGUI method to create new fields for the material inspector.

If you plan to add it manually or in an already existing ShaderGUI follow the upcoming instructions instead:

  1. Create a new C# script and name it as you wish. It is recommended to call it relatable to your shader.
  2. Open the script in the script editor of your choice.
  3. Remove all MonoBehaviour related functions etc.
  4. Use “MB.MatEdit” and “UnityEditor”.
  5. Inherit from “ShaderGUI” and implement the method “OnGUI”
  6. At this point it is recommended to use “MatGUI.SetScope” to define the target of all upcoming operations.
  7. Use any MatGUI-Field method you want.
  8. To bind this GUI to the shader open your shader and insert before the last braces: CustomEditor “YourGUIScript”

Possibilities

Giving you a more user friendly and readable approach for GUI code is not the only task MatEdit tries to fulfill.

By using the special fields you can enable the user to change Color Gradients and Animation Curves directly in the material inspector. These fields generate a texture which can be read in the shader.

In order to guarantee the smooth functionality of MatEdit in future updates it is recommended to use the cg-inclusions provided with MatEdit. These cginc files can be placed manually in your shader's folder or can be used project wide by using the installation button in the about window. The cginc files provide a method for converting the textures back into Color Gradients or Animation Curves.