Boppin score UI
This commit is contained in:
parent
c9f00f2f03
commit
01607da25e
Binary file not shown.
|
@ -55,7 +55,7 @@ Material:
|
||||||
m_PrefabInstance: {fileID: 0}
|
m_PrefabInstance: {fileID: 0}
|
||||||
m_PrefabAsset: {fileID: 0}
|
m_PrefabAsset: {fileID: 0}
|
||||||
m_Name: LEMONMILK-Regular SDF Material
|
m_Name: LEMONMILK-Regular SDF Material
|
||||||
m_Shader: {fileID: 4800000, guid: 68e6db2ebdc24f95958faec2be5558d6, type: 3}
|
m_Shader: {fileID: 4800000, guid: dd89cf5b9246416f84610a006f916af7, type: 3}
|
||||||
m_ShaderKeywords:
|
m_ShaderKeywords:
|
||||||
m_LightmapFlags: 4
|
m_LightmapFlags: 4
|
||||||
m_EnableInstancingVariants: 0
|
m_EnableInstancingVariants: 0
|
||||||
|
|
|
@ -1,8 +0,0 @@
|
||||||
fileFormatVersion: 2
|
|
||||||
guid: a626c4196d1da4a9197aabfe96a37078
|
|
||||||
folderAsset: yes
|
|
||||||
DefaultImporter:
|
|
||||||
externalObjects: {}
|
|
||||||
userData:
|
|
||||||
assetBundleName:
|
|
||||||
assetBundleVariant:
|
|
BIN
Assets/Images/crosshairs64.png (Stored with Git LFS)
BIN
Assets/Images/crosshairs64.png (Stored with Git LFS)
Binary file not shown.
File diff suppressed because it is too large
Load Diff
|
@ -288,6 +288,106 @@ MonoBehaviour:
|
||||||
m_Script: {fileID: 11500000, guid: 3147f962613cca54f8a0b78929a2854b, type: 3}
|
m_Script: {fileID: 11500000, guid: 3147f962613cca54f8a0b78929a2854b, type: 3}
|
||||||
m_Name:
|
m_Name:
|
||||||
m_EditorClassIdentifier:
|
m_EditorClassIdentifier:
|
||||||
|
--- !u!1 &726912288
|
||||||
|
GameObject:
|
||||||
|
m_ObjectHideFlags: 0
|
||||||
|
m_CorrespondingSourceObject: {fileID: 0}
|
||||||
|
m_PrefabInstance: {fileID: 0}
|
||||||
|
m_PrefabAsset: {fileID: 0}
|
||||||
|
serializedVersion: 6
|
||||||
|
m_Component:
|
||||||
|
- component: {fileID: 726912292}
|
||||||
|
- component: {fileID: 726912291}
|
||||||
|
- component: {fileID: 726912290}
|
||||||
|
- component: {fileID: 726912289}
|
||||||
|
m_Layer: 5
|
||||||
|
m_Name: Canvas
|
||||||
|
m_TagString: Untagged
|
||||||
|
m_Icon: {fileID: 0}
|
||||||
|
m_NavMeshLayer: 0
|
||||||
|
m_StaticEditorFlags: 0
|
||||||
|
m_IsActive: 1
|
||||||
|
--- !u!114 &726912289
|
||||||
|
MonoBehaviour:
|
||||||
|
m_ObjectHideFlags: 0
|
||||||
|
m_CorrespondingSourceObject: {fileID: 0}
|
||||||
|
m_PrefabInstance: {fileID: 0}
|
||||||
|
m_PrefabAsset: {fileID: 0}
|
||||||
|
m_GameObject: {fileID: 726912288}
|
||||||
|
m_Enabled: 1
|
||||||
|
m_EditorHideFlags: 0
|
||||||
|
m_Script: {fileID: 11500000, guid: dc42784cf147c0c48a680349fa168899, type: 3}
|
||||||
|
m_Name:
|
||||||
|
m_EditorClassIdentifier:
|
||||||
|
m_IgnoreReversedGraphics: 1
|
||||||
|
m_BlockingObjects: 0
|
||||||
|
m_BlockingMask:
|
||||||
|
serializedVersion: 2
|
||||||
|
m_Bits: 4294967295
|
||||||
|
--- !u!114 &726912290
|
||||||
|
MonoBehaviour:
|
||||||
|
m_ObjectHideFlags: 0
|
||||||
|
m_CorrespondingSourceObject: {fileID: 0}
|
||||||
|
m_PrefabInstance: {fileID: 0}
|
||||||
|
m_PrefabAsset: {fileID: 0}
|
||||||
|
m_GameObject: {fileID: 726912288}
|
||||||
|
m_Enabled: 1
|
||||||
|
m_EditorHideFlags: 0
|
||||||
|
m_Script: {fileID: 11500000, guid: 0cd44c1031e13a943bb63640046fad76, type: 3}
|
||||||
|
m_Name:
|
||||||
|
m_EditorClassIdentifier:
|
||||||
|
m_UiScaleMode: 0
|
||||||
|
m_ReferencePixelsPerUnit: 100
|
||||||
|
m_ScaleFactor: 1
|
||||||
|
m_ReferenceResolution: {x: 800, y: 600}
|
||||||
|
m_ScreenMatchMode: 0
|
||||||
|
m_MatchWidthOrHeight: 0
|
||||||
|
m_PhysicalUnit: 3
|
||||||
|
m_FallbackScreenDPI: 96
|
||||||
|
m_DefaultSpriteDPI: 96
|
||||||
|
m_DynamicPixelsPerUnit: 1
|
||||||
|
m_PresetInfoIsWorld: 0
|
||||||
|
--- !u!223 &726912291
|
||||||
|
Canvas:
|
||||||
|
m_ObjectHideFlags: 0
|
||||||
|
m_CorrespondingSourceObject: {fileID: 0}
|
||||||
|
m_PrefabInstance: {fileID: 0}
|
||||||
|
m_PrefabAsset: {fileID: 0}
|
||||||
|
m_GameObject: {fileID: 726912288}
|
||||||
|
m_Enabled: 1
|
||||||
|
serializedVersion: 3
|
||||||
|
m_RenderMode: 0
|
||||||
|
m_Camera: {fileID: 0}
|
||||||
|
m_PlaneDistance: 100
|
||||||
|
m_PixelPerfect: 0
|
||||||
|
m_ReceivesEvents: 1
|
||||||
|
m_OverrideSorting: 0
|
||||||
|
m_OverridePixelPerfect: 0
|
||||||
|
m_SortingBucketNormalizedSize: 0
|
||||||
|
m_AdditionalShaderChannelsFlag: 25
|
||||||
|
m_SortingLayerID: 0
|
||||||
|
m_SortingOrder: 0
|
||||||
|
m_TargetDisplay: 0
|
||||||
|
--- !u!224 &726912292
|
||||||
|
RectTransform:
|
||||||
|
m_ObjectHideFlags: 0
|
||||||
|
m_CorrespondingSourceObject: {fileID: 0}
|
||||||
|
m_PrefabInstance: {fileID: 0}
|
||||||
|
m_PrefabAsset: {fileID: 0}
|
||||||
|
m_GameObject: {fileID: 726912288}
|
||||||
|
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
|
||||||
|
m_LocalPosition: {x: 0, y: 0, z: 0}
|
||||||
|
m_LocalScale: {x: 0, y: 0, z: 0}
|
||||||
|
m_Children:
|
||||||
|
- {fileID: 1330494722}
|
||||||
|
m_Father: {fileID: 0}
|
||||||
|
m_RootOrder: 8
|
||||||
|
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
|
||||||
|
m_AnchorMin: {x: 0, y: 0}
|
||||||
|
m_AnchorMax: {x: 0, y: 0}
|
||||||
|
m_AnchoredPosition: {x: 0, y: 0}
|
||||||
|
m_SizeDelta: {x: 0, y: 0}
|
||||||
|
m_Pivot: {x: 0, y: 0}
|
||||||
--- !u!1 &728836291
|
--- !u!1 &728836291
|
||||||
GameObject:
|
GameObject:
|
||||||
m_ObjectHideFlags: 0
|
m_ObjectHideFlags: 0
|
||||||
|
@ -534,7 +634,7 @@ PrefabInstance:
|
||||||
objectReference: {fileID: 0}
|
objectReference: {fileID: 0}
|
||||||
- target: {fileID: 3397488660859550701, guid: 1f82f952c53fc7449a0091cf29ba3def, type: 3}
|
- target: {fileID: 3397488660859550701, guid: 1f82f952c53fc7449a0091cf29ba3def, type: 3}
|
||||||
propertyPath: m_LocalPosition.y
|
propertyPath: m_LocalPosition.y
|
||||||
value: 9.773619
|
value: 8.773619
|
||||||
objectReference: {fileID: 0}
|
objectReference: {fileID: 0}
|
||||||
- target: {fileID: 3397488660859550701, guid: 1f82f952c53fc7449a0091cf29ba3def, type: 3}
|
- target: {fileID: 3397488660859550701, guid: 1f82f952c53fc7449a0091cf29ba3def, type: 3}
|
||||||
propertyPath: m_LocalPosition.z
|
propertyPath: m_LocalPosition.z
|
||||||
|
@ -904,6 +1004,155 @@ Transform:
|
||||||
m_Father: {fileID: 1173812008}
|
m_Father: {fileID: 1173812008}
|
||||||
m_RootOrder: 1
|
m_RootOrder: 1
|
||||||
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
|
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
|
||||||
|
--- !u!1 &1330494721
|
||||||
|
GameObject:
|
||||||
|
m_ObjectHideFlags: 0
|
||||||
|
m_CorrespondingSourceObject: {fileID: 0}
|
||||||
|
m_PrefabInstance: {fileID: 0}
|
||||||
|
m_PrefabAsset: {fileID: 0}
|
||||||
|
serializedVersion: 6
|
||||||
|
m_Component:
|
||||||
|
- component: {fileID: 1330494722}
|
||||||
|
- component: {fileID: 1330494724}
|
||||||
|
- component: {fileID: 1330494723}
|
||||||
|
- component: {fileID: 1330494726}
|
||||||
|
m_Layer: 5
|
||||||
|
m_Name: Score
|
||||||
|
m_TagString: Untagged
|
||||||
|
m_Icon: {fileID: 0}
|
||||||
|
m_NavMeshLayer: 0
|
||||||
|
m_StaticEditorFlags: 0
|
||||||
|
m_IsActive: 1
|
||||||
|
--- !u!224 &1330494722
|
||||||
|
RectTransform:
|
||||||
|
m_ObjectHideFlags: 0
|
||||||
|
m_CorrespondingSourceObject: {fileID: 0}
|
||||||
|
m_PrefabInstance: {fileID: 0}
|
||||||
|
m_PrefabAsset: {fileID: 0}
|
||||||
|
m_GameObject: {fileID: 1330494721}
|
||||||
|
m_LocalRotation: {x: -0, y: -0, z: -0, w: 1}
|
||||||
|
m_LocalPosition: {x: 0, y: 0, z: 0}
|
||||||
|
m_LocalScale: {x: 1, y: 1, z: 1}
|
||||||
|
m_Children: []
|
||||||
|
m_Father: {fileID: 726912292}
|
||||||
|
m_RootOrder: 0
|
||||||
|
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
|
||||||
|
m_AnchorMin: {x: 0, y: 1}
|
||||||
|
m_AnchorMax: {x: 1, y: 1}
|
||||||
|
m_AnchoredPosition: {x: 0, y: -30}
|
||||||
|
m_SizeDelta: {x: 0, y: 50}
|
||||||
|
m_Pivot: {x: 0.5, y: 1}
|
||||||
|
--- !u!114 &1330494723
|
||||||
|
MonoBehaviour:
|
||||||
|
m_ObjectHideFlags: 0
|
||||||
|
m_CorrespondingSourceObject: {fileID: 0}
|
||||||
|
m_PrefabInstance: {fileID: 0}
|
||||||
|
m_PrefabAsset: {fileID: 0}
|
||||||
|
m_GameObject: {fileID: 1330494721}
|
||||||
|
m_Enabled: 1
|
||||||
|
m_EditorHideFlags: 0
|
||||||
|
m_Script: {fileID: 11500000, guid: f4688fdb7df04437aeb418b961361dc5, type: 3}
|
||||||
|
m_Name:
|
||||||
|
m_EditorClassIdentifier:
|
||||||
|
m_Material: {fileID: 0}
|
||||||
|
m_Color: {r: 1, g: 1, b: 1, a: 1}
|
||||||
|
m_RaycastTarget: 1
|
||||||
|
m_RaycastPadding: {x: 0, y: 0, z: 0, w: 0}
|
||||||
|
m_Maskable: 1
|
||||||
|
m_OnCullStateChanged:
|
||||||
|
m_PersistentCalls:
|
||||||
|
m_Calls: []
|
||||||
|
m_text: 1,234,567,898,765,432
|
||||||
|
m_isRightToLeft: 0
|
||||||
|
m_fontAsset: {fileID: 11400000, guid: 0f0f54895994248b0bf34c4b4d27beef, type: 2}
|
||||||
|
m_sharedMaterial: {fileID: -3347474280721358513, guid: 0f0f54895994248b0bf34c4b4d27beef, type: 2}
|
||||||
|
m_fontSharedMaterials: []
|
||||||
|
m_fontMaterial: {fileID: 0}
|
||||||
|
m_fontMaterials: []
|
||||||
|
m_fontColor32:
|
||||||
|
serializedVersion: 2
|
||||||
|
rgba: 4294967295
|
||||||
|
m_fontColor: {r: 1, g: 1, b: 1, a: 1}
|
||||||
|
m_enableVertexGradient: 0
|
||||||
|
m_colorMode: 3
|
||||||
|
m_fontColorGradient:
|
||||||
|
topLeft: {r: 1, g: 1, b: 1, a: 1}
|
||||||
|
topRight: {r: 1, g: 1, b: 1, a: 1}
|
||||||
|
bottomLeft: {r: 1, g: 1, b: 1, a: 1}
|
||||||
|
bottomRight: {r: 1, g: 1, b: 1, a: 1}
|
||||||
|
m_fontColorGradientPreset: {fileID: 0}
|
||||||
|
m_spriteAsset: {fileID: 0}
|
||||||
|
m_tintAllSprites: 0
|
||||||
|
m_StyleSheet: {fileID: 0}
|
||||||
|
m_TextStyleHashCode: -1183493901
|
||||||
|
m_overrideHtmlColors: 0
|
||||||
|
m_faceColor:
|
||||||
|
serializedVersion: 2
|
||||||
|
rgba: 4294967295
|
||||||
|
m_fontSize: 48
|
||||||
|
m_fontSizeBase: 48
|
||||||
|
m_fontWeight: 400
|
||||||
|
m_enableAutoSizing: 0
|
||||||
|
m_fontSizeMin: 18
|
||||||
|
m_fontSizeMax: 72
|
||||||
|
m_fontStyle: 0
|
||||||
|
m_HorizontalAlignment: 2
|
||||||
|
m_VerticalAlignment: 8192
|
||||||
|
m_textAlignment: 65535
|
||||||
|
m_characterSpacing: 0
|
||||||
|
m_wordSpacing: 0
|
||||||
|
m_lineSpacing: 0
|
||||||
|
m_lineSpacingMax: 0
|
||||||
|
m_paragraphSpacing: 0
|
||||||
|
m_charWidthMaxAdj: 0
|
||||||
|
m_enableWordWrapping: 1
|
||||||
|
m_wordWrappingRatios: 0.4
|
||||||
|
m_overflowMode: 0
|
||||||
|
m_linkedTextComponent: {fileID: 0}
|
||||||
|
parentLinkedComponent: {fileID: 0}
|
||||||
|
m_enableKerning: 1
|
||||||
|
m_enableExtraPadding: 0
|
||||||
|
checkPaddingRequired: 0
|
||||||
|
m_isRichText: 1
|
||||||
|
m_parseCtrlCharacters: 1
|
||||||
|
m_isOrthographic: 1
|
||||||
|
m_isCullingEnabled: 0
|
||||||
|
m_horizontalMapping: 0
|
||||||
|
m_verticalMapping: 0
|
||||||
|
m_uvLineOffset: 0
|
||||||
|
m_geometrySortingOrder: 0
|
||||||
|
m_IsTextObjectScaleStatic: 0
|
||||||
|
m_VertexBufferAutoSizeReduction: 1
|
||||||
|
m_useMaxVisibleDescender: 1
|
||||||
|
m_pageToDisplay: 1
|
||||||
|
m_margin: {x: 0, y: 0, z: 0, w: 0}
|
||||||
|
m_isUsingLegacyAnimationComponent: 0
|
||||||
|
m_isVolumetricText: 0
|
||||||
|
m_hasFontAssetChanged: 0
|
||||||
|
m_baseMaterial: {fileID: 0}
|
||||||
|
m_maskOffset: {x: 0, y: 0, z: 0, w: 0}
|
||||||
|
--- !u!222 &1330494724
|
||||||
|
CanvasRenderer:
|
||||||
|
m_ObjectHideFlags: 0
|
||||||
|
m_CorrespondingSourceObject: {fileID: 0}
|
||||||
|
m_PrefabInstance: {fileID: 0}
|
||||||
|
m_PrefabAsset: {fileID: 0}
|
||||||
|
m_GameObject: {fileID: 1330494721}
|
||||||
|
m_CullTransparentMesh: 1
|
||||||
|
--- !u!114 &1330494726
|
||||||
|
MonoBehaviour:
|
||||||
|
m_ObjectHideFlags: 0
|
||||||
|
m_CorrespondingSourceObject: {fileID: 0}
|
||||||
|
m_PrefabInstance: {fileID: 0}
|
||||||
|
m_PrefabAsset: {fileID: 0}
|
||||||
|
m_GameObject: {fileID: 1330494721}
|
||||||
|
m_Enabled: 1
|
||||||
|
m_EditorHideFlags: 0
|
||||||
|
m_Script: {fileID: 11500000, guid: 45e7636ea714949cd8358ebe56fef05f, type: 3}
|
||||||
|
m_Name:
|
||||||
|
m_EditorClassIdentifier:
|
||||||
|
timeSince: {fileID: 11400000, guid: 8f05f93192443bc42b8523048bde0dc4, type: 2}
|
||||||
|
scale: 0.25
|
||||||
--- !u!1 &1395215960
|
--- !u!1 &1395215960
|
||||||
GameObject:
|
GameObject:
|
||||||
m_ObjectHideFlags: 0
|
m_ObjectHideFlags: 0
|
||||||
|
|
|
@ -22,7 +22,7 @@ public class BeatSpawner : ShootInputBase
|
||||||
{
|
{
|
||||||
_shoot = beat % spawnOnBeat == 0;
|
_shoot = beat % spawnOnBeat == 0;
|
||||||
if (_shoot)
|
if (_shoot)
|
||||||
transform.position = new Vector3(Random.Range(xMin, xMax), transform.position.y, transform.position.z);
|
transform.position = new Vector3(Mathf.Lerp(xMin, xMax, Mathf.Sin(beat)), transform.position.y, transform.position.z);
|
||||||
}
|
}
|
||||||
|
|
||||||
public override bool IsShooting()
|
public override bool IsShooting()
|
||||||
|
|
|
@ -10,6 +10,9 @@ public class DisableOnDeath : MonoBehaviour
|
||||||
|
|
||||||
private Color _color1;
|
private Color _color1;
|
||||||
private Color _color2;
|
private Color _color2;
|
||||||
|
private static readonly int Color1 = Shader.PropertyToID(COLOR_1);
|
||||||
|
private static readonly int Color2 = Shader.PropertyToID(COLOR_2);
|
||||||
|
private static readonly int Alpha = Shader.PropertyToID("_Alpha");
|
||||||
|
|
||||||
private const string COLOR_1 = "_Color1";
|
private const string COLOR_1 = "_Color1";
|
||||||
private const string COLOR_2 = "_Color2";
|
private const string COLOR_2 = "_Color2";
|
||||||
|
@ -19,16 +22,16 @@ public class DisableOnDeath : MonoBehaviour
|
||||||
_health = GetComponent<EntityHealth>();
|
_health = GetComponent<EntityHealth>();
|
||||||
_renderer = GetComponentInChildren<Renderer>();
|
_renderer = GetComponentInChildren<Renderer>();
|
||||||
|
|
||||||
_color1 = _renderer.material.GetColor(COLOR_1);
|
_color1 = _renderer.material.GetColor(Color1);
|
||||||
_color2 = _renderer.material.GetColor(COLOR_2);
|
_color2 = _renderer.material.GetColor(Color2);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void OnEnable()
|
private void OnEnable()
|
||||||
{
|
{
|
||||||
_health.Die += Die;
|
_health.Die += Die;
|
||||||
|
|
||||||
_renderer.material.SetColor(COLOR_1, _color1);
|
_renderer.material.SetColor(Color1, _color1);
|
||||||
_renderer.material.SetColor(COLOR_2, _color2);
|
_renderer.material.SetColor(Color2, _color2);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void OnDisable()
|
private void OnDisable()
|
||||||
|
@ -49,19 +52,16 @@ public class DisableOnDeath : MonoBehaviour
|
||||||
var c1 = Color.Lerp(_color1, Color.white, t);
|
var c1 = Color.Lerp(_color1, Color.white, t);
|
||||||
var c2 = Color.Lerp(_color2, Color.white, t);
|
var c2 = Color.Lerp(_color2, Color.white, t);
|
||||||
|
|
||||||
_renderer.material.SetColor(COLOR_1, c1);
|
_renderer.material.SetColor(Color1, c1);
|
||||||
_renderer.material.SetColor(COLOR_2, c2);
|
_renderer.material.SetColor(Color2, c2);
|
||||||
_renderer.material.SetFloat("_Alpha", 1.0f-t);
|
_renderer.material.SetFloat(Alpha, 1.0f-t);
|
||||||
},
|
},
|
||||||
1.0f,
|
1.0f,
|
||||||
0.1f);
|
0.05f);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// _renderer.material.DOColor(Color.white, COLOR_1, 0.1f);
|
transform.DOScale(Vector3.one * 1.5f, 0.15f).SetEase(Ease.OutQuint).OnComplete(() =>
|
||||||
// _renderer.material.DOColor(Color.white, COLOR_2, 0.1f);
|
|
||||||
// _renderer.material.DOFade(0, 0.1f).SetDelay(0.2f);
|
|
||||||
transform.DOScale(Vector3.one * 1.5f, 0.3f).SetEase(Ease.OutQuint).OnComplete(() =>
|
|
||||||
{
|
{
|
||||||
gameObject.name = oldName;
|
gameObject.name = oldName;
|
||||||
gameObject.SetActive(false);
|
gameObject.SetActive(false);
|
||||||
|
|
|
@ -0,0 +1,29 @@
|
||||||
|
using System;
|
||||||
|
using System.Collections;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using Ktyl.Util;
|
||||||
|
using TMPro;
|
||||||
|
using UnityEngine;
|
||||||
|
|
||||||
|
public class ScaleWithTime : MonoBehaviour
|
||||||
|
{
|
||||||
|
[SerializeField] private SerialFloat timeSince;
|
||||||
|
|
||||||
|
[SerializeField] private float scale = 1.5f;
|
||||||
|
[SerializeField] private float ySquish = -0.15f;
|
||||||
|
[SerializeField] private float characterSpacing = 10f;
|
||||||
|
|
||||||
|
private TextMeshProUGUI _text;
|
||||||
|
|
||||||
|
private void Awake()
|
||||||
|
{
|
||||||
|
_text = GetComponent<TextMeshProUGUI>();
|
||||||
|
}
|
||||||
|
|
||||||
|
// Update is called once per frame
|
||||||
|
void Update()
|
||||||
|
{
|
||||||
|
_text.characterSpacing = timeSince * timeSince * characterSpacing;
|
||||||
|
transform.localScale = new Vector3(1 + timeSince*timeSince * scale, 1 + timeSince*timeSince * ySquish, 1);
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,11 @@
|
||||||
|
fileFormatVersion: 2
|
||||||
|
guid: 45e7636ea714949cd8358ebe56fef05f
|
||||||
|
MonoImporter:
|
||||||
|
externalObjects: {}
|
||||||
|
serializedVersion: 2
|
||||||
|
defaultReferences: []
|
||||||
|
executionOrder: 0
|
||||||
|
icon: {instanceID: 0}
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
|
@ -0,0 +1,175 @@
|
||||||
|
using UnityEngine;
|
||||||
|
using System.Collections;
|
||||||
|
|
||||||
|
|
||||||
|
namespace TMPro.Examples
|
||||||
|
{
|
||||||
|
|
||||||
|
public class VertexJitter : MonoBehaviour
|
||||||
|
{
|
||||||
|
|
||||||
|
public float AngleMultiplier = 1.0f;
|
||||||
|
public float SpeedMultiplier = 1.0f;
|
||||||
|
public float CurveScale = 1.0f;
|
||||||
|
|
||||||
|
private TMP_Text m_TextComponent;
|
||||||
|
private bool hasTextChanged;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Structure to hold pre-computed animation data.
|
||||||
|
/// </summary>
|
||||||
|
private struct VertexAnim
|
||||||
|
{
|
||||||
|
public float angleRange;
|
||||||
|
public float angle;
|
||||||
|
public float speed;
|
||||||
|
}
|
||||||
|
|
||||||
|
void Awake()
|
||||||
|
{
|
||||||
|
m_TextComponent = GetComponent<TMP_Text>();
|
||||||
|
}
|
||||||
|
|
||||||
|
void OnEnable()
|
||||||
|
{
|
||||||
|
// Subscribe to event fired when text object has been regenerated.
|
||||||
|
TMPro_EventManager.TEXT_CHANGED_EVENT.Add(ON_TEXT_CHANGED);
|
||||||
|
}
|
||||||
|
|
||||||
|
void OnDisable()
|
||||||
|
{
|
||||||
|
TMPro_EventManager.TEXT_CHANGED_EVENT.Remove(ON_TEXT_CHANGED);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void Start()
|
||||||
|
{
|
||||||
|
StartCoroutine(AnimateVertexColors());
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void ON_TEXT_CHANGED(Object obj)
|
||||||
|
{
|
||||||
|
if (obj == m_TextComponent)
|
||||||
|
hasTextChanged = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Method to animate vertex colors of a TMP Text object.
|
||||||
|
/// </summary>
|
||||||
|
/// <returns></returns>
|
||||||
|
IEnumerator AnimateVertexColors()
|
||||||
|
{
|
||||||
|
|
||||||
|
// We force an update of the text object since it would only be updated at the end of the frame. Ie. before this code is executed on the first frame.
|
||||||
|
// Alternatively, we could yield and wait until the end of the frame when the text object will be generated.
|
||||||
|
m_TextComponent.ForceMeshUpdate();
|
||||||
|
|
||||||
|
TMP_TextInfo textInfo = m_TextComponent.textInfo;
|
||||||
|
|
||||||
|
Matrix4x4 matrix;
|
||||||
|
|
||||||
|
int loopCount = 0;
|
||||||
|
hasTextChanged = true;
|
||||||
|
|
||||||
|
// Create an Array which contains pre-computed Angle Ranges and Speeds for a bunch of characters.
|
||||||
|
VertexAnim[] vertexAnim = new VertexAnim[1024];
|
||||||
|
for (int i = 0; i < 1024; i++)
|
||||||
|
{
|
||||||
|
vertexAnim[i].angleRange = Random.Range(10f, 25f);
|
||||||
|
vertexAnim[i].speed = Random.Range(1f, 3f);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Cache the vertex data of the text object as the Jitter FX is applied to the original position of the characters.
|
||||||
|
TMP_MeshInfo[] cachedMeshInfo = textInfo.CopyMeshInfoVertexData();
|
||||||
|
|
||||||
|
while (true)
|
||||||
|
{
|
||||||
|
// Get new copy of vertex data if the text has changed.
|
||||||
|
if (hasTextChanged)
|
||||||
|
{
|
||||||
|
// Update the copy of the vertex data for the text object.
|
||||||
|
cachedMeshInfo = textInfo.CopyMeshInfoVertexData();
|
||||||
|
|
||||||
|
hasTextChanged = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
int characterCount = textInfo.characterCount;
|
||||||
|
|
||||||
|
// If No Characters then just yield and wait for some text to be added
|
||||||
|
if (characterCount == 0)
|
||||||
|
{
|
||||||
|
yield return new WaitForSeconds(0.25f);
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
for (int i = 0; i < characterCount; i++)
|
||||||
|
{
|
||||||
|
TMP_CharacterInfo charInfo = textInfo.characterInfo[i];
|
||||||
|
|
||||||
|
// Skip characters that are not visible and thus have no geometry to manipulate.
|
||||||
|
if (!charInfo.isVisible)
|
||||||
|
continue;
|
||||||
|
|
||||||
|
// Retrieve the pre-computed animation data for the given character.
|
||||||
|
VertexAnim vertAnim = vertexAnim[i];
|
||||||
|
|
||||||
|
// Get the index of the material used by the current character.
|
||||||
|
int materialIndex = textInfo.characterInfo[i].materialReferenceIndex;
|
||||||
|
|
||||||
|
// Get the index of the first vertex used by this text element.
|
||||||
|
int vertexIndex = textInfo.characterInfo[i].vertexIndex;
|
||||||
|
|
||||||
|
// Get the cached vertices of the mesh used by this text element (character or sprite).
|
||||||
|
Vector3[] sourceVertices = cachedMeshInfo[materialIndex].vertices;
|
||||||
|
|
||||||
|
// Determine the center point of each character at the baseline.
|
||||||
|
//Vector2 charMidBasline = new Vector2((sourceVertices[vertexIndex + 0].x + sourceVertices[vertexIndex + 2].x) / 2, charInfo.baseLine);
|
||||||
|
// Determine the center point of each character.
|
||||||
|
Vector2 charMidBasline = (sourceVertices[vertexIndex + 0] + sourceVertices[vertexIndex + 2]) / 2;
|
||||||
|
|
||||||
|
// Need to translate all 4 vertices of each quad to aligned with middle of character / baseline.
|
||||||
|
// This is needed so the matrix TRS is applied at the origin for each character.
|
||||||
|
Vector3 offset = charMidBasline;
|
||||||
|
|
||||||
|
Vector3[] destinationVertices = textInfo.meshInfo[materialIndex].vertices;
|
||||||
|
|
||||||
|
destinationVertices[vertexIndex + 0] = sourceVertices[vertexIndex + 0] - offset;
|
||||||
|
destinationVertices[vertexIndex + 1] = sourceVertices[vertexIndex + 1] - offset;
|
||||||
|
destinationVertices[vertexIndex + 2] = sourceVertices[vertexIndex + 2] - offset;
|
||||||
|
destinationVertices[vertexIndex + 3] = sourceVertices[vertexIndex + 3] - offset;
|
||||||
|
|
||||||
|
vertAnim.angle = Mathf.SmoothStep(-vertAnim.angleRange, vertAnim.angleRange, Mathf.PingPong(loopCount / 25f * vertAnim.speed, 1f));
|
||||||
|
Vector3 jitterOffset = new Vector3(Random.Range(-.25f, .25f), Random.Range(-.25f, .25f), 0);
|
||||||
|
|
||||||
|
matrix = Matrix4x4.TRS(jitterOffset * CurveScale, Quaternion.Euler(0, 0, Random.Range(-5f, 5f) * AngleMultiplier), Vector3.one);
|
||||||
|
|
||||||
|
destinationVertices[vertexIndex + 0] = matrix.MultiplyPoint3x4(destinationVertices[vertexIndex + 0]);
|
||||||
|
destinationVertices[vertexIndex + 1] = matrix.MultiplyPoint3x4(destinationVertices[vertexIndex + 1]);
|
||||||
|
destinationVertices[vertexIndex + 2] = matrix.MultiplyPoint3x4(destinationVertices[vertexIndex + 2]);
|
||||||
|
destinationVertices[vertexIndex + 3] = matrix.MultiplyPoint3x4(destinationVertices[vertexIndex + 3]);
|
||||||
|
|
||||||
|
destinationVertices[vertexIndex + 0] += offset;
|
||||||
|
destinationVertices[vertexIndex + 1] += offset;
|
||||||
|
destinationVertices[vertexIndex + 2] += offset;
|
||||||
|
destinationVertices[vertexIndex + 3] += offset;
|
||||||
|
|
||||||
|
vertexAnim[i] = vertAnim;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Push changes into meshes
|
||||||
|
for (int i = 0; i < textInfo.meshInfo.Length; i++)
|
||||||
|
{
|
||||||
|
textInfo.meshInfo[i].mesh.vertices = textInfo.meshInfo[i].vertices;
|
||||||
|
m_TextComponent.UpdateGeometry(textInfo.meshInfo[i].mesh, i);
|
||||||
|
}
|
||||||
|
|
||||||
|
loopCount += 1;
|
||||||
|
|
||||||
|
yield return new WaitForSeconds(0.1f);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,12 @@
|
||||||
|
fileFormatVersion: 2
|
||||||
|
guid: 2ed57967c52645d390a89dcf8f61ba73
|
||||||
|
timeCreated: 1461286718
|
||||||
|
licenseType: Pro
|
||||||
|
MonoImporter:
|
||||||
|
serializedVersion: 2
|
||||||
|
defaultReferences: []
|
||||||
|
executionOrder: 0
|
||||||
|
icon: {instanceID: 0}
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
|
@ -0,0 +1,161 @@
|
||||||
|
using UnityEngine;
|
||||||
|
using System.Collections;
|
||||||
|
|
||||||
|
|
||||||
|
namespace TMPro.Examples
|
||||||
|
{
|
||||||
|
|
||||||
|
public class VertexShakeA : MonoBehaviour
|
||||||
|
{
|
||||||
|
|
||||||
|
public float AngleMultiplier = 1.0f;
|
||||||
|
public float SpeedMultiplier = 1.0f;
|
||||||
|
public float ScaleMultiplier = 1.0f;
|
||||||
|
public float RotationMultiplier = 1.0f;
|
||||||
|
|
||||||
|
private TMP_Text m_TextComponent;
|
||||||
|
private bool hasTextChanged;
|
||||||
|
|
||||||
|
|
||||||
|
void Awake()
|
||||||
|
{
|
||||||
|
m_TextComponent = GetComponent<TMP_Text>();
|
||||||
|
}
|
||||||
|
|
||||||
|
void OnEnable()
|
||||||
|
{
|
||||||
|
// Subscribe to event fired when text object has been regenerated.
|
||||||
|
TMPro_EventManager.TEXT_CHANGED_EVENT.Add(ON_TEXT_CHANGED);
|
||||||
|
}
|
||||||
|
|
||||||
|
void OnDisable()
|
||||||
|
{
|
||||||
|
TMPro_EventManager.TEXT_CHANGED_EVENT.Remove(ON_TEXT_CHANGED);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void Start()
|
||||||
|
{
|
||||||
|
StartCoroutine(AnimateVertexColors());
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void ON_TEXT_CHANGED(Object obj)
|
||||||
|
{
|
||||||
|
if (obj = m_TextComponent)
|
||||||
|
hasTextChanged = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Method to animate vertex colors of a TMP Text object.
|
||||||
|
/// </summary>
|
||||||
|
/// <returns></returns>
|
||||||
|
IEnumerator AnimateVertexColors()
|
||||||
|
{
|
||||||
|
|
||||||
|
// We force an update of the text object since it would only be updated at the end of the frame. Ie. before this code is executed on the first frame.
|
||||||
|
// Alternatively, we could yield and wait until the end of the frame when the text object will be generated.
|
||||||
|
m_TextComponent.ForceMeshUpdate();
|
||||||
|
|
||||||
|
TMP_TextInfo textInfo = m_TextComponent.textInfo;
|
||||||
|
|
||||||
|
Matrix4x4 matrix;
|
||||||
|
Vector3[][] copyOfVertices = new Vector3[0][];
|
||||||
|
|
||||||
|
hasTextChanged = true;
|
||||||
|
|
||||||
|
while (true)
|
||||||
|
{
|
||||||
|
// Allocate new vertices
|
||||||
|
if (hasTextChanged)
|
||||||
|
{
|
||||||
|
if (copyOfVertices.Length < textInfo.meshInfo.Length)
|
||||||
|
copyOfVertices = new Vector3[textInfo.meshInfo.Length][];
|
||||||
|
|
||||||
|
for (int i = 0; i < textInfo.meshInfo.Length; i++)
|
||||||
|
{
|
||||||
|
int length = textInfo.meshInfo[i].vertices.Length;
|
||||||
|
copyOfVertices[i] = new Vector3[length];
|
||||||
|
}
|
||||||
|
|
||||||
|
hasTextChanged = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
int characterCount = textInfo.characterCount;
|
||||||
|
|
||||||
|
// If No Characters then just yield and wait for some text to be added
|
||||||
|
if (characterCount == 0)
|
||||||
|
{
|
||||||
|
yield return new WaitForSeconds(0.25f);
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
int lineCount = textInfo.lineCount;
|
||||||
|
|
||||||
|
// Iterate through each line of the text.
|
||||||
|
for (int i = 0; i < lineCount; i++)
|
||||||
|
{
|
||||||
|
|
||||||
|
int first = textInfo.lineInfo[i].firstCharacterIndex;
|
||||||
|
int last = textInfo.lineInfo[i].lastCharacterIndex;
|
||||||
|
|
||||||
|
// Determine the center of each line
|
||||||
|
Vector3 centerOfLine = (textInfo.characterInfo[first].bottomLeft + textInfo.characterInfo[last].topRight) / 2;
|
||||||
|
Quaternion rotation = Quaternion.Euler(0, 0, Random.Range(-0.25f, 0.25f) * RotationMultiplier);
|
||||||
|
|
||||||
|
// Iterate through each character of the line.
|
||||||
|
for (int j = first; j <= last; j++)
|
||||||
|
{
|
||||||
|
// Skip characters that are not visible and thus have no geometry to manipulate.
|
||||||
|
if (!textInfo.characterInfo[j].isVisible)
|
||||||
|
continue;
|
||||||
|
|
||||||
|
// Get the index of the material used by the current character.
|
||||||
|
int materialIndex = textInfo.characterInfo[j].materialReferenceIndex;
|
||||||
|
|
||||||
|
// Get the index of the first vertex used by this text element.
|
||||||
|
int vertexIndex = textInfo.characterInfo[j].vertexIndex;
|
||||||
|
|
||||||
|
// Get the vertices of the mesh used by this text element (character or sprite).
|
||||||
|
Vector3[] sourceVertices = textInfo.meshInfo[materialIndex].vertices;
|
||||||
|
|
||||||
|
// Need to translate all 4 vertices of each quad to aligned with center of character.
|
||||||
|
// This is needed so the matrix TRS is applied at the origin for each character.
|
||||||
|
copyOfVertices[materialIndex][vertexIndex + 0] = sourceVertices[vertexIndex + 0] - centerOfLine;
|
||||||
|
copyOfVertices[materialIndex][vertexIndex + 1] = sourceVertices[vertexIndex + 1] - centerOfLine;
|
||||||
|
copyOfVertices[materialIndex][vertexIndex + 2] = sourceVertices[vertexIndex + 2] - centerOfLine;
|
||||||
|
copyOfVertices[materialIndex][vertexIndex + 3] = sourceVertices[vertexIndex + 3] - centerOfLine;
|
||||||
|
|
||||||
|
// Determine the random scale change for each character.
|
||||||
|
float randomScale = Random.Range(0.995f - 0.001f * ScaleMultiplier, 1.005f + 0.001f * ScaleMultiplier);
|
||||||
|
|
||||||
|
// Setup the matrix rotation.
|
||||||
|
matrix = Matrix4x4.TRS(Vector3.one, rotation, Vector3.one * randomScale);
|
||||||
|
|
||||||
|
// Apply the matrix TRS to the individual characters relative to the center of the current line.
|
||||||
|
copyOfVertices[materialIndex][vertexIndex + 0] = matrix.MultiplyPoint3x4(copyOfVertices[materialIndex][vertexIndex + 0]);
|
||||||
|
copyOfVertices[materialIndex][vertexIndex + 1] = matrix.MultiplyPoint3x4(copyOfVertices[materialIndex][vertexIndex + 1]);
|
||||||
|
copyOfVertices[materialIndex][vertexIndex + 2] = matrix.MultiplyPoint3x4(copyOfVertices[materialIndex][vertexIndex + 2]);
|
||||||
|
copyOfVertices[materialIndex][vertexIndex + 3] = matrix.MultiplyPoint3x4(copyOfVertices[materialIndex][vertexIndex + 3]);
|
||||||
|
|
||||||
|
// Revert the translation change.
|
||||||
|
copyOfVertices[materialIndex][vertexIndex + 0] += centerOfLine;
|
||||||
|
copyOfVertices[materialIndex][vertexIndex + 1] += centerOfLine;
|
||||||
|
copyOfVertices[materialIndex][vertexIndex + 2] += centerOfLine;
|
||||||
|
copyOfVertices[materialIndex][vertexIndex + 3] += centerOfLine;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Push changes into meshes
|
||||||
|
for (int i = 0; i < textInfo.meshInfo.Length; i++)
|
||||||
|
{
|
||||||
|
textInfo.meshInfo[i].mesh.vertices = copyOfVertices[i];
|
||||||
|
m_TextComponent.UpdateGeometry(textInfo.meshInfo[i].mesh, i);
|
||||||
|
}
|
||||||
|
|
||||||
|
yield return new WaitForSeconds(0.1f);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,12 @@
|
||||||
|
fileFormatVersion: 2
|
||||||
|
guid: f7cfa58e417a46ea8889989684c2522e
|
||||||
|
timeCreated: 1462089320
|
||||||
|
licenseType: Pro
|
||||||
|
MonoImporter:
|
||||||
|
serializedVersion: 2
|
||||||
|
defaultReferences: []
|
||||||
|
executionOrder: 0
|
||||||
|
icon: {instanceID: 0}
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
|
@ -0,0 +1,185 @@
|
||||||
|
using UnityEngine;
|
||||||
|
using System.Collections;
|
||||||
|
|
||||||
|
|
||||||
|
namespace TMPro.Examples
|
||||||
|
{
|
||||||
|
|
||||||
|
public class VertexShakeB : MonoBehaviour
|
||||||
|
{
|
||||||
|
|
||||||
|
public float AngleMultiplier = 1.0f;
|
||||||
|
public float SpeedMultiplier = 1.0f;
|
||||||
|
public float CurveScale = 1.0f;
|
||||||
|
|
||||||
|
private TMP_Text m_TextComponent;
|
||||||
|
private bool hasTextChanged;
|
||||||
|
|
||||||
|
|
||||||
|
void Awake()
|
||||||
|
{
|
||||||
|
m_TextComponent = GetComponent<TMP_Text>();
|
||||||
|
}
|
||||||
|
|
||||||
|
void OnEnable()
|
||||||
|
{
|
||||||
|
// Subscribe to event fired when text object has been regenerated.
|
||||||
|
TMPro_EventManager.TEXT_CHANGED_EVENT.Add(ON_TEXT_CHANGED);
|
||||||
|
}
|
||||||
|
|
||||||
|
void OnDisable()
|
||||||
|
{
|
||||||
|
TMPro_EventManager.TEXT_CHANGED_EVENT.Remove(ON_TEXT_CHANGED);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void Start()
|
||||||
|
{
|
||||||
|
StartCoroutine(AnimateVertexColors());
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void ON_TEXT_CHANGED(Object obj)
|
||||||
|
{
|
||||||
|
if (obj = m_TextComponent)
|
||||||
|
hasTextChanged = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Method to animate vertex colors of a TMP Text object.
|
||||||
|
/// </summary>
|
||||||
|
/// <returns></returns>
|
||||||
|
IEnumerator AnimateVertexColors()
|
||||||
|
{
|
||||||
|
|
||||||
|
// We force an update of the text object since it would only be updated at the end of the frame. Ie. before this code is executed on the first frame.
|
||||||
|
// Alternatively, we could yield and wait until the end of the frame when the text object will be generated.
|
||||||
|
m_TextComponent.ForceMeshUpdate();
|
||||||
|
|
||||||
|
TMP_TextInfo textInfo = m_TextComponent.textInfo;
|
||||||
|
|
||||||
|
Matrix4x4 matrix;
|
||||||
|
Vector3[][] copyOfVertices = new Vector3[0][];
|
||||||
|
|
||||||
|
hasTextChanged = true;
|
||||||
|
|
||||||
|
while (true)
|
||||||
|
{
|
||||||
|
// Allocate new vertices
|
||||||
|
if (hasTextChanged)
|
||||||
|
{
|
||||||
|
if (copyOfVertices.Length < textInfo.meshInfo.Length)
|
||||||
|
copyOfVertices = new Vector3[textInfo.meshInfo.Length][];
|
||||||
|
|
||||||
|
for (int i = 0; i < textInfo.meshInfo.Length; i++)
|
||||||
|
{
|
||||||
|
int length = textInfo.meshInfo[i].vertices.Length;
|
||||||
|
copyOfVertices[i] = new Vector3[length];
|
||||||
|
}
|
||||||
|
|
||||||
|
hasTextChanged = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
int characterCount = textInfo.characterCount;
|
||||||
|
|
||||||
|
// If No Characters then just yield and wait for some text to be added
|
||||||
|
if (characterCount == 0)
|
||||||
|
{
|
||||||
|
yield return new WaitForSeconds(0.25f);
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
int lineCount = textInfo.lineCount;
|
||||||
|
|
||||||
|
// Iterate through each line of the text.
|
||||||
|
for (int i = 0; i < lineCount; i++)
|
||||||
|
{
|
||||||
|
|
||||||
|
int first = textInfo.lineInfo[i].firstCharacterIndex;
|
||||||
|
int last = textInfo.lineInfo[i].lastCharacterIndex;
|
||||||
|
|
||||||
|
// Determine the center of each line
|
||||||
|
Vector3 centerOfLine = (textInfo.characterInfo[first].bottomLeft + textInfo.characterInfo[last].topRight) / 2;
|
||||||
|
Quaternion rotation = Quaternion.Euler(0, 0, Random.Range(-0.25f, 0.25f));
|
||||||
|
|
||||||
|
// Iterate through each character of the line.
|
||||||
|
for (int j = first; j <= last; j++)
|
||||||
|
{
|
||||||
|
// Skip characters that are not visible and thus have no geometry to manipulate.
|
||||||
|
if (!textInfo.characterInfo[j].isVisible)
|
||||||
|
continue;
|
||||||
|
|
||||||
|
// Get the index of the material used by the current character.
|
||||||
|
int materialIndex = textInfo.characterInfo[j].materialReferenceIndex;
|
||||||
|
|
||||||
|
// Get the index of the first vertex used by this text element.
|
||||||
|
int vertexIndex = textInfo.characterInfo[j].vertexIndex;
|
||||||
|
|
||||||
|
// Get the vertices of the mesh used by this text element (character or sprite).
|
||||||
|
Vector3[] sourceVertices = textInfo.meshInfo[materialIndex].vertices;
|
||||||
|
|
||||||
|
// Determine the center point of each character at the baseline.
|
||||||
|
Vector3 charCenter = (sourceVertices[vertexIndex + 0] + sourceVertices[vertexIndex + 2]) / 2;
|
||||||
|
|
||||||
|
// Need to translate all 4 vertices of each quad to aligned with center of character.
|
||||||
|
// This is needed so the matrix TRS is applied at the origin for each character.
|
||||||
|
copyOfVertices[materialIndex][vertexIndex + 0] = sourceVertices[vertexIndex + 0] - charCenter;
|
||||||
|
copyOfVertices[materialIndex][vertexIndex + 1] = sourceVertices[vertexIndex + 1] - charCenter;
|
||||||
|
copyOfVertices[materialIndex][vertexIndex + 2] = sourceVertices[vertexIndex + 2] - charCenter;
|
||||||
|
copyOfVertices[materialIndex][vertexIndex + 3] = sourceVertices[vertexIndex + 3] - charCenter;
|
||||||
|
|
||||||
|
// Determine the random scale change for each character.
|
||||||
|
float randomScale = Random.Range(0.95f, 1.05f);
|
||||||
|
|
||||||
|
// Setup the matrix for the scale change.
|
||||||
|
matrix = Matrix4x4.TRS(Vector3.one, Quaternion.identity, Vector3.one * randomScale);
|
||||||
|
|
||||||
|
// Apply the scale change relative to the center of each character.
|
||||||
|
copyOfVertices[materialIndex][vertexIndex + 0] = matrix.MultiplyPoint3x4(copyOfVertices[materialIndex][vertexIndex + 0]);
|
||||||
|
copyOfVertices[materialIndex][vertexIndex + 1] = matrix.MultiplyPoint3x4(copyOfVertices[materialIndex][vertexIndex + 1]);
|
||||||
|
copyOfVertices[materialIndex][vertexIndex + 2] = matrix.MultiplyPoint3x4(copyOfVertices[materialIndex][vertexIndex + 2]);
|
||||||
|
copyOfVertices[materialIndex][vertexIndex + 3] = matrix.MultiplyPoint3x4(copyOfVertices[materialIndex][vertexIndex + 3]);
|
||||||
|
|
||||||
|
// Revert the translation change.
|
||||||
|
copyOfVertices[materialIndex][vertexIndex + 0] += charCenter;
|
||||||
|
copyOfVertices[materialIndex][vertexIndex + 1] += charCenter;
|
||||||
|
copyOfVertices[materialIndex][vertexIndex + 2] += charCenter;
|
||||||
|
copyOfVertices[materialIndex][vertexIndex + 3] += charCenter;
|
||||||
|
|
||||||
|
// Need to translate all 4 vertices of each quad to aligned with the center of the line.
|
||||||
|
// This is needed so the matrix TRS is applied from the center of the line.
|
||||||
|
copyOfVertices[materialIndex][vertexIndex + 0] -= centerOfLine;
|
||||||
|
copyOfVertices[materialIndex][vertexIndex + 1] -= centerOfLine;
|
||||||
|
copyOfVertices[materialIndex][vertexIndex + 2] -= centerOfLine;
|
||||||
|
copyOfVertices[materialIndex][vertexIndex + 3] -= centerOfLine;
|
||||||
|
|
||||||
|
// Setup the matrix rotation.
|
||||||
|
matrix = Matrix4x4.TRS(Vector3.one, rotation, Vector3.one);
|
||||||
|
|
||||||
|
// Apply the matrix TRS to the individual characters relative to the center of the current line.
|
||||||
|
copyOfVertices[materialIndex][vertexIndex + 0] = matrix.MultiplyPoint3x4(copyOfVertices[materialIndex][vertexIndex + 0]);
|
||||||
|
copyOfVertices[materialIndex][vertexIndex + 1] = matrix.MultiplyPoint3x4(copyOfVertices[materialIndex][vertexIndex + 1]);
|
||||||
|
copyOfVertices[materialIndex][vertexIndex + 2] = matrix.MultiplyPoint3x4(copyOfVertices[materialIndex][vertexIndex + 2]);
|
||||||
|
copyOfVertices[materialIndex][vertexIndex + 3] = matrix.MultiplyPoint3x4(copyOfVertices[materialIndex][vertexIndex + 3]);
|
||||||
|
|
||||||
|
// Revert the translation change.
|
||||||
|
copyOfVertices[materialIndex][vertexIndex + 0] += centerOfLine;
|
||||||
|
copyOfVertices[materialIndex][vertexIndex + 1] += centerOfLine;
|
||||||
|
copyOfVertices[materialIndex][vertexIndex + 2] += centerOfLine;
|
||||||
|
copyOfVertices[materialIndex][vertexIndex + 3] += centerOfLine;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Push changes into meshes
|
||||||
|
for (int i = 0; i < textInfo.meshInfo.Length; i++)
|
||||||
|
{
|
||||||
|
textInfo.meshInfo[i].mesh.vertices = copyOfVertices[i];
|
||||||
|
m_TextComponent.UpdateGeometry(textInfo.meshInfo[i].mesh, i);
|
||||||
|
}
|
||||||
|
|
||||||
|
yield return new WaitForSeconds(0.1f);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,12 @@
|
||||||
|
fileFormatVersion: 2
|
||||||
|
guid: e4e0d9ccee5f4950be8979268c9014e0
|
||||||
|
timeCreated: 1462093319
|
||||||
|
licenseType: Pro
|
||||||
|
MonoImporter:
|
||||||
|
serializedVersion: 2
|
||||||
|
defaultReferences: []
|
||||||
|
executionOrder: 0
|
||||||
|
icon: {instanceID: 0}
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
|
@ -0,0 +1,192 @@
|
||||||
|
using UnityEngine;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Collections;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
|
||||||
|
|
||||||
|
namespace TMPro.Examples
|
||||||
|
{
|
||||||
|
|
||||||
|
public class VertexZoom : MonoBehaviour
|
||||||
|
{
|
||||||
|
public float AngleMultiplier = 1.0f;
|
||||||
|
public float SpeedMultiplier = 1.0f;
|
||||||
|
public float CurveScale = 1.0f;
|
||||||
|
|
||||||
|
private TMP_Text m_TextComponent;
|
||||||
|
private bool hasTextChanged;
|
||||||
|
|
||||||
|
|
||||||
|
void Awake()
|
||||||
|
{
|
||||||
|
m_TextComponent = GetComponent<TMP_Text>();
|
||||||
|
}
|
||||||
|
|
||||||
|
void OnEnable()
|
||||||
|
{
|
||||||
|
// Subscribe to event fired when text object has been regenerated.
|
||||||
|
TMPro_EventManager.TEXT_CHANGED_EVENT.Add(ON_TEXT_CHANGED);
|
||||||
|
}
|
||||||
|
|
||||||
|
void OnDisable()
|
||||||
|
{
|
||||||
|
// UnSubscribe to event fired when text object has been regenerated.
|
||||||
|
TMPro_EventManager.TEXT_CHANGED_EVENT.Remove(ON_TEXT_CHANGED);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void Start()
|
||||||
|
{
|
||||||
|
StartCoroutine(AnimateVertexColors());
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void ON_TEXT_CHANGED(Object obj)
|
||||||
|
{
|
||||||
|
if (obj == m_TextComponent)
|
||||||
|
hasTextChanged = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Method to animate vertex colors of a TMP Text object.
|
||||||
|
/// </summary>
|
||||||
|
/// <returns></returns>
|
||||||
|
IEnumerator AnimateVertexColors()
|
||||||
|
{
|
||||||
|
|
||||||
|
// We force an update of the text object since it would only be updated at the end of the frame. Ie. before this code is executed on the first frame.
|
||||||
|
// Alternatively, we could yield and wait until the end of the frame when the text object will be generated.
|
||||||
|
m_TextComponent.ForceMeshUpdate();
|
||||||
|
|
||||||
|
TMP_TextInfo textInfo = m_TextComponent.textInfo;
|
||||||
|
|
||||||
|
Matrix4x4 matrix;
|
||||||
|
TMP_MeshInfo[] cachedMeshInfoVertexData = textInfo.CopyMeshInfoVertexData();
|
||||||
|
|
||||||
|
// Allocations for sorting of the modified scales
|
||||||
|
List<float> modifiedCharScale = new List<float>();
|
||||||
|
List<int> scaleSortingOrder = new List<int>();
|
||||||
|
|
||||||
|
hasTextChanged = true;
|
||||||
|
|
||||||
|
while (true)
|
||||||
|
{
|
||||||
|
// Allocate new vertices
|
||||||
|
if (hasTextChanged)
|
||||||
|
{
|
||||||
|
// Get updated vertex data
|
||||||
|
cachedMeshInfoVertexData = textInfo.CopyMeshInfoVertexData();
|
||||||
|
|
||||||
|
hasTextChanged = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
int characterCount = textInfo.characterCount;
|
||||||
|
|
||||||
|
// If No Characters then just yield and wait for some text to be added
|
||||||
|
if (characterCount == 0)
|
||||||
|
{
|
||||||
|
yield return new WaitForSeconds(0.25f);
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Clear list of character scales
|
||||||
|
modifiedCharScale.Clear();
|
||||||
|
scaleSortingOrder.Clear();
|
||||||
|
|
||||||
|
for (int i = 0; i < characterCount; i++)
|
||||||
|
{
|
||||||
|
TMP_CharacterInfo charInfo = textInfo.characterInfo[i];
|
||||||
|
|
||||||
|
// Skip characters that are not visible and thus have no geometry to manipulate.
|
||||||
|
if (!charInfo.isVisible)
|
||||||
|
continue;
|
||||||
|
|
||||||
|
// Get the index of the material used by the current character.
|
||||||
|
int materialIndex = textInfo.characterInfo[i].materialReferenceIndex;
|
||||||
|
|
||||||
|
// Get the index of the first vertex used by this text element.
|
||||||
|
int vertexIndex = textInfo.characterInfo[i].vertexIndex;
|
||||||
|
|
||||||
|
// Get the cached vertices of the mesh used by this text element (character or sprite).
|
||||||
|
Vector3[] sourceVertices = cachedMeshInfoVertexData[materialIndex].vertices;
|
||||||
|
|
||||||
|
// Determine the center point of each character at the baseline.
|
||||||
|
//Vector2 charMidBasline = new Vector2((sourceVertices[vertexIndex + 0].x + sourceVertices[vertexIndex + 2].x) / 2, charInfo.baseLine);
|
||||||
|
// Determine the center point of each character.
|
||||||
|
Vector2 charMidBasline = (sourceVertices[vertexIndex + 0] + sourceVertices[vertexIndex + 2]) / 2;
|
||||||
|
|
||||||
|
// Need to translate all 4 vertices of each quad to aligned with middle of character / baseline.
|
||||||
|
// This is needed so the matrix TRS is applied at the origin for each character.
|
||||||
|
Vector3 offset = charMidBasline;
|
||||||
|
|
||||||
|
Vector3[] destinationVertices = textInfo.meshInfo[materialIndex].vertices;
|
||||||
|
|
||||||
|
destinationVertices[vertexIndex + 0] = sourceVertices[vertexIndex + 0] - offset;
|
||||||
|
destinationVertices[vertexIndex + 1] = sourceVertices[vertexIndex + 1] - offset;
|
||||||
|
destinationVertices[vertexIndex + 2] = sourceVertices[vertexIndex + 2] - offset;
|
||||||
|
destinationVertices[vertexIndex + 3] = sourceVertices[vertexIndex + 3] - offset;
|
||||||
|
|
||||||
|
//Vector3 jitterOffset = new Vector3(Random.Range(-.25f, .25f), Random.Range(-.25f, .25f), 0);
|
||||||
|
|
||||||
|
// Determine the random scale change for each character.
|
||||||
|
float randomScale = Random.Range(1f, 1.5f);
|
||||||
|
|
||||||
|
// Add modified scale and index
|
||||||
|
modifiedCharScale.Add(randomScale);
|
||||||
|
scaleSortingOrder.Add(modifiedCharScale.Count - 1);
|
||||||
|
|
||||||
|
// Setup the matrix for the scale change.
|
||||||
|
//matrix = Matrix4x4.TRS(jitterOffset, Quaternion.Euler(0, 0, Random.Range(-5f, 5f)), Vector3.one * randomScale);
|
||||||
|
matrix = Matrix4x4.TRS(new Vector3(0, 0, 0), Quaternion.identity, Vector3.one * randomScale);
|
||||||
|
|
||||||
|
destinationVertices[vertexIndex + 0] = matrix.MultiplyPoint3x4(destinationVertices[vertexIndex + 0]);
|
||||||
|
destinationVertices[vertexIndex + 1] = matrix.MultiplyPoint3x4(destinationVertices[vertexIndex + 1]);
|
||||||
|
destinationVertices[vertexIndex + 2] = matrix.MultiplyPoint3x4(destinationVertices[vertexIndex + 2]);
|
||||||
|
destinationVertices[vertexIndex + 3] = matrix.MultiplyPoint3x4(destinationVertices[vertexIndex + 3]);
|
||||||
|
|
||||||
|
destinationVertices[vertexIndex + 0] += offset;
|
||||||
|
destinationVertices[vertexIndex + 1] += offset;
|
||||||
|
destinationVertices[vertexIndex + 2] += offset;
|
||||||
|
destinationVertices[vertexIndex + 3] += offset;
|
||||||
|
|
||||||
|
// Restore Source UVS which have been modified by the sorting
|
||||||
|
Vector2[] sourceUVs0 = cachedMeshInfoVertexData[materialIndex].uvs0;
|
||||||
|
Vector2[] destinationUVs0 = textInfo.meshInfo[materialIndex].uvs0;
|
||||||
|
|
||||||
|
destinationUVs0[vertexIndex + 0] = sourceUVs0[vertexIndex + 0];
|
||||||
|
destinationUVs0[vertexIndex + 1] = sourceUVs0[vertexIndex + 1];
|
||||||
|
destinationUVs0[vertexIndex + 2] = sourceUVs0[vertexIndex + 2];
|
||||||
|
destinationUVs0[vertexIndex + 3] = sourceUVs0[vertexIndex + 3];
|
||||||
|
|
||||||
|
// Restore Source Vertex Colors
|
||||||
|
Color32[] sourceColors32 = cachedMeshInfoVertexData[materialIndex].colors32;
|
||||||
|
Color32[] destinationColors32 = textInfo.meshInfo[materialIndex].colors32;
|
||||||
|
|
||||||
|
destinationColors32[vertexIndex + 0] = sourceColors32[vertexIndex + 0];
|
||||||
|
destinationColors32[vertexIndex + 1] = sourceColors32[vertexIndex + 1];
|
||||||
|
destinationColors32[vertexIndex + 2] = sourceColors32[vertexIndex + 2];
|
||||||
|
destinationColors32[vertexIndex + 3] = sourceColors32[vertexIndex + 3];
|
||||||
|
}
|
||||||
|
|
||||||
|
// Push changes into meshes
|
||||||
|
for (int i = 0; i < textInfo.meshInfo.Length; i++)
|
||||||
|
{
|
||||||
|
//// Sort Quads based modified scale
|
||||||
|
scaleSortingOrder.Sort((a, b) => modifiedCharScale[a].CompareTo(modifiedCharScale[b]));
|
||||||
|
|
||||||
|
textInfo.meshInfo[i].SortGeometry(scaleSortingOrder);
|
||||||
|
|
||||||
|
// Updated modified vertex attributes
|
||||||
|
textInfo.meshInfo[i].mesh.vertices = textInfo.meshInfo[i].vertices;
|
||||||
|
textInfo.meshInfo[i].mesh.uv = textInfo.meshInfo[i].uvs0;
|
||||||
|
textInfo.meshInfo[i].mesh.colors32 = textInfo.meshInfo[i].colors32;
|
||||||
|
|
||||||
|
m_TextComponent.UpdateGeometry(textInfo.meshInfo[i].mesh, i);
|
||||||
|
}
|
||||||
|
|
||||||
|
yield return new WaitForSeconds(0.1f);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,12 @@
|
||||||
|
fileFormatVersion: 2
|
||||||
|
guid: 52ec835d14bd486f900952b77698b7eb
|
||||||
|
timeCreated: 1466280202
|
||||||
|
licenseType: Pro
|
||||||
|
MonoImporter:
|
||||||
|
serializedVersion: 2
|
||||||
|
defaultReferences: []
|
||||||
|
executionOrder: 0
|
||||||
|
icon: {instanceID: 0}
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
|
@ -107,7 +107,8 @@ SubShader {
|
||||||
Lighting Off
|
Lighting Off
|
||||||
Fog { Mode Off }
|
Fog { Mode Off }
|
||||||
ZTest Always
|
ZTest Always
|
||||||
Blend One OneMinusSrcAlpha
|
Blend OneMinusDstColor OneMinusSrcAlpha
|
||||||
|
|
||||||
ColorMask [_ColorMask]
|
ColorMask [_ColorMask]
|
||||||
|
|
||||||
Pass {
|
Pass {
|
||||||
|
|
|
@ -65,7 +65,7 @@ MonoBehaviour:
|
||||||
m_PostInfinity: 2
|
m_PostInfinity: 2
|
||||||
m_RotationOrder: 4
|
m_RotationOrder: 4
|
||||||
m_ConstantMin: 20
|
m_ConstantMin: 20
|
||||||
m_ConstantMax: 30
|
m_ConstantMax: 60
|
||||||
bulletLifetime:
|
bulletLifetime:
|
||||||
m_Mode: 0
|
m_Mode: 0
|
||||||
m_CurveMultiplier: 0
|
m_CurveMultiplier: 0
|
||||||
|
|
Loading…
Reference in New Issue