net.dreditor.chartweener 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,447 @@
1
+ //Author: Copyright (c) 2021 Matthew Dechatech under MIT License
2
+ #if DOTWEEN
3
+ using TMPro;
4
+ using UnityEngine;
5
+
6
+ namespace CharTween
7
+ {
8
+ // Contains getters and setters for character properties. Characters can be modified using the same methods as are in
9
+ // Unity's Transform.
10
+ public partial class CharTweener : MonoBehaviour
11
+ {
12
+ public float GetAlpha(int charIndex)
13
+ {
14
+ ProxyColor proxyColor = TryGetProxyColor(charIndex);
15
+ return proxyColor != null ? proxyColor.Alpha : Text.alpha;
16
+ }
17
+
18
+ public void SetAlpha(int charIndex, float value)
19
+ {
20
+ GetProxyColor(charIndex).SetAlpha(value);
21
+ colorsChangedByProperties = true;
22
+ }
23
+
24
+ public Color GetColor(int charIndex)
25
+ {
26
+ ProxyColor proxyColor = TryGetProxyColor(charIndex);
27
+ return proxyColor != null ? proxyColor.Color : Text.color;
28
+ }
29
+
30
+ public void SetColor(int charIndex, Color value)
31
+ {
32
+ GetProxyColor(charIndex).SetColor(value);
33
+ colorsChangedByProperties = true;
34
+ }
35
+
36
+ public VertexGradient GetColorGradient(int charIndex)
37
+ {
38
+ ProxyColor proxyColor = TryGetProxyColor(charIndex);
39
+ return proxyColor != null ? proxyColor.ColorGradient : Text.colorGradient;
40
+ }
41
+
42
+ public void SetColorGradient(int charIndex, VertexGradient value)
43
+ {
44
+ GetProxyColor(charIndex).SetColorGradient(value);
45
+ colorsChangedByProperties = true;
46
+ }
47
+
48
+ /// <summary>
49
+ ///
50
+ /// </summary>
51
+ public Vector3 GetLocalStartPosition(int charIndex)
52
+ {
53
+ if (charIndex >= characterCount)
54
+ return Vector3.zero;
55
+
56
+ ProxyTransform proxy;
57
+ if (proxyTransformDict != null && proxyTransformDict.TryGetValue(charIndex, out proxy))
58
+ return proxy.LocalStartPosition;
59
+
60
+ TMP_CharacterInfo charInfo = Text.textInfo.characterInfo[charIndex];
61
+ return new Vector3(
62
+ (charInfo.topLeft.x + charInfo.bottomRight.x) * 0.5f,
63
+ (charInfo.topLeft.y + charInfo.bottomRight.y) * 0.5f,
64
+ (charInfo.topLeft.z + charInfo.bottomRight.z) * 0.5f);
65
+ }
66
+
67
+ /// <summary>
68
+ ///
69
+ /// </summary>
70
+ public Vector3 GetStartPosition(int charIndex)
71
+ {
72
+ return proxyTransformParent.TransformPoint(GetLocalStartPosition(charIndex));
73
+ }
74
+
75
+ /// <summary>
76
+ ///
77
+ /// </summary>
78
+ public Vector3 GetOffsetPosition(int charIndex)
79
+ {
80
+ ProxyTransform proxyTransform = TryGetProxyTransform(charIndex);
81
+ return proxyTransform != null ? proxyTransform.OffsetPosition : Vector3.zero;
82
+ }
83
+
84
+ /// <summary>
85
+ ///
86
+ /// </summary>
87
+ public void SetOffsetPosition(int charIndex, Vector3 value)
88
+ {
89
+ GetProxyTransform(charIndex).OffsetPosition = value;
90
+ transformsChangedByProperties = true;
91
+ }
92
+
93
+ /// <summary>
94
+ ///
95
+ /// </summary>
96
+ public void ResetPosition(int charIndex)
97
+ {
98
+ GetProxyTransform(charIndex).OffsetPosition = Vector3.zero;
99
+ transformsChangedByProperties = true;
100
+ }
101
+
102
+ /// <summary>
103
+ ///
104
+ /// </summary>
105
+ public Vector3 GetLocalPosition(int charIndex)
106
+ {
107
+ // We must create the proxy here to calculate the value
108
+ return GetProxyTransform(charIndex).LocalPosition;
109
+ }
110
+
111
+ /// <summary>
112
+ ///
113
+ /// </summary>
114
+ public void SetLocalPosition(int charIndex, Vector3 localPosition)
115
+ {
116
+ GetProxyTransform(charIndex).LocalPosition = localPosition;
117
+ transformsChangedByProperties = true;
118
+ }
119
+
120
+ /// <summary>
121
+ ///
122
+ /// </summary>
123
+ public Vector3 GetPosition(int charIndex)
124
+ {
125
+ // We must create the proxy here to calculate the value
126
+ return GetProxyTransform(charIndex).Position;
127
+ }
128
+
129
+ /// <summary>
130
+ ///
131
+ /// </summary>
132
+ public void SetPosition(int charIndex, Vector3 position)
133
+ {
134
+ GetProxyTransform(charIndex).Position = position;
135
+ transformsChangedByProperties = true;
136
+ }
137
+
138
+ public Vector3 GetLocalEulerAngles(int charIndex)
139
+ {
140
+ ProxyTransform proxyTransform = TryGetProxyTransform(charIndex);
141
+ return proxyTransform != null ? proxyTransform.Target.localEulerAngles : Vector3.zero;
142
+ }
143
+
144
+ public void SetLocalEulerAngles(int charIndex, Vector3 localEulerAngles)
145
+ {
146
+ GetProxyTransform(charIndex).Target.localEulerAngles = localEulerAngles;
147
+ transformsChangedByProperties = true;
148
+ }
149
+
150
+ public Vector3 GetEulerAngles(int charIndex)
151
+ {
152
+ ProxyTransform proxyTransform = TryGetProxyTransform(charIndex);
153
+ return proxyTransform != null ? proxyTransform.Target.eulerAngles : proxyTransformParent.eulerAngles;
154
+ }
155
+
156
+ public void SetEulerAngles(int charIndex, Vector3 eulerAngles)
157
+ {
158
+ GetProxyTransform(charIndex).Target.eulerAngles = eulerAngles;
159
+ transformsChangedByProperties = true;
160
+ }
161
+
162
+ public Quaternion GetLocalRotation(int charIndex)
163
+ {
164
+ ProxyTransform proxyTransform = TryGetProxyTransform(charIndex);
165
+ return proxyTransform != null ? proxyTransform.Target.localRotation : Quaternion.identity;
166
+ }
167
+
168
+ public void SetLocalRotation(int charIndex, Quaternion localRotation)
169
+ {
170
+ GetProxyTransform(charIndex).Target.localRotation = localRotation;
171
+ transformsChangedByProperties = true;
172
+ }
173
+
174
+ public Quaternion GetRotation(int charIndex)
175
+ {
176
+ ProxyTransform proxyTransform = TryGetProxyTransform(charIndex);
177
+ return proxyTransform != null ? proxyTransform.Target.rotation : proxyTransformParent.rotation;
178
+ }
179
+
180
+ public void SetRotation(int charIndex, Quaternion rotation)
181
+ {
182
+ GetProxyTransform(charIndex).Target.rotation = rotation;
183
+ transformsChangedByProperties = true;
184
+ }
185
+
186
+ public void ResetRotation(int charIndex)
187
+ {
188
+ // Setting localRotation because we want to keep the textmesh's rotation
189
+ GetProxyTransform(charIndex).Target.localRotation = Quaternion.identity;
190
+ transformsChangedByProperties = true;
191
+ }
192
+
193
+ public Vector3 GetLocalScale(int charIndex)
194
+ {
195
+ ProxyTransform proxyTransform = TryGetProxyTransform(charIndex);
196
+ return proxyTransform != null ? GetProxyTransform(charIndex).Target.localScale : Vector3.one;
197
+ }
198
+
199
+ public void SetLocalScale(int charIndex, float localScale)
200
+ {
201
+ GetProxyTransform(charIndex).Target.localScale = new Vector3(localScale, localScale, localScale);
202
+ transformsChangedByProperties = true;
203
+ }
204
+
205
+ public void SetLocalScale(int charIndex, Vector3 localScale)
206
+ {
207
+ GetProxyTransform(charIndex).Target.localScale = localScale;
208
+ transformsChangedByProperties = true;
209
+ }
210
+
211
+ public void ResetScale(int charIndex)
212
+ {
213
+ GetProxyTransform(charIndex).Target.localScale = Vector3.one;
214
+ transformsChangedByProperties = true;
215
+ }
216
+
217
+ public void LookAt(int charIndex, Transform target)
218
+ {
219
+ GetProxyTransform(charIndex).Target.LookAt(target);
220
+ transformsChangedByProperties = true;
221
+ }
222
+
223
+ public void LookAt(int charIndex, Transform target, Vector3 worldUp)
224
+ {
225
+ GetProxyTransform(charIndex).Target.LookAt(target, worldUp);
226
+ transformsChangedByProperties = true;
227
+ }
228
+
229
+ public void LookAt(int charIndex, Vector3 worldPosition)
230
+ {
231
+ GetProxyTransform(charIndex).Target.LookAt(worldPosition);
232
+ transformsChangedByProperties = true;
233
+ }
234
+
235
+ public void LookAt(int charIndex, Vector3 worldPosition, Vector3 worldUp)
236
+ {
237
+ GetProxyTransform(charIndex).Target.LookAt(worldPosition, worldUp);
238
+ transformsChangedByProperties = true;
239
+ }
240
+
241
+ public void Rotate(int charIndex, Vector3 eulerAngles)
242
+ {
243
+ GetProxyTransform(charIndex).Target.Rotate(eulerAngles);
244
+ transformsChangedByProperties = true;
245
+ }
246
+
247
+ public void Rotate(int charIndex, Vector3 eulerAngles, Space relativeTo)
248
+ {
249
+ GetProxyTransform(charIndex).Target.Rotate(eulerAngles, relativeTo);
250
+ transformsChangedByProperties = true;
251
+ }
252
+
253
+ public void Rotate(int charIndex, Vector3 axis, float angle)
254
+ {
255
+ GetProxyTransform(charIndex).Target.Rotate(axis, angle);
256
+ transformsChangedByProperties = true;
257
+ }
258
+
259
+ public void Rotate(int charIndex, Vector3 axis, float angle, Space relativeTo)
260
+ {
261
+ GetProxyTransform(charIndex).Target.Rotate(axis, angle, relativeTo);
262
+ transformsChangedByProperties = true;
263
+ }
264
+
265
+ public void Rotate(int charIndex, float xAngle, float yAngle, float zAngle)
266
+ {
267
+ GetProxyTransform(charIndex).Target.Rotate(xAngle, yAngle, zAngle);
268
+ transformsChangedByProperties = true;
269
+ }
270
+
271
+ public void Rotate(int charIndex, float xAngle, float yAngle, float zAngle, Space relativeTo)
272
+ {
273
+ GetProxyTransform(charIndex).Target.Rotate(xAngle, yAngle, zAngle, relativeTo);
274
+ transformsChangedByProperties = true;
275
+ }
276
+
277
+ public void RotateAround(int charIndex, Vector3 point, Vector3 axis, float angle)
278
+ {
279
+ GetProxyTransform(charIndex).Target.RotateAround(point, axis, angle);
280
+ transformsChangedByProperties = true;
281
+ }
282
+
283
+ public void Translate(int charIndex, Vector3 translation)
284
+ {
285
+ GetProxyTransform(charIndex).Target.Translate(translation);
286
+ transformsChangedByProperties = true;
287
+ }
288
+
289
+ public void Translate(int charIndex, Vector3 translation, Space relativeTo)
290
+ {
291
+ GetProxyTransform(charIndex).Target.Translate(translation, relativeTo);
292
+ transformsChangedByProperties = true;
293
+ }
294
+
295
+ public void Translate(int charIndex, Vector3 translation, Transform relativeTo)
296
+ {
297
+ GetProxyTransform(charIndex).Target.Translate(translation, relativeTo);
298
+ transformsChangedByProperties = true;
299
+ }
300
+
301
+ public void Translate(int charIndex, float x, float y, float z)
302
+ {
303
+ GetProxyTransform(charIndex).Target.Translate(x, y, z);
304
+ transformsChangedByProperties = true;
305
+ }
306
+
307
+ public void Translate(int charIndex, float x, float y, float z, Space relativeTo)
308
+ {
309
+ GetProxyTransform(charIndex).Target.Translate(x, y, z, relativeTo);
310
+ transformsChangedByProperties = true;
311
+ }
312
+
313
+ // There is no SetLossyScale because it's not available in Transform
314
+ public Vector3 GetLossyScale(int charIndex)
315
+ {
316
+ ProxyTransform proxyTransform = TryGetProxyTransform(charIndex);
317
+ return proxyTransform != null ? proxyTransform.Target.lossyScale : proxyTransformParent.lossyScale;
318
+ }
319
+
320
+ public Matrix4x4 GetLocalToWorldMatrix(int charIndex)
321
+ {
322
+ ProxyTransform proxyTransform = TryGetProxyTransform(charIndex);
323
+ return proxyTransform != null ? proxyTransform.Target.localToWorldMatrix : proxyTransformParent.localToWorldMatrix;
324
+ }
325
+
326
+ public Matrix4x4 GetWorldToLocalMatrix(int charIndex)
327
+ {
328
+ ProxyTransform proxyTransform = TryGetProxyTransform(charIndex);
329
+ return proxyTransform != null ? proxyTransform.Target.worldToLocalMatrix : proxyTransformParent.worldToLocalMatrix;
330
+ }
331
+
332
+ public Vector3 GetUpVector(int charIndex)
333
+ {
334
+ ProxyTransform proxyTransform = TryGetProxyTransform(charIndex);
335
+ return proxyTransform != null ? proxyTransform.Target.up : proxyTransformParent.up;
336
+ }
337
+
338
+ public Vector3 GetForwardVector(int charIndex)
339
+ {
340
+ ProxyTransform proxyTransform = TryGetProxyTransform(charIndex);
341
+ return proxyTransform != null ? proxyTransform.Target.forward : proxyTransformParent.forward;
342
+ }
343
+
344
+ public Vector3 GetRightVector(int charIndex)
345
+ {
346
+ ProxyTransform proxyTransform = TryGetProxyTransform(charIndex);
347
+ return proxyTransform != null ? proxyTransform.Target.right : proxyTransformParent.right;
348
+ }
349
+
350
+ public Vector3 InverseTransformDirection(int charIndex, Vector3 direction)
351
+ {
352
+ ProxyTransform proxyTransform = TryGetProxyTransform(charIndex);
353
+ return proxyTransform != null
354
+ ? proxyTransform.Target.InverseTransformDirection(direction)
355
+ : proxyTransformParent.InverseTransformDirection(direction);
356
+ }
357
+
358
+ public Vector3 InverseTransformDirection(int charIndex, float x, float y, float z)
359
+ {
360
+ ProxyTransform proxyTransform = TryGetProxyTransform(charIndex);
361
+ return proxyTransform != null
362
+ ? proxyTransform.Target.InverseTransformDirection(x, y, z)
363
+ : proxyTransformParent.InverseTransformDirection(x, y, z);
364
+ }
365
+
366
+ public Vector3 InverseTransformPoint(int charIndex, Vector3 Point)
367
+ {
368
+ ProxyTransform proxyTransform = TryGetProxyTransform(charIndex);
369
+ return proxyTransform != null
370
+ ? proxyTransform.Target.InverseTransformPoint(Point)
371
+ : proxyTransformParent.InverseTransformPoint(Point);
372
+ }
373
+
374
+ public Vector3 InverseTransformPoint(int charIndex, float x, float y, float z)
375
+ {
376
+ ProxyTransform proxyTransform = TryGetProxyTransform(charIndex);
377
+ return proxyTransform != null
378
+ ? proxyTransform.Target.InverseTransformPoint(x, y, z)
379
+ : proxyTransformParent.InverseTransformPoint(x, y, z);
380
+ }
381
+
382
+ public Vector3 InverseTransformVector(int charIndex, Vector3 Vector)
383
+ {
384
+ ProxyTransform proxyTransform = TryGetProxyTransform(charIndex);
385
+ return proxyTransform != null
386
+ ? proxyTransform.Target.InverseTransformVector(Vector)
387
+ : proxyTransformParent.InverseTransformVector(Vector);
388
+ }
389
+
390
+ public Vector3 InverseTransformVector(int charIndex, float x, float y, float z)
391
+ {
392
+ ProxyTransform proxyTransform = TryGetProxyTransform(charIndex);
393
+ return proxyTransform != null
394
+ ? proxyTransform.Target.InverseTransformVector(x, y, z)
395
+ : proxyTransformParent.InverseTransformVector(x, y, z);
396
+ }
397
+
398
+ public Vector3 TransformDirection(int charIndex, Vector3 direction)
399
+ {
400
+ ProxyTransform proxyTransform = TryGetProxyTransform(charIndex);
401
+ return proxyTransform != null
402
+ ? proxyTransform.Target.TransformDirection(direction)
403
+ : proxyTransformParent.TransformDirection(direction);
404
+ }
405
+
406
+ public Vector3 TransformDirection(int charIndex, float x, float y, float z)
407
+ {
408
+ ProxyTransform proxyTransform = TryGetProxyTransform(charIndex);
409
+ return proxyTransform != null
410
+ ? proxyTransform.Target.TransformDirection(x, y, z)
411
+ : proxyTransformParent.TransformDirection(x, y, z);
412
+ }
413
+
414
+ public Vector3 TransformPoint(int charIndex, Vector3 Point)
415
+ {
416
+ ProxyTransform proxyTransform = TryGetProxyTransform(charIndex);
417
+ return proxyTransform != null
418
+ ? proxyTransform.Target.TransformPoint(Point)
419
+ : proxyTransformParent.TransformPoint(Point);
420
+ }
421
+
422
+ public Vector3 TransformPoint(int charIndex, float x, float y, float z)
423
+ {
424
+ ProxyTransform proxyTransform = TryGetProxyTransform(charIndex);
425
+ return proxyTransform != null
426
+ ? proxyTransform.Target.TransformPoint(x, y, z)
427
+ : proxyTransformParent.TransformPoint(x, y, z);
428
+ }
429
+
430
+ public Vector3 TransformVector(int charIndex, Vector3 Vector)
431
+ {
432
+ ProxyTransform proxyTransform = TryGetProxyTransform(charIndex);
433
+ return proxyTransform != null
434
+ ? proxyTransform.Target.TransformVector(Vector)
435
+ : proxyTransformParent.TransformVector(Vector);
436
+ }
437
+
438
+ public Vector3 TransformVector(int charIndex, float x, float y, float z)
439
+ {
440
+ ProxyTransform proxyTransform = TryGetProxyTransform(charIndex);
441
+ return proxyTransform != null
442
+ ? proxyTransform.Target.TransformVector(x, y, z)
443
+ : proxyTransformParent.TransformVector(x, y, z);
444
+ }
445
+ }
446
+ }
447
+ #endif
@@ -0,0 +1,13 @@
1
+ fileFormatVersion: 2
2
+ guid: 75ff201e398eb65438449843fc1e70ec
3
+ timeCreated: 1525910733
4
+ licenseType: Free
5
+ MonoImporter:
6
+ externalObjects: {}
7
+ serializedVersion: 2
8
+ defaultReferences: []
9
+ executionOrder: 0
10
+ icon: {instanceID: 0}
11
+ userData:
12
+ assetBundleName:
13
+ assetBundleVariant: