-
-
Notifications
You must be signed in to change notification settings - Fork 28
/
Copy pathFoldExample.cs
79 lines (58 loc) · 2.01 KB
/
FoldExample.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
using UnityEngine;
namespace RapidGUI.Example
{
public class FoldExample : ExampleBase
{
Fold fold;
Folds folds;
public bool isEnable = true;
private void Start()
{
InitFold();
InitFolds();
}
void InitFold()
{
fold = new Fold("Fold");
// add funcion
fold.Add(() => GUILayout.Label("Added function"));
// add function with checkEnableFunc
// Called only when checkEnableFunc returns true.
fold.Add(
() => isEnable,
() => GUILayout.Label("With checkEnableFunc.")
);
// add title label action
fold.SetTitleAction(() => GUILayout.Label("Title Action"));
// set open first
fold.Open();
}
void InitFolds()
{
folds = new Folds();
// Add() returns Fold. so you can method chains.
folds.Add("Simple Add()", () => GUILayout.Label("This is Folds."))
.SetTitleAction(() => GUILayout.Label("Title Action"))
.Open();
// if name used already, it will margined.
folds.Add("Simple Add()", () => GUILayout.Label("added by same name"));
folds.Add("With checkEnableFunc.",
() => isEnable,
() => GUILayout.Label("Displayed only when checkEnableFunc return true.")
);
folds.Add("finds the type of IDoGUI in the scene.", typeof(FieldExample));
}
protected override string title => "Fold, Folds";
public override void DoGUI()
{
isEnable = GUILayout.Toggle(isEnable, "checkEnableFunc return value");
using (new GUILayout.VerticalScope(GUILayout.MinWidth(500f)))
{
fold.DoGUI();
GUILayout.Space(10f);
GUILayout.Label("<b>Folds</b>");
folds.DoGUI();
}
}
}
}