GUILayout.Button - how to display content when button pressed in Inspector?

Hi this is a very easy and straight forward question:

I have created this button in my custom inspector but when I press the button, it does not display the content I want displayed. how do I display the content?

Thanks.

 if (GUILayout.Button("Texture Channel 0"))
                        {
                            planet.planetMaterial.SetFloat("_Metallic1", planet.metallicValue);
                            planet.metallicValue = EditorGUILayout.Slider(new GUIContent("Metallic Value"), planet.metallicValue, 0f, 1f);
                        }

My editor scripting knowledge is limited. I did not research this at all, so at best it’s partial :slight_smile:

Anyways, this appears to be working for me with a simple class / variable…

bool showSlider = false;
    public override void OnInspectorGUI()
    {
        Test1 t1 = target as Test1;
      
        if (GUILayout.Button("Whatever"))
        {
            showSlider = !showSlider;
        }
        if (showSlider)
            t1.someInt = EditorGUILayout.IntSlider(t1.someInt, 0, 20);      
    }
1 Like

Thanks that works for me!

Cool, you’re welcome :slight_smile: