Skip to content

Commit fc4d831

Browse files
committed
add CustomGUI
1 parent 30e3aa0 commit fc4d831

20 files changed

+189
-74
lines changed

CHANGELOG.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,11 @@
11
# RapidGUI
22
Unity IMGUI extension for Rapid prototyping/development.
33

4+
## [1.2.0] - 2020-04-28
5+
### Added
6+
- CustomGUI: Configure the GUI from outside the class instead of the attributes.
7+
8+
49
## [1.1.0] - 2020-02-24
510
### Added
611
- IgnoreFieldScope: Ignore fields with specified names in recursive display

Example/RapidGUIExample.unity

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -131,7 +131,7 @@ GameObject:
131131
- component: {fileID: 113337801}
132132
- component: {fileID: 113337802}
133133
m_Layer: 0
134-
m_Name: FieldExample_Part2
134+
m_Name: FieldWithClassExample
135135
m_TagString: Untagged
136136
m_Icon: {fileID: 0}
137137
m_NavMeshLayer: 0
@@ -380,7 +380,7 @@ GameObject:
380380
- component: {fileID: 607490101}
381381
- component: {fileID: 607490102}
382382
m_Layer: 0
383-
m_Name: FieldExample_Part1
383+
m_Name: FieldExample
384384
m_TagString: Untagged
385385
m_Icon: {fileID: 0}
386386
m_NavMeshLayer: 0

Example/Scripts/FieldExample_Part1.cs renamed to Example/Scripts/FieldExample.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ namespace RapidGUI.Example
88
/// <summary>
99
/// RGUI.Field() examples part1
1010
/// </summary>
11-
public class FieldExample_Part1 : ExampleBase
11+
public class FieldExample : ExampleBase
1212
{
1313
public enum EnumSample
1414
{
@@ -47,7 +47,7 @@ public enum EnumSampleFlags
4747
public float[] arrayVal;
4848
public List<int> listVal;
4949

50-
protected override string title => "RGUI.Field() Part1";
50+
protected override string title => "RGUI.Field()s";
5151

5252
public override void DoGUI()
5353
{
File renamed without changes.

Example/Scripts/FieldExample_Part2.cs renamed to Example/Scripts/FieldWithClassExample.cs

Lines changed: 34 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ namespace RapidGUI.Example
88
/// <summary>
99
/// RGUI.Field() examples part2
1010
/// </summary>
11-
public class FieldExample_Part2 : ExampleBase
11+
public class FieldWithClassExample : ExampleBase
1212
{
1313
/// <summary>
1414
/// Simple Class
@@ -17,7 +17,7 @@ public class FieldExample_Part2 : ExampleBase
1717
/// - If field name is long, name and value are displayed in multiple lines
1818
/// </summary>
1919
[Serializable]
20-
public class CustomClass
20+
public class MyClass
2121
{
2222
public int publicField;
2323

@@ -30,10 +30,25 @@ public class CustomClass
3030
[Range(0f, 10f)]
3131
public float rangeVal;
3232

33+
[Range(0f, 10f)] // The Range attribute is applied to a variety of numeric types
34+
public Vector3Int rangeVec3Int;
35+
3336
public string longNameFieldWillBeMultiLine;
3437
}
35-
36-
38+
39+
/// <summary>
40+
/// CustomGUIClass
41+
/// - If you can't add an attribute to a class, you can specify a GUI from outside by using CustomGUI.
42+
/// - See also Start().
43+
/// </summary>
44+
public class CustomGUIClass
45+
{
46+
public int value0;
47+
public int value1;
48+
public int value2;
49+
}
50+
51+
3752
/// <summary>
3853
/// RobustTestClass
3954
/// </summary>
@@ -45,7 +60,7 @@ public class RobustTestClass
4560

4661
/// <summary>
4762
/// ClassWithIDoGUI
48-
/// Class with IDoGUI will automatically call DoGUI within an Array/List and another class
63+
/// - Class with IDoGUI will automatically call DoGUI within an Array/List and another class
4964
/// </summary>
5065
public class ClassWithIDoGUI : IDoGUI
5166
{
@@ -67,7 +82,7 @@ public void DoGUI()
6782

6883
/// <summary>
6984
/// ClassWithICloneable
70-
/// - if class is ICloneable or has Copy Constructor then Array/List element will be duplicate when add new element.
85+
/// - If class is ICloneable or has Copy Constructor then Array/List element will be duplicate when add new element.
7186
/// </summary>
7287
public class ClassWithICloneable : ICloneable
7388
{
@@ -83,28 +98,36 @@ public object Clone()
8398
}
8499

85100

86-
public CustomClass customClass = new CustomClass();
101+
102+
103+
public MyClass myClass = new MyClass();
104+
public CustomGUIClass customGUIClass = new CustomGUIClass();
87105
public RobustTestClass robustTestClass = new RobustTestClass();
88106
public List<ClassWithIDoGUI> classWithIDoGUIList = new List<ClassWithIDoGUI>();
89107
public List<ClassWithICloneable> classWithICloneableList = new List<ClassWithICloneable>();
90108

91109
private void Start()
92110
{
93111
robustTestClass.selfReference = robustTestClass; // circular reference
112+
113+
CustomGUI.Label<CustomGUIClass>("value0", "label changed");
114+
CustomGUI.IgnoreMember<CustomGUIClass>("value1");
115+
CustomGUI.AddRange<CustomGUIClass>("value2", new MinMaxFloat() { max = 100f });
94116
}
95-
117+
96118
public override void DoGUI()
97119
{
98-
customClass = RGUI.Field(customClass, nameof(customClass));
120+
myClass = RGUI.Field(myClass, nameof(myClass));
121+
customGUIClass = RGUI.Field(customGUIClass, nameof(customGUIClass));
99122
robustTestClass = RGUI.Field(robustTestClass, nameof(robustTestClass));
100123

101124
GUILayout.Label("ClassWithIDoGUI - automatically call DoGUI within an Array/List and another class.");
102125
classWithIDoGUIList = RGUI.Field(classWithIDoGUIList, nameof(classWithIDoGUIList));
103-
126+
104127
GUILayout.Label("ClassWithICloneable - element will be duplicated when add new element.");
105128
classWithICloneableList = RGUI.Field(classWithICloneableList, nameof(classWithICloneableList));
106129
}
107130

108-
protected override string title => "RGUI.Field() Part2";
131+
protected override string title => "RGUI.Field() with class";
109132
}
110133
}

Example/Scripts/FoldExample.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ void InitFolds()
5555
() => GUILayout.Label("Displayed only when checkEnableFunc return true.")
5656
);
5757

58-
folds.Add("finds the type of IDoGUI in the scene.", typeof(FieldExample_Part1));
58+
folds.Add("finds the type of IDoGUI in the scene.", typeof(FieldExample));
5959
}
6060

6161

Example/Scripts/RapidGUIExample.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,8 @@ public void Start()
1717
name = "WindowLaunchers"
1818
};
1919

20-
launchers.Add("RGUI.Field() Part1", typeof(FieldExample_Part1));
21-
launchers.Add("RGUI.Field() Part2", typeof(FieldExample_Part2));
20+
launchers.Add("RGUI.Field()", typeof(FieldExample));
21+
launchers.Add("RGUI.Field() with class", typeof(FieldWithClassExample));
2222
launchers.Add("RGUI.Slider()", typeof(SliderExample));
2323
launchers.Add("RGUI.MinMaxSlider()", typeof(MinMaxSliderExample));
2424
launchers.Add("Scope", typeof(ScopeExample));

Example/Scripts/WindowLauncherExample.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ void InitFolds()
5959
() => GUILayout.Label("Displayed only when checkEnableFunc return true.")
6060
);
6161

62-
launchers.Add("finds the type of IDoGUI in the scene.", typeof(FieldExample_Part1));
62+
launchers.Add("finds the type of IDoGUI in the scene.", typeof(FieldExample));
6363
}
6464

6565

Runtime/Component/Utilities/TypeUtility.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ public static bool IsMultiLine(Type type)
2020
{
2121
var infoList = GetMemberInfoList(type);
2222

23-
ret = infoList.Any(info => info.Range != null);
23+
ret = infoList.Any(info => info.range != null);
2424
if (!ret)
2525
{
2626
var elemtTypes = infoList.Select(info => info.MemberType);

0 commit comments

Comments
 (0)