net.dreditor.phraseanimations 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.
Files changed (44) hide show
  1. package/AnimData.cs +42 -0
  2. package/AnimData.cs.meta +11 -0
  3. package/DREditor.PhraseAnimations.asmdef +20 -0
  4. package/DREditor.PhraseAnimations.asmdef.meta +7 -0
  5. package/Editor/CompactPhraseTypeEditor.cs +97 -0
  6. package/Editor/CompactPhraseTypeEditor.cs.meta +11 -0
  7. package/Editor/PhraseAnimationEditor.cs +180 -0
  8. package/Editor/PhraseAnimationEditor.cs.meta +11 -0
  9. package/Editor/PhraseAnimationTypeEditor.cs +25 -0
  10. package/Editor/PhraseAnimationTypeEditor.cs.meta +11 -0
  11. package/Editor/PhraseAnimationTypeList.cs +24 -0
  12. package/Editor/PhraseAnimationTypeList.cs.meta +11 -0
  13. package/Editor/PhraseFadeTypeEditor.cs +19 -0
  14. package/Editor/PhraseFadeTypeEditor.cs.meta +11 -0
  15. package/Editor/PhraseRotationTypeEditor.cs +20 -0
  16. package/Editor/PhraseRotationTypeEditor.cs.meta +11 -0
  17. package/Editor/PhraseScaleTypeEditor.cs +20 -0
  18. package/Editor/PhraseScaleTypeEditor.cs.meta +11 -0
  19. package/Editor/PhraseTransformTypeEditor.cs +19 -0
  20. package/Editor/PhraseTransformTypeEditor.cs.meta +11 -0
  21. package/Editor/PhraseTypeEditor.cs +278 -0
  22. package/Editor/PhraseTypeEditor.cs.meta +11 -0
  23. package/Editor.meta +8 -0
  24. package/IPhraseAnimationType.cs +17 -0
  25. package/IPhraseAnimationType.cs.meta +11 -0
  26. package/PhraseAnimation.cs +74 -0
  27. package/PhraseAnimation.cs.meta +11 -0
  28. package/PhraseAnimationCompact.cs +45 -0
  29. package/PhraseAnimationCompact.cs.meta +11 -0
  30. package/PhraseAnimationHandler.cs +136 -0
  31. package/PhraseAnimationHandler.cs.meta +11 -0
  32. package/PhraseAnimationTypeBase.cs +54 -0
  33. package/PhraseAnimationTypeBase.cs.meta +11 -0
  34. package/PhraseFadeType.cs +20 -0
  35. package/PhraseFadeType.cs.meta +11 -0
  36. package/PhraseRotationType.cs +28 -0
  37. package/PhraseRotationType.cs.meta +11 -0
  38. package/PhraseScaleType.cs +26 -0
  39. package/PhraseScaleType.cs.meta +11 -0
  40. package/PhraseTransformType.cs +26 -0
  41. package/PhraseTransformType.cs.meta +11 -0
  42. package/package.json +37 -6
  43. package/package.json.meta +7 -0
  44. package/README.md +0 -3
package/AnimData.cs ADDED
@@ -0,0 +1,42 @@
1
+ //Author: Benjamin "Sweden" Jillson : Discord: sweden_gaming For Project Eden's Garden
2
+ using UnityEngine;
3
+
4
+ namespace DREditor.PhraseAnimations
5
+ {
6
+ /// <summary>
7
+ ///
8
+ /// </summary>
9
+ [System.Serializable]
10
+ public class AnimData
11
+ {
12
+ /// <summary>
13
+ ///
14
+ /// </summary>
15
+ [SerializeReference]
16
+ public IPhraseAnimationType animationType;
17
+
18
+ /// <summary>
19
+ ///
20
+ /// </summary>
21
+ public int typeIndex;
22
+
23
+
24
+ /// <summary>
25
+ ///
26
+ /// </summary>
27
+ /// <param name="animationType"></param>
28
+ public virtual void SetType(IPhraseAnimationType animationType) => this.animationType = animationType;
29
+
30
+ /// <summary>
31
+ ///
32
+ /// </summary>
33
+ /// <param name="typeIndex"></param>
34
+ public virtual void SetIndex(int typeIndex) => this.typeIndex = typeIndex;
35
+
36
+ /// <summary>
37
+ ///
38
+ /// </summary>
39
+ /// <param name="clip"></param>
40
+ public virtual void Initialize(AnimationClip clip) => animationType?.Initialize(clip);
41
+ }
42
+ }
@@ -0,0 +1,11 @@
1
+ fileFormatVersion: 2
2
+ guid: ae9893f91b0ee6541a8de288cdbb21a4
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,20 @@
1
+ {
2
+ "name": "DREditor.PhraseAnimations",
3
+ "rootNamespace": "",
4
+ "references": [
5
+ "DREditor",
6
+ "Unity.TextMeshPro",
7
+ "DREditor.Editor",
8
+ "DREditor.Minigames",
9
+ "DREditor.Minigames.Debates"
10
+ ],
11
+ "includePlatforms": [],
12
+ "excludePlatforms": [],
13
+ "allowUnsafeCode": false,
14
+ "overrideReferences": false,
15
+ "precompiledReferences": [],
16
+ "autoReferenced": true,
17
+ "defineConstraints": [],
18
+ "versionDefines": [],
19
+ "noEngineReferences": false
20
+ }
@@ -0,0 +1,7 @@
1
+ fileFormatVersion: 2
2
+ guid: e383c2b79aa802c4d8f983e9d5520a89
3
+ AssemblyDefinitionImporter:
4
+ externalObjects: {}
5
+ userData:
6
+ assetBundleName:
7
+ assetBundleVariant:
@@ -0,0 +1,97 @@
1
+ //Author: Benjamin "Sweden" Jillson : Discord: sweden_gaming For Project Eden's Garden
2
+ #if UNITY_EDITOR
3
+ using System;
4
+ using UnityEngine;
5
+
6
+ namespace DREditor.PhraseAnimations.Editor
7
+ {
8
+ /// <summary>
9
+ ///
10
+ /// </summary>
11
+ /// <typeparam name="T"></typeparam>
12
+ /// <typeparam name="T2"></typeparam>
13
+ public abstract class CompactPhraseTypeEditor<T, T2> : PhraseAnimationTypeEditor<T>
14
+ where T : PhraseAnimationCompact<T2>
15
+ where T2 : struct
16
+ {
17
+ /// <summary>
18
+ ///
19
+ /// </summary>
20
+ public abstract string TypeName { get; }
21
+
22
+ /// <summary>
23
+ ///
24
+ /// </summary>
25
+ public abstract Func<string, T2, int, int, T2> FieldFunc { get; }
26
+
27
+ protected override void DisplayType()
28
+ {
29
+ typeTarget.SetStartValue(FieldFunc($"Starting {TypeName}: ", typeTarget.startValue, 200, 6));
30
+
31
+ typeTarget.SetEndValue(FieldFunc($"Ending {TypeName}: ", typeTarget.endValue, 200, 6));
32
+ }
33
+
34
+ protected override void DisplayCurves() => PopulateCurves(DisplayCurve);
35
+
36
+ protected override void UpdateCurves() => PopulateCurves(UpdateKey);
37
+
38
+ /// <summary>
39
+ ///
40
+ /// </summary>
41
+ /// <param name="operation"></param>
42
+ protected virtual void PopulateCurves(Func<AnimationCurve, float, float, AnimationCurve> operation)
43
+ {
44
+ if (typeof(T2) == typeof(float))
45
+ typeTarget.animationCurves[0] = operation(
46
+ typeTarget.animationCurves[0],
47
+ (float)(object)typeTarget.startValue,
48
+ (float)(object)typeTarget.endValue);
49
+ else
50
+ EditVectorCurves(typeTarget.startValue, typeTarget.endValue, operation);
51
+ }
52
+
53
+ /// <summary>
54
+ ///
55
+ /// </summary>
56
+ /// <typeparam name="T3"></typeparam>
57
+ /// <param name="start"></param>
58
+ /// <param name="end"></param>
59
+ /// <param name="operation"></param>
60
+ /// <param name="offset"></param>
61
+ protected virtual void EditVectorCurves<T3>
62
+ (T3 start, T3 end, Func<AnimationCurve, float, float, AnimationCurve> operation, int offset = 0)
63
+ where T3 : struct
64
+ {
65
+ for (int i = 0; i < typeBaseTarget.CurveCount; i++)
66
+ {
67
+ int index = i + offset;
68
+
69
+ float startVal = GetVectorComponent(start, i);
70
+
71
+ float endVal = GetVectorComponent(end, i);
72
+
73
+ typeBaseTarget.animationCurves[index] = operation(typeBaseTarget.animationCurves[index], startVal, endVal);
74
+ }
75
+ }
76
+
77
+ /// <summary>
78
+ ///
79
+ /// </summary>
80
+ /// <typeparam name="T4"></typeparam>
81
+ /// <param name="vector"></param>
82
+ /// <param name="index"></param>
83
+ /// <returns></returns>
84
+ /// <exception cref="ArgumentException"></exception>
85
+ protected float GetVectorComponent<T4>(T4 vector, int index) where T4 : struct
86
+ {
87
+ return vector switch
88
+ {
89
+ Vector2 v2 => v2[index],
90
+ Vector3 v3 => v3[index],
91
+ Vector4 v4 => v4[index],
92
+ _ => throw new ArgumentException($"Unsupported vector type: {typeof(T4)}")
93
+ };
94
+ }
95
+ }
96
+ }
97
+ #endif
@@ -0,0 +1,11 @@
1
+ fileFormatVersion: 2
2
+ guid: 7421e48f9cec91d4ea40cfded3f35968
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,180 @@
1
+ //Author: Benjamin "Sweden" Jillson : Discord: sweden_gaming For Project Eden's Garden
2
+ #if UNITY_EDITOR
3
+ using DREditor.Editor.Utility;
4
+ using System;
5
+ using System.Collections.Generic;
6
+ using UnityEditor;
7
+ using UnityEngine;
8
+
9
+ namespace DREditor.PhraseAnimations.Editor
10
+ {
11
+ /// <summary>
12
+ ///
13
+ /// </summary>
14
+ [CustomClassEditor(typeof(PhraseAnimation))]
15
+ public class PhraseAnimationEditor : ClassEditorBase
16
+ {
17
+ /// <summary>
18
+ ///
19
+ /// </summary>
20
+ protected List<Type> _types;
21
+
22
+ /// <summary>
23
+ ///
24
+ /// </summary>
25
+ protected string[] choices;
26
+
27
+ /// <summary>
28
+ ///
29
+ /// </summary>
30
+ protected PhraseAnimation target;
31
+
32
+ /// <summary>
33
+ ///
34
+ /// </summary>
35
+ protected AnimData anim;
36
+
37
+ // Since this assembly is self contained, Phrase Animation Presets will come in a TBD future update.
38
+ //protected readonly PhrasePresetEditor presetEditor = new();
39
+
40
+ /// <inheritdoc/>
41
+ protected override void OnInspectorGUI()
42
+ {
43
+ target = baseTarget as PhraseAnimation;
44
+
45
+ DisplaySpawnData();
46
+
47
+ if (target.animations.Count > 0)
48
+ DisplayPhraseAnimations();
49
+
50
+ DisplayAddAnimationButton();
51
+ }
52
+
53
+ /// <summary>
54
+ ///
55
+ /// </summary>
56
+ protected virtual void DisplaySpawnData()
57
+ {
58
+ target.SetSpawnPoint(HandyFields.Vector3Field("Spawn Point: ", target.spawnPoint, 200, 7));
59
+
60
+ target.SetSpawnAngle(HandyFields.Vector4Field("Spawn Angle: ", target.spawnAngle, 200, 7));
61
+ }
62
+
63
+ /// <summary>
64
+ ///
65
+ /// </summary>
66
+ protected virtual void DisplayPhraseAnimations()
67
+ {
68
+ for (int i = 0; i < target.animations.Count; i++)
69
+ DisplayPhraseAnimation(i);
70
+ }
71
+
72
+ /// <summary>
73
+ ///
74
+ /// </summary>
75
+ /// <param name="i"></param>
76
+ protected virtual void DisplayPhraseAnimation(int i)
77
+ {
78
+ anim = target.animations[i];
79
+
80
+ // Since this assembly is self contained, Phrase Animation Presets will come in a TBD future update.
81
+ //presetEditor.EditPhrasePreset(currPhrase);
82
+
83
+ InitializeTypeList();
84
+
85
+ using (new EditorGUILayout.VerticalScope("Box"))
86
+ {
87
+ EditorGUILayout.LabelField("Animation " + (i + 1) + ": ");
88
+
89
+ DisplayPhraseAnimationType();
90
+ }
91
+ }
92
+
93
+ /// <summary>
94
+ ///
95
+ /// </summary>
96
+ protected virtual void InitializeTypeList()
97
+ {
98
+ if (_types == null || _types.Count == 0)
99
+ PhraseAnimationTypeList.UpdateTypeList(out _types, out choices);
100
+ }
101
+
102
+ /// <summary>
103
+ ///
104
+ /// </summary>
105
+ protected virtual void DisplayPhraseAnimationType()
106
+ {
107
+ DisplayPhraseAnimationTypeDropdown();
108
+
109
+ DisplayReplaceAnimationButton();
110
+
111
+ DisplayPhraseAnimationEditor();
112
+
113
+ DisplaySpawnAnimationButton();
114
+
115
+ DisplayRemoveAnimationButton();
116
+ }
117
+
118
+ /// <summary>
119
+ ///
120
+ /// </summary>
121
+ protected virtual void DisplayPhraseAnimationTypeDropdown()
122
+ {
123
+ if (anim.animationType != null &&
124
+ _types[anim.typeIndex] != anim.animationType.GetType())
125
+ anim.SetIndex(_types.IndexOf(anim.animationType.GetType()));
126
+
127
+ anim.SetIndex(EditorGUILayout.Popup(anim.typeIndex, choices));
128
+ }
129
+
130
+ /// <summary>
131
+ ///
132
+ /// </summary>
133
+ protected virtual void DisplayReplaceAnimationButton()
134
+ {
135
+ if (anim.animationType != null &&
136
+ _types[anim.typeIndex] != anim.animationType.GetType() &&
137
+ GUILayout.Button("Replace Animation"))
138
+ anim.SetType((IPhraseAnimationType)Activator.CreateInstance(_types[anim.typeIndex]));
139
+ }
140
+
141
+ /// <summary>
142
+ ///
143
+ /// </summary>
144
+ protected virtual void DisplayPhraseAnimationEditor()
145
+ {
146
+ if (anim.animationType != null)
147
+ ClassEditorFactory.DrawEditorFor(anim.animationType);
148
+ }
149
+
150
+ /// <summary>
151
+ ///
152
+ /// </summary>
153
+ protected virtual void DisplaySpawnAnimationButton()
154
+ {
155
+ if (anim.animationType == null && GUILayout.Button("Spawn Animation"))
156
+ anim.SetType((IPhraseAnimationType)Activator.CreateInstance(_types[anim.typeIndex]));
157
+ }
158
+
159
+ /// <summary>
160
+ ///
161
+ /// </summary>
162
+ protected virtual void DisplayRemoveAnimationButton()
163
+ {
164
+ if (GUILayout.Button("Remove Animation") &&
165
+ EditorUtility.DisplayDialog("Remove Animation", "Are you sure you want to Delete this Animation?",
166
+ "Yes", "No"))
167
+ target.animations.Remove(anim);
168
+ }
169
+
170
+ /// <summary>
171
+ ///
172
+ /// </summary>
173
+ protected virtual void DisplayAddAnimationButton()
174
+ {
175
+ if (GUILayout.Button("Add Animation"))
176
+ target.animations.Add(new AnimData());
177
+ }
178
+ }
179
+ }
180
+ #endif
@@ -0,0 +1,11 @@
1
+ fileFormatVersion: 2
2
+ guid: d8b7235b29ad7334f840a2aeda774c05
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,25 @@
1
+ //Author: Benjamin "Sweden" Jillson : Discord: sweden_gaming For Project Eden's Garden
2
+ #if UNITY_EDITOR
3
+ namespace DREditor.PhraseAnimations.Editor
4
+ {
5
+ /// <summary>
6
+ ///
7
+ /// </summary>
8
+ /// <typeparam name="T"></typeparam>
9
+ public abstract class PhraseAnimationTypeEditor<T> : PhraseTypeEditor where T : class
10
+ {
11
+ /// <summary>
12
+ ///
13
+ /// </summary>
14
+ protected T typeTarget;
15
+
16
+
17
+ protected override void OnInspectorGUI()
18
+ {
19
+ typeTarget = baseTarget as T;
20
+
21
+ base.OnInspectorGUI();
22
+ }
23
+ }
24
+ }
25
+ #endif
@@ -0,0 +1,11 @@
1
+ fileFormatVersion: 2
2
+ guid: a0cd9d7d83af7e244ba0cbee6651e021
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,24 @@
1
+ //Author: Benjamin "Sweden" Jillson : Discord: sweden_gaming For Project Eden's Garden
2
+ #if UNITY_EDITOR
3
+ using UnityEditor;
4
+
5
+ namespace DREditor.PhraseAnimations.Editor
6
+ {
7
+ /// <summary>
8
+ ///
9
+ /// </summary>
10
+ [InitializeOnLoad]
11
+ public class PhraseAnimationTypeList : TypeListBase<IPhraseAnimationType>
12
+ {
13
+ static PhraseAnimationTypeList()
14
+ {
15
+ if (!SessionState.GetBool("PhraseAnimationTypeInitDone", false))
16
+ {
17
+ UpdateList();
18
+
19
+ SessionState.SetBool("PhraseAnimationTypeInitDone", true);
20
+ }
21
+ }
22
+ }
23
+ }
24
+ #endif
@@ -0,0 +1,11 @@
1
+ fileFormatVersion: 2
2
+ guid: e35746afdc91169478b58d7f23eeb98f
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
+ //Author: Benjamin "Sweden" Jillson : Discord: sweden_gaming For Project Eden's Garden
2
+ #if UNITY_EDITOR
3
+ using DREditor.Editor.Utility;
4
+ using System;
5
+
6
+ namespace DREditor.PhraseAnimations.Editor
7
+ {
8
+ /// <summary>
9
+ ///
10
+ /// </summary>
11
+ [CustomClassEditor(typeof(PhraseFadeType))]
12
+ public class PhraseFadeTypeEditor : CompactPhraseTypeEditor<PhraseFadeType, float>
13
+ {
14
+ public override string TypeName => "Fade";
15
+
16
+ public override Func<string, float, int, int, float> FieldFunc => HandyFields.FloatField;
17
+ }
18
+ }
19
+ #endif
@@ -0,0 +1,11 @@
1
+ fileFormatVersion: 2
2
+ guid: 31b47eee6b502fc4aa5a70ba64060fa8
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,20 @@
1
+ //Author: Benjamin "Sweden" Jillson : Discord: sweden_gaming For Project Eden's Garden
2
+ #if UNITY_EDITOR
3
+ using DREditor.Editor.Utility;
4
+ using System;
5
+ using UnityEngine;
6
+
7
+ namespace DREditor.PhraseAnimations.Editor
8
+ {
9
+ /// <summary>
10
+ ///
11
+ /// </summary>
12
+ [CustomClassEditor(typeof(PhraseRotationType))]
13
+ public class PhraseRotationTypeEditor : CompactPhraseTypeEditor<PhraseRotationType, Vector4>
14
+ {
15
+ public override string TypeName => "Rotation";
16
+
17
+ public override Func<string, Vector4, int, int, Vector4> FieldFunc => HandyFields.Vector4Field;
18
+ }
19
+ }
20
+ #endif
@@ -0,0 +1,11 @@
1
+ fileFormatVersion: 2
2
+ guid: ab789603dfdc5604e9078144a90d2a8e
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,20 @@
1
+ //Author: Benjamin "Sweden" Jillson : Discord: sweden_gaming For Project Eden's Garden
2
+ #if UNITY_EDITOR
3
+ using DREditor.Editor.Utility;
4
+ using System;
5
+ using UnityEngine;
6
+
7
+ namespace DREditor.PhraseAnimations.Editor
8
+ {
9
+ /// <summary>
10
+ ///
11
+ /// </summary>
12
+ [CustomClassEditor(typeof(PhraseScaleType))]
13
+ public class PhraseScaleTypeEditor : CompactPhraseTypeEditor<PhraseScaleType, Vector3>
14
+ {
15
+ public override string TypeName => "Scale";
16
+
17
+ public override Func<string, Vector3, int, int, Vector3> FieldFunc => HandyFields.Vector3Field;
18
+ }
19
+ }
20
+ #endif
@@ -0,0 +1,11 @@
1
+ fileFormatVersion: 2
2
+ guid: f03c0af6c8122db409c6064df090b0df
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
+ //Author: Benjamin "Sweden" Jillson : Discord: sweden_gaming For Project Eden's Garden
2
+ #if UNITY_EDITOR
3
+ using DREditor.Editor.Utility;
4
+ using System;
5
+ using UnityEngine;
6
+
7
+ namespace DREditor.PhraseAnimations.Editor
8
+ {
9
+ /// <summary>
10
+ ///
11
+ /// </summary>
12
+ [CustomClassEditor(typeof(PhraseTransformType))]
13
+ public class PhraseTransformTypeEditor : CompactPhraseTypeEditor<PhraseTransformType, Vector3>
14
+ {
15
+ public override string TypeName => "Position";
16
+ public override Func<string, Vector3, int, int, Vector3> FieldFunc => HandyFields.Vector3Field;
17
+ }
18
+ }
19
+ #endif
@@ -0,0 +1,11 @@
1
+ fileFormatVersion: 2
2
+ guid: a0355badcfd40b04fb737282046d37ed
3
+ MonoImporter:
4
+ externalObjects: {}
5
+ serializedVersion: 2
6
+ defaultReferences: []
7
+ executionOrder: 0
8
+ icon: {instanceID: 0}
9
+ userData:
10
+ assetBundleName:
11
+ assetBundleVariant: