Hi All,
I am trying to learn unity3d with c# but it is hard going! I have created a custom inspector with a simple single button. When the button is clicked It should create a foldout. If the button is clicked again it should display foldout2, then foldout3 etc. I can show you what I have managed to do so far…
using System;
using System.IO;
using UnityEngine;
using UnityEditor;
using System.Text;
using System.Collections;
public class Foldouts : EditorWindow
{
bool MyFoldout3 = false;
bool MyFoldout4 = false;
int increment = 0;
// Add menu named "Window/your script name" to the Window menu
[MenuItem("Window/Foldouts/Open")]
static void Init()
{
// Get existing open window or if none, make a new one:
Foldouts window = (Foldouts)EditorWindow.GetWindow(typeof(Foldouts));
}
void OnGUI() // void means won't return a value
{
GUILayout.BeginHorizontal();
GUILayout.Label(" ", EditorStyles.boldLabel);
if (GUILayout.Button("Make Foldout", GUILayout.Width(100)))
{
MyFoldout3 = EditorGUILayout.Foldout(MyFoldout3, "About.");
if (MyFoldout3)
{
GUILayout.Label("automated foldout", EditorStyles.largeLabel);
}
}
GUILayout.EndHorizontal();
MyFoldout4 = EditorGUILayout.Foldout(MyFoldout4, "hello World");
if (MyFoldout4)
{
EditorGUILayout.Space();
GUILayout.Label("Just testing", EditorStyles.whiteLargeLabel);
}
}
}
being a newby to programming I think I need a counter variable, a create new foldout function as such and something that creates the new foldout name/number. Just not sure how to go about it yet or even where to start.
Thanks
john