Skip to content

Commit 6ee7f7f

Browse files
committed
PrefsGuiImageLabelを追加
1 parent d16d32b commit 6ee7f7f

File tree

8 files changed

+762
-2
lines changed

8 files changed

+762
-2
lines changed

Assets/PrefsUGUI/Prefabs/Guis/Prefs/PrefsImageLabel.prefab

Lines changed: 666 additions & 0 deletions
Large diffs are not rendered by default.

Assets/PrefsUGUI/Prefabs/Guis/Prefs/PrefsImageLabel.prefab.meta

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

Assets/PrefsUGUI/Prefabs/PrefsCanvas.prefab

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1147,6 +1147,9 @@ MonoBehaviour:
11471147
- key: PrefsGuiLabel
11481148
prefab: {fileID: 114390116732711480, guid: 1e1ca0b8eeedc604581a9743e958c359,
11491149
type: 2}
1150+
- key: PrefsGuiImageLabel
1151+
prefab: {fileID: 114738236854438500, guid: 2bdce11f31a54e641838985d763d817f,
1152+
type: 2}
11501153
--- !u!114 &114727951694102646
11511154
MonoBehaviour:
11521155
m_ObjectHideFlags: 1

Assets/PrefsUGUI/Scripts/Guis/Factories/Classes/GuiPrefabs.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -44,8 +44,8 @@ public class GuiPrefabs
4444
new GuiPrefab(typeof(PrefsGuiString)), new GuiPrefab(typeof(PrefsGuiVector2)),
4545
new GuiPrefab(typeof(PrefsGuiVector2Int)), new GuiPrefab(typeof(PrefsGuiVector3)),
4646
new GuiPrefab(typeof(PrefsGuiVector3Int)), new GuiPrefab(typeof(PrefsGuiVector4)),
47-
new GuiPrefab(typeof(PrefsGuiRect)),
48-
new GuiPrefab(typeof(GuiButton)), new GuiPrefab(typeof(PrefsGuiLabel))
47+
new GuiPrefab(typeof(PrefsGuiRect)), new GuiPrefab(typeof(GuiButton)),
48+
new GuiPrefab(typeof(PrefsGuiLabel)), new GuiPrefab(typeof(PrefsGuiImageLabel))
4949
};
5050

5151

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
using UnityEngine;
2+
using UnityEngine.UI;
3+
4+
namespace PrefsUGUI.Guis.Prefs
5+
{
6+
[AddComponentMenu("")]
7+
public class PrefsGuiImageLabel : PrefsGuiLabel
8+
{
9+
[SerializeField]
10+
protected RawImage rawImage = null;
11+
12+
13+
public Texture SetImage(Texture texture)
14+
=> this.rawImage.texture = texture;
15+
16+
public Texture GetImage()
17+
=> this.rawImage.texture;
18+
19+
protected override void Reset()
20+
{
21+
base.Reset();
22+
this.rawImage = this.elements?.GetComponentInChildren<RawImage>();
23+
}
24+
}
25+
}

Assets/PrefsUGUI/Scripts/Guis/Prefs/PrefsGuiImageLabel.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.
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
using System;
2+
using UnityEngine;
3+
using UnityEngine.UI;
4+
5+
namespace PrefsUGUI
6+
{
7+
using Guis.Prefs;
8+
9+
[Serializable]
10+
public class PrefsImageLabel : Prefs.PrefsGuiBaseConnector<string, PrefsGuiImageLabel>
11+
{
12+
public Texture Image
13+
{
14+
get { return this.gui?.GetImage(); }
15+
set { this.gui?.SetImage(value); }
16+
}
17+
18+
19+
public PrefsImageLabel(string key, string text, GuiHierarchy hierarchy = null, string guiLabel = null)
20+
: base(key, text ?? "", hierarchy, guiLabel)
21+
{
22+
}
23+
24+
public override void Reload(bool withEvent = true)
25+
=> this.ResetDefaultValue();
26+
27+
protected override void OnCreatedGuiInternal(PrefsGuiImageLabel gui)
28+
{
29+
gui.Initialize(this.GuiLabel, this.Get());
30+
this.OnValueChanged += () => gui.SetValue(this.Get());
31+
}
32+
33+
protected override void Regist()
34+
=> this.AfterRegist();
35+
}
36+
}

Assets/PrefsUGUI/Scripts/Prefs/PrefsImageLabel.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.

0 commit comments

Comments
 (0)