Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. We have updated the language to the Editor Terms based on feedback from our employees and community. Learn more.
    Dismiss Notice
  3. Join us on November 16th, 2023, between 1 pm and 9 pm CET for Ask the Experts Online on Discord and on Unity Discussions.
    Dismiss Notice

Custom Editors for Shaders?

Discussion in 'Scripting' started by ATLAS-INTERACTIVE, Oct 4, 2015.

  1. ATLAS-INTERACTIVE

    ATLAS-INTERACTIVE

    Joined:
    Mar 3, 2014
    Posts:
    1,421
    After developing a series of very large shaders, I feel I am in need of a custom inspector for them as they take up far too much room.
    I like the look of the Standard Shader editor with the small texture boxes, but have no idea where to start, not very many people do this to shaders but I feel like I should probably have them.

    Does anyone know how to write custom inspectors for shaders?
     
  2. Roland1234

    Roland1234

    Joined:
    Nov 21, 2012
    Posts:
    190
    You can define a custom editor for a shader by deriving from ShaderGUI, and adding
    Code (csharp):
    1.  
    2. Shader "ShaderName"
    3. {
    4.     [...]
    5.     CustomEditor "NameOfCustomGUI"
    6. }
    7.  
    to the shader itself.

    I have little experience with this myself, but it looks like you can use standard EditorGUI calls in this.
    Check Unity's built-in shaders for examples.
    Cheers!