Skip to content

Commit 99ac6d6

Browse files
committed
Add IReadOnlyPrefs interface.
1 parent ef75786 commit 99ac6d6

File tree

5 files changed

+56
-5
lines changed

5 files changed

+56
-5
lines changed

Assets/PrefsUGUI/Examples/Scripts/Example.cs

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@ namespace PrefsUGUI.Examples
77
[AddComponentMenu("")]
88
public partial class Example : MonoBehaviour
99
{
10+
public IReadOnlyPrefs<string> Label => this.label;
11+
1012
#pragma warning disable 0414
1113
public Test2Ex1 Test2Ex = new Test2Ex1();
1214

@@ -45,7 +47,12 @@ private void Awake()
4547
this.prefsRect.TopMargin = 15f;
4648
}
4749

48-
void Update()
50+
private void Start()
51+
{
52+
Debug.Log(this.Label.Get());
53+
}
54+
55+
private void Update()
4956
{
5057
if(Input.GetKeyDown(KeyCode.S))
5158
{

Assets/PrefsUGUI/Scripts/Prefs/Abstracts/PrefsGuiBaseConnector.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ namespace PrefsUGUI
88
public static partial class Prefs
99
{
1010
[Serializable]
11-
public abstract class PrefsGuiBaseConnector<ValType, GuiType> : PrefsValueBase<ValType> where GuiType : PrefsGuiBase
11+
public abstract class PrefsGuiBaseConnector<ValType, GuiType> : PrefsValueBase<ValType>, IReadOnlyPrefs<ValType> where GuiType : PrefsGuiBase
1212
{
1313
public event Action OnCreatedGui = delegate { };
1414

@@ -30,7 +30,7 @@ public virtual bool VisibleGUI
3030
get { return this.gui == null ? false : this.gui.gameObject.activeSelf; }
3131
set { this.gui?.gameObject.SetActive(value); }
3232
}
33-
public string GuiLabelPrefix
33+
public virtual string GuiLabelPrefix
3434
{
3535
get { return this.guiLabelPrefix; }
3636
set
@@ -39,7 +39,7 @@ public string GuiLabelPrefix
3939
this.UpdateLabel();
4040
}
4141
}
42-
public string GuiLabelSufix
42+
public virtual string GuiLabelSufix
4343
{
4444
get { return this.guiLabelSufix; }
4545
set
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
using System;
2+
3+
namespace PrefsUGUI
4+
{
5+
public interface IReadOnlyPrefs<ValType>
6+
{
7+
#region "PrefsBase"
8+
event Action OnValueChanged;
9+
10+
string Key { get; }
11+
string GuiLabel { get; }
12+
#endregion
13+
14+
#region "PrefsValueBase"
15+
ValType Value { get; }
16+
ValType DefaultValue { get; }
17+
Type ValueType { get; }
18+
19+
ValType Get();
20+
#endregion
21+
22+
#region "PrefsGUiBaseConnector"
23+
event Action OnCreatedGui;
24+
25+
string GuiLabelWithoutAffix { get; }
26+
float BottomMargin { get; }
27+
float TopMargin { get; }
28+
bool VisibleGUI { get; }
29+
string GuiLabelPrefix { get; }
30+
string GuiLabelSufix { get; }
31+
#endregion
32+
}
33+
}

Assets/PrefsUGUI/Scripts/Prefs/IReadOnlyPrefs.cs.meta

Lines changed: 11 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Assets/PrefsUGUI/Version.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
1.1.1
1+
1.2.0

0 commit comments

Comments
 (0)