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. Dismiss Notice

Show Material Editor on Custom Inspector

Discussion in 'Editor & General Support' started by popMark, Nov 30, 2014.

  1. popMark

    popMark

    Joined:
    Apr 14, 2013
    Posts:
    114
    Hi all,

    I have a script with a custom inspector and a material property and I would like to show the default Unity material editor at the bottom of the inspector when the object is selected, but I can't figure out how?

    Is it possible?
     
  2. LightStriker

    LightStriker

    Joined:
    Aug 3, 2013
    Posts:
    2,716
    It is possible, but not really easy. Unity didn't really exposed much for that purpose except the access to draw something on the preview section. It's pretty much up to you to draw that in that section.

    You're best bet is to explore the PreviewUtility class, and to reverse engineer what they did in Unity.

    I ended up writing my own stuff to support all the preview I could imagine.
     
  3. popMark

    popMark

    Joined:
    Apr 14, 2013
    Posts:
    114
    Hmm, its not so much the material preview I want as the property inspectors and shader selection drop down, so that the user can change a materials properties

    Its a specific shader set so I will be able to hard code the properties, but I like the familiarity the standard inspector brings
     
  4. LightStriker

    LightStriker

    Joined:
    Aug 3, 2013
    Posts:
    2,716
    You can write your own custom editor that replicate what the MaterialEditor does... You should get yourself a IL explorer to see how Unity did it in UnityEditor.dll
     
  5. Xaurrien

    Xaurrien

    Joined:
    Jul 2, 2012
    Posts:
    20