-
-
Notifications
You must be signed in to change notification settings - Fork 27
/
WindowLauncherExample.cs
87 lines (65 loc) · 2.37 KB
/
WindowLauncherExample.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
80
81
82
83
84
85
86
87
using System;
using System.Collections.Generic;
using UnityEngine;
namespace RapidGUI.Example
{
public class WindowLauncherExample : ExampleBase
{
WindowLauncher launcher;
WindowLaunchers launchers;
public bool isEnable = true;
private void Start()
{
InitFold();
InitFolds();
}
void InitFold()
{
launcher = new WindowLauncher("WindowLauncher");
// add funcion
launcher.Add(() => GUILayout.Label("Added function"));
// add function with checkEnableFunc
// Called only when checkEnableFunc returns true.
launcher.Add(
() => isEnable,
() => GUILayout.Label("With checkEnableFunc.")
);
// add title label action
launcher.SetTitleAction(() => GUILayout.Label("Title Action"));
}
void InitFolds()
{
launchers = new WindowLaunchers()
{
isWindow = false
};
// Add() returns Fold. so you can method chains.
// SetWidth() can set window width.
launchers.Add("Simple Add()", () => GUILayout.Label("This is WindowLaunchers."))
.SetTitleAction(() => GUILayout.Label("Title Action"))
.SetWidth(500f);
// if name used already, it will margined.
launchers.Add("Simple Add()", () => GUILayout.Label("added by same name"));
launchers.Add("With checkEnableFunc.",
() => isEnable,
() => GUILayout.Label("Displayed only when checkEnableFunc return true.")
);
launchers.Add("finds the type of IDoGUI in the scene.", typeof(FieldExample));
}
protected override string title => "WindowLancuer, WindowLancuers";
public override void DoGUI()
{
isEnable = GUILayout.Toggle(isEnable, "checkEnableFunc return value");
using (new GUILayout.HorizontalScope())
{
using (new GUILayout.VerticalScope(GUILayout.MinWidth(500f)))
{
launcher.DoGUI();
GUILayout.Space(10f);
GUILayout.Label("<b>WindowLaunchers</b>");
launchers.DoGUI();
}
}
}
}
}