net.dreditor.uispritehandling 0.0.0-stage → 0.1.6

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,42 @@
1
+ //Author: Benjamin "Sweden" Jillson : Discord: sweden_gaming For Project Eden's Garden
2
+ using DREditor.Dialogues.Events;
3
+ using System;
4
+ using UnityEngine;
5
+
6
+
7
+ #if UNITY_EDITOR
8
+ using DREditor.Editor.Utility;
9
+ #endif
10
+
11
+ namespace DREditor.UISpriteHandling
12
+ {
13
+ /// <summary>
14
+ ///
15
+ /// </summary>
16
+ [Serializable]
17
+ public class ChangeUISpriteEventData : IDataCapsulate
18
+ {
19
+ /// <summary>
20
+ ///
21
+ /// </summary>
22
+ public CharacterUISpriteData characterUIData = null;
23
+
24
+
25
+ #if UNITY_EDITOR
26
+ /// <inheritdoc/>
27
+ public void Display(object o)
28
+ {
29
+ HandyFields.Label("The data for telling the protag manager how to swap the protag.");
30
+
31
+ characterUIData = HandyFields.UnityField(new GUIContent("CharacterUIData:",
32
+ "Asset containing info related to how a character sprite is displayed to the UI."),
33
+ characterUIData);
34
+ }
35
+ #else
36
+ public void Display(object o = null)
37
+ {
38
+
39
+ }
40
+ #endif
41
+ }
42
+ }
@@ -0,0 +1,11 @@
1
+ fileFormatVersion: 2
2
+ guid: 0f0f9f49d8e489544880d9dc460f6671
3
+ MonoImporter:
4
+ externalObjects: {}
5
+ serializedVersion: 2
6
+ defaultReferences: []
7
+ executionOrder: 0
8
+ icon: {instanceID: 0}
9
+ userData:
10
+ assetBundleName:
11
+ assetBundleVariant:
@@ -0,0 +1,48 @@
1
+ //Author: Benjamin "Sweden" Jillson : Discord: sweden_gaming For Project Eden's Garden
2
+ using UnityEngine;
3
+
4
+ namespace DREditor.UISpriteHandling
5
+ {
6
+ /// <summary>
7
+ ///
8
+ /// </summary>
9
+ [System.Serializable]
10
+ [CreateAssetMenu(menuName = "DREditor/Characters/Protag UI Sprite Data", fileName = "UI Sprite Data")]
11
+ public class CharacterUISpriteData : ScriptableObject
12
+ {
13
+ /// <summary>
14
+ ///
15
+ /// </summary>
16
+ [Header("")]
17
+ public string charName = string.Empty;
18
+
19
+ /// <summary>
20
+ ///
21
+ /// </summary>
22
+ public float x = 0;
23
+
24
+ /// <summary>
25
+ ///
26
+ /// </summary>
27
+ public float y = 0;
28
+
29
+
30
+ /// <summary>
31
+ ///
32
+ /// </summary>
33
+ /// <param name="charName"></param>
34
+ public virtual void SetCharacterName(string charName) => this.charName = charName;
35
+
36
+ /// <summary>
37
+ ///
38
+ /// </summary>
39
+ /// <param name="x"></param>
40
+ /// <param name="y"></param>
41
+ public virtual void SetSpritePosition(float x, float y)
42
+ {
43
+ this.x = x;
44
+
45
+ this.y = y;
46
+ }
47
+ }
48
+ }
@@ -0,0 +1,11 @@
1
+ fileFormatVersion: 2
2
+ guid: 8c56e321ab86add4e8d80d20b6453c54
3
+ MonoImporter:
4
+ externalObjects: {}
5
+ serializedVersion: 2
6
+ defaultReferences: []
7
+ executionOrder: 0
8
+ icon: {instanceID: 0}
9
+ userData:
10
+ assetBundleName:
11
+ assetBundleVariant:
@@ -0,0 +1,19 @@
1
+ {
2
+ "name": "DREditor.UISpriteHandling",
3
+ "rootNamespace": "",
4
+ "references": [
5
+ "DREditor",
6
+ "DREditor.DialogueEventHandling",
7
+ "DREditor.Editor",
8
+ "DG.Tweening"
9
+ ],
10
+ "includePlatforms": [],
11
+ "excludePlatforms": [],
12
+ "allowUnsafeCode": false,
13
+ "overrideReferences": false,
14
+ "precompiledReferences": [],
15
+ "autoReferenced": true,
16
+ "defineConstraints": [],
17
+ "versionDefines": [],
18
+ "noEngineReferences": false
19
+ }
@@ -0,0 +1,7 @@
1
+ fileFormatVersion: 2
2
+ guid: de30b9bb7d7287342a302106da214372
3
+ AssemblyDefinitionImporter:
4
+ externalObjects: {}
5
+ userData:
6
+ assetBundleName:
7
+ assetBundleVariant:
@@ -0,0 +1,55 @@
1
+ //Author: Benjamin "Sweden" Jillson : Discord: sweden_gaming For Project Eden's Garden
2
+ using DREditor.Dialogues;
3
+ using DREditor.Dialogues.Events;
4
+ using DREditor.Dialogues.LineReading;
5
+ using DREditor.Dialogues.Loading;
6
+ using DREditor.EventObjects;
7
+ using UnityEngine;
8
+
9
+ namespace DREditor.UISpriteHandling
10
+ {
11
+ /// <summary>
12
+ ///
13
+ /// </summary>
14
+ [ClassHeader(nameof(DialogueComponent) + ", " + nameof(ILineProcessor) + ", " + nameof(ILoadToLineEnd) +
15
+ "\n\n")]
16
+ public class ProtagUISpriteHandler : DialogueComponent, ILineProcessor, ILoadToLineEnd
17
+ {
18
+ /// <summary>
19
+ ///
20
+ /// </summary>
21
+ [Header("")]
22
+ [Divider]
23
+ [Tooltip("")]
24
+ [SerializeField] protected BoolWithEvent isProtagSpeaking = null;
25
+
26
+ /// <summary>
27
+ ///
28
+ /// </summary>
29
+ [Tooltip("")]
30
+ [SerializeField] protected string spriteLineEvent = "ProtagSpriteLineEvent";
31
+
32
+ /// <summary>
33
+ ///
34
+ /// </summary>
35
+ [Tooltip("")]
36
+ [SerializeField] protected string loadToLineEndEvent = "ProtagLoadToLineEndSpriteEvent";
37
+
38
+
39
+ /// <inheritdoc/>
40
+ public virtual void LineProcess(Line currentLine)
41
+ {
42
+ bool expressionIsValid = currentLine.Expression != null && currentLine.Expression.Sprite != null;
43
+
44
+ if (isProtagSpeaking.Value && expressionIsValid)
45
+ DialogueEventSystem.TriggerEvent(spriteLineEvent, currentLine);
46
+ }
47
+
48
+ /// <inheritdoc/>
49
+ public virtual void OnLoadToLineEnd(Line currentLine)
50
+ {
51
+ if (isProtagSpeaking.Value)
52
+ DialogueEventSystem.TriggerEvent(loadToLineEndEvent, currentLine);
53
+ }
54
+ }
55
+ }
@@ -0,0 +1,11 @@
1
+ fileFormatVersion: 2
2
+ guid: 3895a6a72fb86284d852a2df73b93422
3
+ MonoImporter:
4
+ externalObjects: {}
5
+ serializedVersion: 2
6
+ defaultReferences: []
7
+ executionOrder: 0
8
+ icon: {instanceID: 0}
9
+ userData:
10
+ assetBundleName:
11
+ assetBundleVariant:
@@ -0,0 +1,17 @@
1
+ %YAML 1.1
2
+ %TAG !u! tag:unity3d.com,2011:
3
+ --- !u!114 &11400000
4
+ MonoBehaviour:
5
+ m_ObjectHideFlags: 0
6
+ m_CorrespondingSourceObject: {fileID: 0}
7
+ m_PrefabInstance: {fileID: 0}
8
+ m_PrefabAsset: {fileID: 0}
9
+ m_GameObject: {fileID: 0}
10
+ m_Enabled: 1
11
+ m_EditorHideFlags: 0
12
+ m_Script: {fileID: 11500000, guid: 8c56e321ab86add4e8d80d20b6453c54, type: 3}
13
+ m_Name: Default_Protag_Data
14
+ m_EditorClassIdentifier:
15
+ charName:
16
+ x: -72
17
+ y: -298
@@ -0,0 +1,8 @@
1
+ fileFormatVersion: 2
2
+ guid: 50adb13503517454cb5903edc77b6ae8
3
+ NativeFormatImporter:
4
+ externalObjects: {}
5
+ mainObjectFileID: 11400000
6
+ userData:
7
+ assetBundleName:
8
+ assetBundleVariant:
@@ -0,0 +1,17 @@
1
+ %YAML 1.1
2
+ %TAG !u! tag:unity3d.com,2011:
3
+ --- !u!114 &11400000
4
+ MonoBehaviour:
5
+ m_ObjectHideFlags: 0
6
+ m_CorrespondingSourceObject: {fileID: 0}
7
+ m_PrefabInstance: {fileID: 0}
8
+ m_PrefabAsset: {fileID: 0}
9
+ m_GameObject: {fileID: 0}
10
+ m_Enabled: 1
11
+ m_EditorHideFlags: 0
12
+ m_Script: {fileID: 11500000, guid: 8c56e321ab86add4e8d80d20b6453c54, type: 3}
13
+ m_Name: Load_Protag_Data
14
+ m_EditorClassIdentifier:
15
+ charName:
16
+ x: -72
17
+ y: -298
@@ -0,0 +1,8 @@
1
+ fileFormatVersion: 2
2
+ guid: bb9d6894c211f3f46883777595ba789e
3
+ NativeFormatImporter:
4
+ externalObjects: {}
5
+ mainObjectFileID: 11400000
6
+ userData:
7
+ assetBundleName:
8
+ assetBundleVariant:
@@ -0,0 +1,49 @@
1
+ %YAML 1.1
2
+ %TAG !u! tag:unity3d.com,2011:
3
+ --- !u!1 &6081190874047259582
4
+ GameObject:
5
+ m_ObjectHideFlags: 0
6
+ m_CorrespondingSourceObject: {fileID: 0}
7
+ m_PrefabInstance: {fileID: 0}
8
+ m_PrefabAsset: {fileID: 0}
9
+ serializedVersion: 6
10
+ m_Component:
11
+ - component: {fileID: 6081190874047259577}
12
+ - component: {fileID: 6081190874047259576}
13
+ m_Layer: 0
14
+ m_Name: Protag_UI_Sprite_Handler
15
+ m_TagString: Untagged
16
+ m_Icon: {fileID: 0}
17
+ m_NavMeshLayer: 0
18
+ m_StaticEditorFlags: 0
19
+ m_IsActive: 1
20
+ --- !u!4 &6081190874047259577
21
+ Transform:
22
+ m_ObjectHideFlags: 0
23
+ m_CorrespondingSourceObject: {fileID: 0}
24
+ m_PrefabInstance: {fileID: 0}
25
+ m_PrefabAsset: {fileID: 0}
26
+ m_GameObject: {fileID: 6081190874047259582}
27
+ m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
28
+ m_LocalPosition: {x: 0, y: 0, z: 0}
29
+ m_LocalScale: {x: 1, y: 1, z: 1}
30
+ m_ConstrainProportionsScale: 0
31
+ m_Children: []
32
+ m_Father: {fileID: 0}
33
+ m_RootOrder: 0
34
+ m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
35
+ --- !u!114 &6081190874047259576
36
+ MonoBehaviour:
37
+ m_ObjectHideFlags: 0
38
+ m_CorrespondingSourceObject: {fileID: 0}
39
+ m_PrefabInstance: {fileID: 0}
40
+ m_PrefabAsset: {fileID: 0}
41
+ m_GameObject: {fileID: 6081190874047259582}
42
+ m_Enabled: 1
43
+ m_EditorHideFlags: 0
44
+ m_Script: {fileID: 11500000, guid: 3895a6a72fb86284d852a2df73b93422, type: 3}
45
+ m_Name:
46
+ m_EditorClassIdentifier:
47
+ isProtagSpeaking: {fileID: 11400000, guid: 7f279787522335d4c84256f3890a6ced, type: 2}
48
+ spriteLineEvent: ProtagSpriteLineEvent
49
+ loadToLineEndEvent: ProtagLoadToLineEndSpriteEvent
@@ -0,0 +1,7 @@
1
+ fileFormatVersion: 2
2
+ guid: 7e9b798db7a7c434faf97bdd830a9662
3
+ PrefabImporter:
4
+ externalObjects: {}
5
+ userData:
6
+ assetBundleName:
7
+ assetBundleVariant:
package/Samples.meta ADDED
@@ -0,0 +1,8 @@
1
+ fileFormatVersion: 2
2
+ guid: 9c18564bc743dd142aba90f95b8d53de
3
+ folderAsset: yes
4
+ DefaultImporter:
5
+ externalObjects: {}
6
+ userData:
7
+ assetBundleName:
8
+ assetBundleVariant:
@@ -0,0 +1,19 @@
1
+ //Author: Benjamin "Sweden" Jillson : Discord: sweden_gaming For Project Eden's Garden
2
+ using UnityEngine;
3
+
4
+ namespace DREditor.UISpriteHandling
5
+ {
6
+ /// <summary>
7
+ ///
8
+ /// </summary>
9
+ public static class SpriteChangeUtility
10
+ {
11
+ /// <summary>
12
+ ///
13
+ /// </summary>
14
+ /// <param name="rectTransform"></param>
15
+ /// <param name="texture"></param>
16
+ public static void SizeDeltaToTextureSize(this RectTransform rectTransform, Texture texture)
17
+ => rectTransform.sizeDelta = new Vector2(texture.width, texture.height);
18
+ }
19
+ }
@@ -0,0 +1,11 @@
1
+ fileFormatVersion: 2
2
+ guid: bbe48a4f1ab765d42bf8ddbb1c021727
3
+ MonoImporter:
4
+ externalObjects: {}
5
+ serializedVersion: 2
6
+ defaultReferences: []
7
+ executionOrder: 0
8
+ icon: {instanceID: 0}
9
+ userData:
10
+ assetBundleName:
11
+ assetBundleVariant:
@@ -0,0 +1,251 @@
1
+ //Author: Benjamin "Sweden" Jillson : Discord: sweden_gaming For Project Eden's Garden
2
+ #if DOTWEEN
3
+ using DG.Tweening;
4
+ #endif
5
+ using DREditor.DialogueEventHandling;
6
+ using DREditor.Dialogues;
7
+ using DREditor.Dialogues.Events;
8
+ using DREditor.EventObjects;
9
+ using System.Collections;
10
+ using UnityEngine;
11
+ using UnityEngine.UI;
12
+
13
+ namespace DREditor.UISpriteHandling
14
+ {
15
+ /// <summary>
16
+ ///
17
+ /// </summary>
18
+ [ClassHeader(nameof(DialogueEventHandler) +
19
+ "\n\n")]
20
+ public class UISpriteChanger : DialogueEventHandler
21
+ {
22
+ /// <summary>
23
+ ///
24
+ /// </summary>
25
+ [Tooltip("")]
26
+ [SerializeField] protected string loadToLineEndEvent = "ProtagLoadToLineEndSpriteEvent";
27
+
28
+
29
+ /// <summary>
30
+ ///
31
+ /// </summary>
32
+ [Header("")]
33
+ [Divider]
34
+ [Tooltip("")]
35
+ [SerializeField] protected RawImage charSpriteOne = null;
36
+
37
+ /// <summary>
38
+ ///
39
+ /// </summary>
40
+ [Tooltip("")]
41
+ [SerializeField] protected RawImage charSpriteTwo = null;
42
+
43
+
44
+ /// <summary>
45
+ ///
46
+ /// </summary>
47
+ [Header("")]
48
+ [Divider]
49
+ [Tooltip("")]
50
+ [SerializeField] protected BoolWithEvent inFastForwardMode = null;
51
+
52
+
53
+ /// <summary>
54
+ ///
55
+ /// </summary>
56
+ [Header("")]
57
+ [Divider]
58
+ [Tooltip("")]
59
+ [SerializeField] protected float uISpriteChangeTime = 0.185f;
60
+
61
+ /// <summary>
62
+ ///
63
+ /// </summary>
64
+ [Tooltip("")]
65
+ [SerializeField] protected float changeSpriteBufferTime = 0;
66
+
67
+ /// <summary>
68
+ ///
69
+ /// </summary>
70
+ [Tooltip("")]
71
+ [SerializeField] protected float resetSpriteBufferTime = 0;
72
+
73
+ /// <summary>
74
+ ///
75
+ /// </summary>
76
+ [Tooltip("")]
77
+ [SerializeField] protected Vector3 uiSpritePosition = new(-72, -298, 0); // for center panel, y = -513
78
+ #if DOTWEEN
79
+ /// <summary>
80
+ ///
81
+ /// </summary>
82
+ [Tooltip("")]
83
+ [SerializeField] protected Ease topSpriteFadeOutCurve = Ease.Linear;
84
+
85
+ /// <summary>
86
+ ///
87
+ /// </summary>
88
+ [Tooltip("")]
89
+ [SerializeField] protected Ease bottomSpriteFadeInCurve = Ease.Linear;
90
+ #endif
91
+
92
+ /// <summary>
93
+ ///
94
+ /// </summary>
95
+ protected Material currentExpression = null;
96
+
97
+
98
+ /// <inheritdoc/>
99
+ protected override void OnEnable()
100
+ {
101
+ base.OnEnable();
102
+
103
+ DialogueEventSystem.StartListening(loadToLineEndEvent, OnLoadToLineEndEventTriggered);
104
+ }
105
+
106
+ /// <inheritdoc/>
107
+ protected override void OnDisable()
108
+ {
109
+ base.OnDisable();
110
+
111
+ DialogueEventSystem.StopListening(loadToLineEndEvent, OnLoadToLineEndEventTriggered);
112
+ }
113
+
114
+ /// <summary>
115
+ ///
116
+ /// </summary>
117
+ /// <param name="o"></param>
118
+ protected override void OnDialogueEventTriggered(object o = null) => EvaluateSpriteChange((Line)o);
119
+
120
+ /// <summary>
121
+ ///
122
+ /// </summary>
123
+ /// <param name="o"></param>
124
+ protected virtual void OnLoadToLineEndEventTriggered(object o = null) => EvaluateSpriteChange((Line)o);
125
+
126
+
127
+ /// <summary>
128
+ ///
129
+ /// </summary>
130
+ /// <param name="currentLine"></param>
131
+ protected virtual void EvaluateSpriteChange(Line currentLine)
132
+ {
133
+ bool expressionIsValid = currentLine.Expression != null && currentLine.Expression.Sprite != null;
134
+
135
+ if (expressionIsValid)
136
+ EvaluateSpriteChangeProcess(currentLine);
137
+ }
138
+
139
+ /// <summary>
140
+ ///
141
+ /// </summary>
142
+ /// <param name="currentLine"></param>
143
+ protected virtual void EvaluateSpriteChangeProcess(Line currentLine)
144
+ {
145
+ currentExpression = currentLine.Expression.Sprite;
146
+
147
+ if (inFastForwardMode.Value)
148
+ FastForwardChangeUISpriteProcess();
149
+ else if (charSpriteOne != null)
150
+ StartCoroutine(ChangeUISpriteProcess());
151
+ }
152
+
153
+ /// <summary>
154
+ ///
155
+ /// </summary>
156
+ protected virtual void FastForwardChangeUISpriteProcess()
157
+ {
158
+ SetImagePositionInUI(charSpriteOne);
159
+
160
+ ApplyTextureAndSizeToRawImage(charSpriteTwo, currentExpression.mainTexture);
161
+
162
+ ApplyTextureAndSizeToRawImage(charSpriteOne, currentExpression.mainTexture);
163
+ }
164
+
165
+ /// <summary>
166
+ ///
167
+ /// </summary>
168
+ /// <returns></returns>
169
+ protected virtual IEnumerator ChangeUISpriteProcess()
170
+ {
171
+ yield return new WaitForSeconds(changeSpriteBufferTime);
172
+
173
+ SetImagePositionInUI(charSpriteOne);
174
+
175
+ ApplyTextureAndSizeToRawImage(charSpriteTwo, currentExpression.mainTexture);
176
+
177
+ AnimateSpriteChange(currentExpression.mainTexture);
178
+
179
+ yield return new WaitForSeconds(uISpriteChangeTime + resetSpriteBufferTime);
180
+
181
+ ResetImageTextures();
182
+ }
183
+
184
+ /// <summary>
185
+ ///
186
+ /// </summary>
187
+ /// <param name="rawImage"></param>
188
+ /// <param name="texture"></param>
189
+ protected virtual void ApplyTextureAndSizeToRawImage(RawImage rawImage, Texture texture)
190
+ {
191
+ rawImage.texture = texture;
192
+
193
+ rawImage.rectTransform.SizeDeltaToTextureSize(texture);
194
+ }
195
+
196
+ /// <summary>
197
+ ///
198
+ /// </summary>
199
+ /// <param name="rawImage"></param>
200
+ protected virtual void SetImagePositionInUI(RawImage rawImage)
201
+ => rawImage.rectTransform.localPosition = GetUISpritePosition();
202
+
203
+ /// <summary>
204
+ ///
205
+ /// </summary>
206
+ /// <param name="texture"></param>
207
+ protected virtual void AnimateSpriteChange(Texture texture)
208
+ {
209
+ #if DOTWEEN
210
+ charSpriteTwo.DOFade(1, uISpriteChangeTime)
211
+ .SetEase(bottomSpriteFadeInCurve);
212
+
213
+ charSpriteOne.DOFade(0, uISpriteChangeTime)
214
+ .SetEase(topSpriteFadeOutCurve);
215
+ #endif
216
+ charSpriteOne.rectTransform.SizeDeltaToTextureSize(texture);
217
+ }
218
+
219
+ /// <summary>
220
+ ///
221
+ /// </summary>
222
+ protected virtual void ResetImageTextures()
223
+ {
224
+ charSpriteOne.texture = currentExpression.mainTexture;
225
+ #if DOTWEEN
226
+ charSpriteOne.DOFade(1, 0);
227
+
228
+ charSpriteTwo.DOFade(0, 0);
229
+ #endif
230
+ }
231
+
232
+ /// <summary>
233
+ ///
234
+ /// </summary>
235
+ /// <returns></returns>
236
+ public virtual Vector3 GetUISpritePosition() => uiSpritePosition;
237
+
238
+ /// <summary>
239
+ ///
240
+ /// </summary>
241
+ /// <param name="pos"></param>
242
+ public virtual void SetUISpritePosition(Vector2 pos) => uiSpritePosition = pos;
243
+
244
+
245
+ /// <summary>
246
+ ///
247
+ /// </summary>
248
+ [ContextMenu("Set Default Event")]
249
+ public void SetDefaultEvent() => SetDefaultEventString("ProtagSpriteLineEvent");
250
+ }
251
+ }
@@ -0,0 +1,11 @@
1
+ fileFormatVersion: 2
2
+ guid: 508a0ed9ffb602a46a31193960081ca2
3
+ MonoImporter:
4
+ externalObjects: {}
5
+ serializedVersion: 2
6
+ defaultReferences: []
7
+ executionOrder: 0
8
+ icon: {instanceID: 0}
9
+ userData:
10
+ assetBundleName:
11
+ assetBundleVariant:
@@ -0,0 +1,131 @@
1
+ //Author: Benjamin "Sweden" Jillson : Discord: sweden_gaming For Project Eden's Garden
2
+ using DREditor.DialogueEventHandling;
3
+ using DREditor.EventObjects;
4
+ using DREditor.Saving;
5
+ using System.Collections.Generic;
6
+ using UnityEngine;
7
+
8
+ namespace DREditor.UISpriteHandling
9
+ {
10
+ /// <summary>
11
+ ///
12
+ /// </summary>
13
+ /// <remarks></remarks>
14
+ [CustomDialogueEvent("")]
15
+ [ClassHeader(nameof(DialogueEventHandler) + ", " + nameof(IDRESaveable) + ", " + nameof(IDRELoadable) +
16
+ "\n\n")]
17
+ public class UISpriteCharacterSwapper : DialogueEventHandler, IDRESaveable, IDRELoadable
18
+ {
19
+ /// <summary>
20
+ ///
21
+ /// </summary>
22
+ [Tooltip("")]
23
+ [SerializeField] protected CharacterUISpriteData defaultWindowCharacterData;
24
+
25
+ /// <summary>
26
+ ///
27
+ /// </summary>
28
+ [Tooltip("")]
29
+ [SerializeField] protected CharacterUISpriteData loadWindowCharacterData;
30
+
31
+ /// <summary>
32
+ ///
33
+ /// </summary>
34
+ [Tooltip("")]
35
+ [SerializeField] protected StringWithEvent windowCharacterFirstName = null;
36
+
37
+ /// <summary>
38
+ ///
39
+ /// </summary>
40
+ [Tooltip("")]
41
+ [SerializeField] protected UISpriteChanger uiSpriteChanger = null;
42
+
43
+ /// <summary>
44
+ ///
45
+ /// </summary>
46
+ [Tooltip("")]
47
+ [SerializeField] protected string uiWindowSaveKey = "ProtagUISprite";
48
+
49
+
50
+ /// <summary>
51
+ ///
52
+ /// </summary>
53
+ [Header("")]
54
+ [Divider]
55
+ [Tooltip("")]
56
+ [SerializeField] protected CharacterUISpriteData activeWindowCharacterData;
57
+
58
+
59
+ /// <summary>
60
+ ///
61
+ /// </summary>
62
+ protected virtual void Start()
63
+ {
64
+ if (uiSpriteChanger == null)
65
+ uiSpriteChanger = FindAnyObjectByType<UISpriteChanger>();
66
+
67
+ if (defaultWindowCharacterData != null)
68
+ UpdateWindowCharacter(defaultWindowCharacterData);
69
+ else
70
+ UpdateWindowCharacter(loadWindowCharacterData);
71
+ }
72
+
73
+
74
+ /// <summary>
75
+ ///
76
+ /// </summary>
77
+ /// <param name="o"></param>
78
+ protected override void OnDialogueEventTriggered(object o = null)
79
+ {
80
+ if (o == null)
81
+ UnityEngine.Debug.Log($"REPORT: {nameof(UISpriteCharacterSwapper)}: Event data was null, event will not invoke.");
82
+
83
+ if (o is ChangeUISpriteEventData data && data != null)
84
+ UpdateWindowCharacter(data.characterUIData);
85
+ }
86
+
87
+ /// <summary>
88
+ ///
89
+ /// </summary>
90
+ /// <param name="spriteDataAsset"></param>
91
+ protected virtual void UpdateWindowCharacter(ScriptableObject spriteDataAsset)
92
+ {
93
+ CharacterUISpriteData data = (CharacterUISpriteData)spriteDataAsset;
94
+
95
+ activeWindowCharacterData = data;
96
+
97
+ if (data == null)
98
+ {
99
+ UnityEngine.Debug.LogWarning("ALERT: The sent/current UISprite Data was null, the UI window sprite positions " +
100
+ "will not change.");
101
+
102
+ return;
103
+ }
104
+
105
+ windowCharacterFirstName.SetValue(data.charName);
106
+
107
+ uiSpriteChanger.SetUISpritePosition(new Vector2(data.x, data.y));
108
+ }
109
+
110
+
111
+ /// <inheritdoc/>
112
+ public virtual void Save(Dictionary<string, object> saveDatas)
113
+ => saveDatas.Set(uiWindowSaveKey, JsonUtility.ToJson(activeWindowCharacterData, true));
114
+
115
+ /// <inheritdoc/>
116
+ public virtual void Load(Dictionary<string, object> saveDatas)
117
+ {
118
+ JsonUtility.FromJsonOverwrite(saveDatas.Get<string>(uiWindowSaveKey), loadWindowCharacterData);
119
+
120
+ if (!string.IsNullOrEmpty(loadWindowCharacterData.charName))
121
+ UpdateWindowCharacter(loadWindowCharacterData);
122
+ }
123
+
124
+
125
+ /// <summary>
126
+ ///
127
+ /// </summary>
128
+ [ContextMenu("Set Default Event")]
129
+ public void SetDefaultEvent() => SetDefaultEventString("SwapProtagWindowUISprite");
130
+ }
131
+ }
@@ -0,0 +1,11 @@
1
+ fileFormatVersion: 2
2
+ guid: 4e65af74c5a98af41a8d3af4045d6035
3
+ MonoImporter:
4
+ externalObjects: {}
5
+ serializedVersion: 2
6
+ defaultReferences: []
7
+ executionOrder: 0
8
+ icon: {instanceID: 0}
9
+ userData:
10
+ assetBundleName:
11
+ assetBundleVariant:
package/package.json CHANGED
@@ -1,6 +1,35 @@
1
- {
2
- "name": "net.dreditor.uispritehandling",
3
- "version": "0.0.0-stage",
4
- "stub": true,
5
- "description": "Temporary package placeholder for staged publishing"
6
- }
1
+ {
2
+ "name": "net.dreditor.uispritehandling",
3
+ "version": "0.1.6",
4
+ "displayName": "DREditor UI Sprite Handling",
5
+ "description": "The beta for DREditor. A tool to create death game style projects without having to code.",
6
+ "unity": "6000.4",
7
+ "dependencies": {
8
+ "net.dreditor.core": "0.1.6",
9
+ "net.dreditor.dialogueeventhandling": "0.1.6"
10
+ },
11
+ "publishConfig": {
12
+ "access": "public"
13
+ },
14
+ "author": {
15
+ "name": "Benjamin \"Sweden\" Jillson",
16
+ "email": "dreditortool@gmail.com",
17
+ "url": "https://dreditor.net"
18
+ },
19
+ "keywords": [
20
+ "editor",
21
+ "tool",
22
+ "dreditor"
23
+ ],
24
+ "samples": [
25
+ {
26
+ "displayName": "Samples",
27
+ "description": "",
28
+ "path": "Samples~"
29
+ }
30
+ ],
31
+ "documentationUrl": "https://dreditor.net",
32
+ "license": "Apache-2.0",
33
+ "licensesUrl": "https://dreditor.net/docs/LICENSE.html",
34
+ "changelogUrl": "https://dreditor.net/docs/CHANGELOG.html"
35
+ }
@@ -0,0 +1,7 @@
1
+ fileFormatVersion: 2
2
+ guid: 8508e8be738cbbf46ba2d392d5731414
3
+ TextScriptImporter:
4
+ externalObjects: {}
5
+ userData:
6
+ assetBundleName:
7
+ assetBundleVariant:
package/README.md DELETED
@@ -1,3 +0,0 @@
1
- # Temporary Holding Version
2
-
3
- This version is a temporary placeholder for this package. An operational version to replace this has been submitted for review and is awaiting a staged release.