|
I noticed some scripts have different options in collapsible menus in the inspector. For example there's a collapsible menu named "Resolution" and when you open it, it shows the properties. How do they do it? In c# preferred, but I guess I could possibly convert from js. Thanks
(comments are locked)
|
|
You can use the EditorGUILayout.Foldout control. It is basically just a special toggle control; assign it to a boolean, and if it is true then draw the controls "inside", if it is false then don't. That requires using unityeditor, I don't want that. I've seen this being done without unityeditor
Mar 01 '11 at 05:45 PM
Johan 4
Your question does say "in the inspector". Anyway, there isn't really any magic to it; it is just a toggle that displays a little arrow icon pointing sideways or down. So if you want one at runtime, just use Toggle with a couple custom styles that contain arrows.
Mar 01 '11 at 06:06 PM
Molix
(comments are locked)
|
|
I'm sure this question is incredibly old but i stumbled upon it while looking for something else. Based on the comments you need to make a serializable class to contain the data you want to be foldable. So in my FakeDataBehaviour as a monobehaviour, we have a FakeData class that contains something interesting. We define multiple ones inside my class. In the inspector, these will appear as foldable objects for setting the specific values. for example: { [System.Serializable] public class Data { string name; float someValue; } [SerializeField] Data myData1; [SerializeField] Data myData2; // do more stuff... }
(comments are locked)
|
