Create Inspector panel buttons

I am trying to figure out a way to generate GUILayout.Buttons for my inspector panel based upon data that I am pulling from firebase. Is it possible to create these buttons after reading in the data almost like instantiation?

Example: I have 4 types of skins that I have within my database. I want to dynamically create a way to add buttons on the inspector panel for each skin


You would need to get the data and serialize it somewhere and then use that serialized data to decide how to display stuff. Otherwise every time the unity editor paints, you would have to issue a fresh pull from firebase.

1 Like

Okay well I find that my issue is I am not sure how to instantiate the buttons within the Inspector panel

You don’t instantiate it. It’s an immediate-mode GUI. You draw it with GUILayout each frame you want it there. Look up how to make a custom inspector, or you’re welcome to see an incidental example in my Datasacks module here:

https://github.com/kurtdekker/datasacks/blob/master/datasacks/Assets/Datasack/Core/DatasackInspector.cs

Example of buttons on or about line 318, 325, 332, etc.

7988967--1026513--Screen Shot 2022-03-23 at 2.31.22 PM.png

1 Like

I might be miss understood but that is okay because I need to work on my explanation of things better. But it sounds like I can’t draw GUI Buttons without directly setting it within the script

Yes, the GUI interface is immediate mode, not retained mode. The Unity scene in contrast is a retained mode.

https://en.wikipedia.org/wiki/Retained_mode

1 Like