Skip to content

Commit a29f107

Browse files
committed
PrefsLabelを追加して、Exampleを整理して、PrefsButtonが表示されなくなっていたのを習性
1 parent f9c0faa commit a29f107

26 files changed

+748
-167
lines changed

Diff for: Assets/PrefsUGUI/Examples/PrefsUGUI.unity

+86-59
Original file line numberDiff line numberDiff line change
@@ -215,109 +215,136 @@ MonoBehaviour:
215215
m_Script: {fileID: 11500000, guid: 21f00f1ac44a51645b3a62679bbcb467, type: 3}
216216
m_Name:
217217
m_EditorClassIdentifier:
218-
hogeFuga:
219-
v1:
220-
key: HogeFuga - v1
221-
guiLabel: Hoge Fuga - v1
222-
defaultValue: {x: 1, y: 1}
223-
guiLabelPrefix:
224-
guiLabelSufix:
225-
v2:
226-
key: HogeFuga - v2
227-
guiLabel: Hoge Fuga - v2
228-
defaultValue: {x: 2.5, y: 2.5}
229-
guiLabelPrefix:
230-
guiLabelSufix:
231-
hogeFugaPi:
232-
v1:
233-
key: HogeFugaPi - v1
234-
guiLabel: Hoge Fuga Pi - v1
235-
defaultValue: {x: 1, y: 0}
218+
Test2Ex:
219+
PrefsFloatSlider:
220+
key: PrefsFloatSlider2
221+
guiLabel: Prefs Float Slider2
222+
defaultValue: 10
236223
guiLabelPrefix:
237224
guiLabelSufix:
238-
v2:
239-
key: HogeFugaPi - v2
240-
guiLabel: Hoge Fuga Pi - v2
241-
defaultValue: {x: -1, y: 0}
225+
PrefsIntSlider:
226+
key: PrefsIntSlider2
227+
guiLabel: Prefs Int Slider2
228+
defaultValue: 20
242229
guiLabelPrefix:
243230
guiLabelSufix:
244-
v1:
245-
key: v1
246-
guiLabel: v1
247-
defaultValue: {x: 0, y: 0}
248-
guiLabelPrefix:
249-
guiLabelSufix:
250-
v2:
251-
key: v2
252-
guiLabel: v2
253-
defaultValue: {x: 1, y: 1}
254-
guiLabelPrefix:
255-
guiLabelSufix:
256-
v3:
257-
key: v3
258-
guiLabel: v3
259-
defaultValue: {x: 2, y: 3}
260-
guiLabelPrefix:
261-
guiLabelSufix:
262-
test:
263-
b:
231+
test1:
232+
PrefsBool:
264233
key: PrefsBool
265234
guiLabel: Prefs <color=red>Bool</color>
266235
defaultValue: 1
267236
guiLabelPrefix:
268237
guiLabelSufix:
269-
c:
238+
PrefsColor:
270239
key: PrefsColor
271240
guiLabel: Prefs Color
272241
defaultValue: {r: 1, g: 0, b: 0, a: 1}
273242
guiLabelPrefix:
274243
guiLabelSufix:
275-
cs:
276-
key: ColorSlider
277-
guiLabel: Color Slider
244+
PrefsColorSlider:
245+
key: PrefsColorSlider
246+
guiLabel: Prefs Color Slider
278247
defaultValue: {r: 0, g: 0, b: 1, a: 1}
279248
guiLabelPrefix:
280249
guiLabelSufix:
281-
f:
250+
PrefsFloat:
282251
key: PrefsFloat
283252
guiLabel: Prefs Float
284-
defaultValue: 1
253+
defaultValue: 0.12345
285254
guiLabelPrefix:
286255
guiLabelSufix:
287-
fs:
256+
PrefsFloatSlider:
288257
key: PrefsFloatSlider
289258
guiLabel: Prefs Float Slider
290259
defaultValue: 5
291260
guiLabelPrefix:
292261
guiLabelSufix:
293-
i:
262+
PrefsInt:
294263
key: PrefsInt
295264
guiLabel: Prefs Int
296-
defaultValue: 5
265+
defaultValue: 3
297266
guiLabelPrefix:
298267
guiLabelSufix:
299-
isl:
268+
PrefsIntSlider:
300269
key: PrefsIntSlider
301270
guiLabel: Prefs Int Slider
302-
defaultValue: 5
271+
defaultValue: 2
272+
guiLabelPrefix:
273+
guiLabelSufix:
274+
PrefsButton1:
275+
key: Click1
276+
guiLabel: Click1
277+
guiLabelPrefix:
278+
guiLabelSufix:
279+
PrefsButton2:
280+
key: SwitchClick1
281+
guiLabel: Switch Click1
282+
guiLabelPrefix:
283+
guiLabelSufix:
284+
test2:
285+
PrefsString:
286+
key: PrefsString
287+
guiLabel: Prefs String
288+
defaultValue: Example
289+
guiLabelPrefix:
290+
guiLabelSufix:
291+
PrefsVector2:
292+
key: PrefsVector2
293+
guiLabel: Prefs Vector2
294+
defaultValue: {x: 1, y: 1}
295+
guiLabelPrefix:
296+
guiLabelSufix:
297+
PrefsVector2Int:
298+
key: PrefsVector2Int
299+
guiLabel: Prefs Vector2 Int
300+
defaultValue: {x: 1, y: 0}
301+
guiLabelPrefix:
302+
guiLabelSufix:
303+
PrefsButton3:
304+
key: PrefsButton3
305+
guiLabel: Prefs Button3
303306
guiLabelPrefix:
304307
guiLabelSufix:
305-
v6:
308+
prefsVector3:
306309
key: PrefsVector3
307310
guiLabel: Prefs Vector3
308-
defaultValue: {x: 2, y: 4, z: 6}
311+
defaultValue: {x: 0, y: -1, z: 0}
309312
guiLabelPrefix:
310313
guiLabelSufix:
311-
v7:
314+
prefsVector3Int:
312315
key: PrefsVector3Int
313316
guiLabel: Prefs Vector3 Int
314-
defaultValue: {x: -10, y: -5, z: 0}
317+
defaultValue: {x: -1, y: 0, z: 0}
315318
guiLabelPrefix:
316319
guiLabelSufix:
317-
v8:
320+
prefsVector4:
318321
key: PrefsVector4
319322
guiLabel: Prefs Vector4
320-
defaultValue: {x: -2, y: 0, z: 2, w: 100}
323+
defaultValue: {x: 0.1, y: 0.2, z: 0.3, w: 0.4}
324+
guiLabelPrefix:
325+
guiLabelSufix:
326+
test3:
327+
PrefsIntSliderUnsave:
328+
key: PrefsIntSliderUnsave
329+
guiLabel: Prefs Int Slider Unsave
330+
defaultValue: 5
331+
guiLabelPrefix:
332+
guiLabelSufix:
333+
PrefsLabel1:
334+
key: PrefsLabel1
335+
guiLabel: Prefs Label1
336+
defaultValue: Test
337+
guiLabelPrefix:
338+
guiLabelSufix:
339+
PrefsButton:
340+
key: ChangePrefsLabel1
341+
guiLabel: Change Prefs Label1
342+
guiLabelPrefix:
343+
guiLabelSufix:
344+
prefsLabel:
345+
key: PrefsLabel2
346+
guiLabel: Prefs Label2
347+
defaultValue: TimeExample
321348
guiLabelPrefix:
322349
guiLabelSufix:
323350
--- !u!20 &282840813

Diff for: Assets/PrefsUGUI/Examples/Scripts/Classes.cs

+95
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,95 @@
1+
using System;
2+
using UnityEngine;
3+
using UnityEngine.Events;
4+
5+
namespace PrefsUGUI.Examples
6+
{
7+
using static Structs;
8+
9+
public partial class Example : MonoBehaviour
10+
{
11+
#pragma warning disable 0414
12+
[Serializable]
13+
private class Test1
14+
{
15+
public PrefsBool PrefsBool = new PrefsBool("PrefsBool", true, HierarchyTest1, "Prefs " + RichTextColors.Red("Bool"));
16+
public PrefsColor PrefsColor = new PrefsColor("PrefsColor", Color.red, HierarchyTest1);
17+
public PrefsColorSlider PrefsColorSlider = new PrefsColorSlider("PrefsColorSlider", Color.blue, HierarchyTest1);
18+
public PrefsFloat PrefsFloat = new PrefsFloat("PrefsFloat", 0.12345f, HierarchyTest1);
19+
public PrefsFloatSlider PrefsFloatSlider = new PrefsFloatSlider("PrefsFloatSlider", 0f, 10f, 5f, HierarchyTest1);
20+
public PrefsInt PrefsInt = new PrefsInt("PrefsInt", 3, HierarchyTest1);
21+
public PrefsIntSlider PrefsIntSlider = new PrefsIntSlider("PrefsIntSlider", 0, 10, 2, HierarchyTest1);
22+
public PrefsButton PrefsButton1 = new PrefsButton("Click1", null, HierarchyTest1);
23+
24+
[SerializeField]
25+
private PrefsButton PrefsButton2 = new PrefsButton("SwitchClick1", null, HierarchyTest1);
26+
27+
28+
public Test1()
29+
{
30+
this.PrefsButton1.OnClicked = this.Click1;
31+
this.PrefsButton1.OnValueChanged += () => Debug.Log(nameof(this.PrefsButton1) + " : OnValueChanged");
32+
33+
var counter = 0;
34+
this.PrefsButton2.OnClicked += () => Debug.Log(nameof(this.PrefsButton2) + " : Clicked");
35+
this.PrefsButton2.OnClicked += ()
36+
=> this.PrefsButton1.OnClicked = ++counter % 2 == 0 ? (UnityAction)this.Click1 : this.Click2;
37+
}
38+
39+
private void Click1()
40+
=> Debug.Log(nameof(this.PrefsButton1) + " : Click1");
41+
42+
private void Click2()
43+
=> Debug.Log(nameof(this.PrefsButton1) + " : Click2");
44+
}
45+
46+
[Serializable]
47+
private class Test2
48+
{
49+
public PrefsString PrefsString = new PrefsString("PrefsString", "Example", HierarchyTest2);
50+
public PrefsVector2 PrefsVector2 = new PrefsVector2("PrefsVector2", Vector2.one, HierarchyTest2);
51+
public PrefsVector2Int PrefsVector2Int = new PrefsVector2Int("PrefsVector2Int", Vector2Int.right, HierarchyTest2);
52+
public PrefsButton PrefsButton3
53+
= new PrefsButton("PrefsButton3", () => Debug.Log(nameof(PrefsButton3) + " : Clicked"), HierarchyTest2);
54+
55+
[SerializeField]
56+
private PrefsVector3 prefsVector3 = new PrefsVector3("PrefsVector3", Vector3.down, HierarchyTest2);
57+
[SerializeField]
58+
private PrefsVector3Int prefsVector3Int = new PrefsVector3Int("PrefsVector3Int", Vector3Int.left, HierarchyTest2);
59+
[SerializeField]
60+
private PrefsVector4 prefsVector4 = new PrefsVector4("PrefsVector4", new Vector4(0.1f, 0.2f, 0.3f, 0.4f), HierarchyTest2);
61+
62+
63+
public Test2()
64+
{
65+
this.PrefsButton3.OnClicked += () => Debug.Log(nameof(this.PrefsButton3) + " : Clicked2");
66+
}
67+
}
68+
69+
[Serializable]
70+
public class Test2Ex1
71+
{
72+
public PrefsFloatSlider PrefsFloatSlider = new PrefsFloatSlider("PrefsFloatSlider2", 10f, HierarchyTest2Ex1);
73+
public PrefsIntSlider PrefsIntSlider = new PrefsIntSlider("PrefsIntSlider2", 20, HierarchyTest2Ex1);
74+
}
75+
76+
[Serializable]
77+
private class Test3
78+
{
79+
public PrefsIntSlider PrefsIntSliderUnsave = new PrefsIntSlider("PrefsIntSliderUnsave", 0, 10, 5, HierarchyTest3);
80+
public PrefsLabel PrefsLabel1 = new PrefsLabel("PrefsLabel1", "Test", HierarchyTest3);
81+
public PrefsButton PrefsButton = new PrefsButton("ChangePrefsLabel1", null, HierarchyTest3);
82+
83+
[SerializeField]
84+
private PrefsLabel prefsLabel = new PrefsLabel("PrefsLabel2", "TimeExample", HierarchyTest3);
85+
86+
87+
public Test3()
88+
{
89+
this.PrefsIntSliderUnsave.Unsave = true;
90+
this.PrefsButton.OnClicked += () => this.prefsLabel.Set(DateTime.Now.ToString());
91+
}
92+
}
93+
#pragma warning restore 0414
94+
}
95+
}

Diff for: Assets/PrefsUGUI/Examples/Scripts/Classes.cs.meta

+11
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)