Search Unity

EditorGUILayout.Foldout in ShaderGUI not hiding controls

Discussion in 'Immediate Mode GUI (IMGUI)' started by GearKlik, Jun 30, 2017.

  1. GearKlik

    GearKlik

    Joined:
    Sep 21, 2015
    Posts:
    58
    I'm tying to add foldouts to a custom shader UI but can't get them to hide anything. EditorGUILayout.Foldout calls Repaint but repaint isn't defined in ShaderGUI so I get a script error every time i click the foldout.

    Can you use foldouts in ShaderGUI?

    Example code that fails:
    Code (CSharp):
    1. using UnityEditor;
    2.  
    3. public class BRFX_Uber_UI : ShaderGUI
    4. {
    5.     private MaterialEditor matEd = null;
    6.     public override void OnGUI(MaterialEditor materialEditor, MaterialProperty[] properties)
    7.     {
    8.         matEd = materialEditor;
    9.  
    10.         bool myFold = true;
    11.         myFold = EditorGUILayout.Foldout(myFold, "foldoutYay");
    12.        
    13.         if (myFold)
    14.         {
    15.             EditorGUILayout.LabelField("Time since start: ", EditorApplication.timeSinceStartup.ToString());
    16.         }
    17.     }  
    18.  
    19.     // Fixes assert but still doesnt work
    20.     public void Repaint()
    21.     {
    22.         if(matEd != null)
    23.         {
    24.             matEd.Repaint();
    25.         }
    26.     }
    TNKS!

    G
     
  2. GeoEuclid

    GeoEuclid

    Joined:
    Sep 14, 2013
    Posts:
    20
    Did you ever figure this out?