Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
sdk-public
unity_sdk_demo
Commits
0f3088bc
Commit
0f3088bc
authored
Oct 11, 2025
by
gaorui
Browse files
Initial commit
parents
Changes
279
Hide whitespace changes
Inline
Side-by-side
Too many changes to show.
To preserve performance only
20 of 279+
files are displayed.
Plain diff
Email patch
Assets/TextMesh Pro/Examples & Extras/Scripts/DropdownSample.cs.meta
0 → 100755
View file @
0f3088bc
fileFormatVersion: 2
guid: ac1eb05af6d391b4eb0f4c070a99f1d0
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
Assets/TextMesh Pro/Examples & Extras/Scripts/EnvMapAnimator.cs
0 → 100755
View file @
0f3088bc
using
UnityEngine
;
using
System.Collections
;
using
TMPro
;
public
class
EnvMapAnimator
:
MonoBehaviour
{
//private Vector3 TranslationSpeeds;
public
Vector3
RotationSpeeds
;
private
TMP_Text
m_textMeshPro
;
private
Material
m_material
;
void
Awake
()
{
//Debug.Log("Awake() on Script called.");
m_textMeshPro
=
GetComponent
<
TMP_Text
>();
m_material
=
m_textMeshPro
.
fontSharedMaterial
;
}
// Use this for initialization
IEnumerator
Start
()
{
Matrix4x4
matrix
=
new
Matrix4x4
();
while
(
true
)
{
//matrix.SetTRS(new Vector3 (Time.time * TranslationSpeeds.x, Time.time * TranslationSpeeds.y, Time.time * TranslationSpeeds.z), Quaternion.Euler(Time.time * RotationSpeeds.x, Time.time * RotationSpeeds.y , Time.time * RotationSpeeds.z), Vector3.one);
matrix
.
SetTRS
(
Vector3
.
zero
,
Quaternion
.
Euler
(
Time
.
time
*
RotationSpeeds
.
x
,
Time
.
time
*
RotationSpeeds
.
y
,
Time
.
time
*
RotationSpeeds
.
z
),
Vector3
.
one
);
m_material
.
SetMatrix
(
"_EnvMatrix"
,
matrix
);
yield
return
null
;
}
}
}
Assets/TextMesh Pro/Examples & Extras/Scripts/EnvMapAnimator.cs.meta
0 → 100755
View file @
0f3088bc
fileFormatVersion: 2
guid: a4b6f99e8bc54541bbd149b014ff441c
timeCreated: 1449025325
licenseType: Pro
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
Assets/TextMesh Pro/Examples & Extras/Scripts/ObjectSpin.cs
0 → 100755
View file @
0f3088bc
using
UnityEngine
;
using
System.Collections
;
namespace
TMPro.Examples
{
public
class
ObjectSpin
:
MonoBehaviour
{
#pragma warning disable 0414
public
float
SpinSpeed
=
5
;
public
int
RotationRange
=
15
;
private
Transform
m_transform
;
private
float
m_time
;
private
Vector3
m_prevPOS
;
private
Vector3
m_initial_Rotation
;
private
Vector3
m_initial_Position
;
private
Color32
m_lightColor
;
private
int
frames
=
0
;
public
enum
MotionType
{
Rotation
,
BackAndForth
,
Translation
};
public
MotionType
Motion
;
void
Awake
()
{
m_transform
=
transform
;
m_initial_Rotation
=
m_transform
.
rotation
.
eulerAngles
;
m_initial_Position
=
m_transform
.
position
;
Light
light
=
GetComponent
<
Light
>();
m_lightColor
=
light
!=
null
?
light
.
color
:
Color
.
black
;
}
// Update is called once per frame
void
Update
()
{
if
(
Motion
==
MotionType
.
Rotation
)
{
m_transform
.
Rotate
(
0
,
SpinSpeed
*
Time
.
deltaTime
,
0
);
}
else
if
(
Motion
==
MotionType
.
BackAndForth
)
{
m_time
+=
SpinSpeed
*
Time
.
deltaTime
;
m_transform
.
rotation
=
Quaternion
.
Euler
(
m_initial_Rotation
.
x
,
Mathf
.
Sin
(
m_time
)
*
RotationRange
+
m_initial_Rotation
.
y
,
m_initial_Rotation
.
z
);
}
else
{
m_time
+=
SpinSpeed
*
Time
.
deltaTime
;
float
x
=
15
*
Mathf
.
Cos
(
m_time
*
.
95f
);
float
y
=
10
;
// *Mathf.Sin(m_time * 1f) * Mathf.Cos(m_time * 1f);
float
z
=
0f
;
// *Mathf.Sin(m_time * .9f);
m_transform
.
position
=
m_initial_Position
+
new
Vector3
(
x
,
z
,
y
);
// Drawing light patterns because they can be cool looking.
//if (frames > 2)
// Debug.DrawLine(m_transform.position, m_prevPOS, m_lightColor, 100f);
m_prevPOS
=
m_transform
.
position
;
frames
+=
1
;
}
}
}
}
\ No newline at end of file
Assets/TextMesh Pro/Examples & Extras/Scripts/ObjectSpin.cs.meta
0 → 100755
View file @
0f3088bc
fileFormatVersion: 2
guid: 4f19c7f94c794c5097d8bd11e39c750d
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
Assets/TextMesh Pro/Examples & Extras/Scripts/ShaderPropAnimator.cs
0 → 100755
View file @
0f3088bc
using
UnityEngine
;
using
System.Collections
;
namespace
TMPro.Examples
{
public
class
ShaderPropAnimator
:
MonoBehaviour
{
private
Renderer
m_Renderer
;
private
Material
m_Material
;
public
AnimationCurve
GlowCurve
;
public
float
m_frame
;
void
Awake
()
{
// Cache a reference to object's renderer
m_Renderer
=
GetComponent
<
Renderer
>();
// Cache a reference to object's material and create an instance by doing so.
m_Material
=
m_Renderer
.
material
;
}
void
Start
()
{
StartCoroutine
(
AnimateProperties
());
}
IEnumerator
AnimateProperties
()
{
//float lightAngle;
float
glowPower
;
m_frame
=
Random
.
Range
(
0f
,
1f
);
while
(
true
)
{
//lightAngle = (m_Material.GetFloat(ShaderPropertyIDs.ID_LightAngle) + Time.deltaTime) % 6.2831853f;
//m_Material.SetFloat(ShaderPropertyIDs.ID_LightAngle, lightAngle);
glowPower
=
GlowCurve
.
Evaluate
(
m_frame
);
m_Material
.
SetFloat
(
ShaderUtilities
.
ID_GlowPower
,
glowPower
);
m_frame
+=
Time
.
deltaTime
*
Random
.
Range
(
0.2f
,
0.3f
);
yield
return
new
WaitForEndOfFrame
();
}
}
}
}
Assets/TextMesh Pro/Examples & Extras/Scripts/ShaderPropAnimator.cs.meta
0 → 100755
View file @
0f3088bc
fileFormatVersion: 2
guid: 2787a46a4dc848c1b4b7b9307b614bfd
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
Assets/TextMesh Pro/Examples & Extras/Scripts/SimpleScript.cs
0 → 100755
View file @
0f3088bc
using
UnityEngine
;
using
System.Collections
;
namespace
TMPro.Examples
{
public
class
SimpleScript
:
MonoBehaviour
{
private
TextMeshPro
m_textMeshPro
;
//private TMP_FontAsset m_FontAsset;
private
const
string
label
=
"The <#0050FF>count is: </color>{0:2}"
;
private
float
m_frame
;
void
Start
()
{
// Add new TextMesh Pro Component
m_textMeshPro
=
gameObject
.
AddComponent
<
TextMeshPro
>();
m_textMeshPro
.
autoSizeTextContainer
=
true
;
// Load the Font Asset to be used.
//m_FontAsset = Resources.Load("Fonts & Materials/LiberationSans SDF", typeof(TMP_FontAsset)) as TMP_FontAsset;
//m_textMeshPro.font = m_FontAsset;
// Assign Material to TextMesh Pro Component
//m_textMeshPro.fontSharedMaterial = Resources.Load("Fonts & Materials/LiberationSans SDF - Bevel", typeof(Material)) as Material;
//m_textMeshPro.fontSharedMaterial.EnableKeyword("BEVEL_ON");
// Set various font settings.
m_textMeshPro
.
fontSize
=
48
;
m_textMeshPro
.
alignment
=
TextAlignmentOptions
.
Center
;
//m_textMeshPro.anchorDampening = true; // Has been deprecated but under consideration for re-implementation.
//m_textMeshPro.enableAutoSizing = true;
//m_textMeshPro.characterSpacing = 0.2f;
//m_textMeshPro.wordSpacing = 0.1f;
//m_textMeshPro.enableCulling = true;
m_textMeshPro
.
enableWordWrapping
=
false
;
//textMeshPro.fontColor = new Color32(255, 255, 255, 255);
}
void
Update
()
{
m_textMeshPro
.
SetText
(
label
,
m_frame
%
1000
);
m_frame
+=
1
*
Time
.
deltaTime
;
}
}
}
Assets/TextMesh Pro/Examples & Extras/Scripts/SimpleScript.cs.meta
0 → 100755
View file @
0f3088bc
fileFormatVersion: 2
guid: 9eff140b25d64601aabc6ba32245d099
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
Assets/TextMesh Pro/Examples & Extras/Scripts/SkewTextExample.cs
0 → 100755
View file @
0f3088bc
using
UnityEngine
;
using
System.Collections
;
namespace
TMPro.Examples
{
public
class
SkewTextExample
:
MonoBehaviour
{
private
TMP_Text
m_TextComponent
;
public
AnimationCurve
VertexCurve
=
new
AnimationCurve
(
new
Keyframe
(
0
,
0
),
new
Keyframe
(
0.25f
,
2.0f
),
new
Keyframe
(
0.5f
,
0
),
new
Keyframe
(
0.75f
,
2.0f
),
new
Keyframe
(
1
,
0f
));
//public float AngleMultiplier = 1.0f;
//public float SpeedMultiplier = 1.0f;
public
float
CurveScale
=
1.0f
;
public
float
ShearAmount
=
1.0f
;
void
Awake
()
{
m_TextComponent
=
gameObject
.
GetComponent
<
TMP_Text
>();
}
void
Start
()
{
StartCoroutine
(
WarpText
());
}
private
AnimationCurve
CopyAnimationCurve
(
AnimationCurve
curve
)
{
AnimationCurve
newCurve
=
new
AnimationCurve
();
newCurve
.
keys
=
curve
.
keys
;
return
newCurve
;
}
/// <summary>
/// Method to curve text along a Unity animation curve.
/// </summary>
/// <param name="textComponent"></param>
/// <returns></returns>
IEnumerator
WarpText
()
{
VertexCurve
.
preWrapMode
=
WrapMode
.
Clamp
;
VertexCurve
.
postWrapMode
=
WrapMode
.
Clamp
;
//Mesh mesh = m_TextComponent.textInfo.meshInfo[0].mesh;
Vector3
[]
vertices
;
Matrix4x4
matrix
;
m_TextComponent
.
havePropertiesChanged
=
true
;
// Need to force the TextMeshPro Object to be updated.
CurveScale
*=
10
;
float
old_CurveScale
=
CurveScale
;
float
old_ShearValue
=
ShearAmount
;
AnimationCurve
old_curve
=
CopyAnimationCurve
(
VertexCurve
);
while
(
true
)
{
if
(!
m_TextComponent
.
havePropertiesChanged
&&
old_CurveScale
==
CurveScale
&&
old_curve
.
keys
[
1
].
value
==
VertexCurve
.
keys
[
1
].
value
&&
old_ShearValue
==
ShearAmount
)
{
yield
return
null
;
continue
;
}
old_CurveScale
=
CurveScale
;
old_curve
=
CopyAnimationCurve
(
VertexCurve
);
old_ShearValue
=
ShearAmount
;
m_TextComponent
.
ForceMeshUpdate
();
// Generate the mesh and populate the textInfo with data we can use and manipulate.
TMP_TextInfo
textInfo
=
m_TextComponent
.
textInfo
;
int
characterCount
=
textInfo
.
characterCount
;
if
(
characterCount
==
0
)
continue
;
//vertices = textInfo.meshInfo[0].vertices;
//int lastVertexIndex = textInfo.characterInfo[characterCount - 1].vertexIndex;
float
boundsMinX
=
m_TextComponent
.
bounds
.
min
.
x
;
//textInfo.meshInfo[0].mesh.bounds.min.x;
float
boundsMaxX
=
m_TextComponent
.
bounds
.
max
.
x
;
//textInfo.meshInfo[0].mesh.bounds.max.x;
for
(
int
i
=
0
;
i
<
characterCount
;
i
++)
{
if
(!
textInfo
.
characterInfo
[
i
].
isVisible
)
continue
;
int
vertexIndex
=
textInfo
.
characterInfo
[
i
].
vertexIndex
;
// Get the index of the mesh used by this character.
int
materialIndex
=
textInfo
.
characterInfo
[
i
].
materialReferenceIndex
;
vertices
=
textInfo
.
meshInfo
[
materialIndex
].
vertices
;
// Compute the baseline mid point for each character
Vector3
offsetToMidBaseline
=
new
Vector2
((
vertices
[
vertexIndex
+
0
].
x
+
vertices
[
vertexIndex
+
2
].
x
)
/
2
,
textInfo
.
characterInfo
[
i
].
baseLine
);
//float offsetY = VertexCurve.Evaluate((float)i / characterCount + loopCount / 50f); // Random.Range(-0.25f, 0.25f);
// Apply offset to adjust our pivot point.
vertices
[
vertexIndex
+
0
]
+=
-
offsetToMidBaseline
;
vertices
[
vertexIndex
+
1
]
+=
-
offsetToMidBaseline
;
vertices
[
vertexIndex
+
2
]
+=
-
offsetToMidBaseline
;
vertices
[
vertexIndex
+
3
]
+=
-
offsetToMidBaseline
;
// Apply the Shearing FX
float
shear_value
=
ShearAmount
*
0.01f
;
Vector3
topShear
=
new
Vector3
(
shear_value
*
(
textInfo
.
characterInfo
[
i
].
topRight
.
y
-
textInfo
.
characterInfo
[
i
].
baseLine
),
0
,
0
);
Vector3
bottomShear
=
new
Vector3
(
shear_value
*
(
textInfo
.
characterInfo
[
i
].
baseLine
-
textInfo
.
characterInfo
[
i
].
bottomRight
.
y
),
0
,
0
);
vertices
[
vertexIndex
+
0
]
+=
-
bottomShear
;
vertices
[
vertexIndex
+
1
]
+=
topShear
;
vertices
[
vertexIndex
+
2
]
+=
topShear
;
vertices
[
vertexIndex
+
3
]
+=
-
bottomShear
;
// Compute the angle of rotation for each character based on the animation curve
float
x0
=
(
offsetToMidBaseline
.
x
-
boundsMinX
)
/
(
boundsMaxX
-
boundsMinX
);
// Character's position relative to the bounds of the mesh.
float
x1
=
x0
+
0.0001f
;
float
y0
=
VertexCurve
.
Evaluate
(
x0
)
*
CurveScale
;
float
y1
=
VertexCurve
.
Evaluate
(
x1
)
*
CurveScale
;
Vector3
horizontal
=
new
Vector3
(
1
,
0
,
0
);
//Vector3 normal = new Vector3(-(y1 - y0), (x1 * (boundsMaxX - boundsMinX) + boundsMinX) - offsetToMidBaseline.x, 0);
Vector3
tangent
=
new
Vector3
(
x1
*
(
boundsMaxX
-
boundsMinX
)
+
boundsMinX
,
y1
)
-
new
Vector3
(
offsetToMidBaseline
.
x
,
y0
);
float
dot
=
Mathf
.
Acos
(
Vector3
.
Dot
(
horizontal
,
tangent
.
normalized
))
*
57.2957795f
;
Vector3
cross
=
Vector3
.
Cross
(
horizontal
,
tangent
);
float
angle
=
cross
.
z
>
0
?
dot
:
360
-
dot
;
matrix
=
Matrix4x4
.
TRS
(
new
Vector3
(
0
,
y0
,
0
),
Quaternion
.
Euler
(
0
,
0
,
angle
),
Vector3
.
one
);
vertices
[
vertexIndex
+
0
]
=
matrix
.
MultiplyPoint3x4
(
vertices
[
vertexIndex
+
0
]);
vertices
[
vertexIndex
+
1
]
=
matrix
.
MultiplyPoint3x4
(
vertices
[
vertexIndex
+
1
]);
vertices
[
vertexIndex
+
2
]
=
matrix
.
MultiplyPoint3x4
(
vertices
[
vertexIndex
+
2
]);
vertices
[
vertexIndex
+
3
]
=
matrix
.
MultiplyPoint3x4
(
vertices
[
vertexIndex
+
3
]);
vertices
[
vertexIndex
+
0
]
+=
offsetToMidBaseline
;
vertices
[
vertexIndex
+
1
]
+=
offsetToMidBaseline
;
vertices
[
vertexIndex
+
2
]
+=
offsetToMidBaseline
;
vertices
[
vertexIndex
+
3
]
+=
offsetToMidBaseline
;
}
// Upload the mesh with the revised information
m_TextComponent
.
UpdateVertexData
();
yield
return
null
;
// new WaitForSeconds(0.025f);
}
}
}
}
Assets/TextMesh Pro/Examples & Extras/Scripts/SkewTextExample.cs.meta
0 → 100755
View file @
0f3088bc
fileFormatVersion: 2
guid: d412675cfb3441efa3bf8dcd9b7624dc
timeCreated: 1458801336
licenseType: Pro
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
Assets/TextMesh Pro/Examples & Extras/Scripts/TMP_DigitValidator.cs
0 → 100755
View file @
0f3088bc
using
UnityEngine
;
using
System
;
namespace
TMPro
{
/// <summary>
/// EXample of a Custom Character Input Validator to only allow digits from 0 to 9.
/// </summary>
[
Serializable
]
//[CreateAssetMenu(fileName = "InputValidator - Digits.asset", menuName = "TextMeshPro/Input Validators/Digits", order = 100)]
public
class
TMP_DigitValidator
:
TMP_InputValidator
{
// Custom text input validation function
public
override
char
Validate
(
ref
string
text
,
ref
int
pos
,
char
ch
)
{
if
(
ch
>=
'0'
&&
ch
<=
'9'
)
{
text
+=
ch
;
pos
+=
1
;
return
ch
;
}
return
(
char
)
0
;
}
}
}
Assets/TextMesh Pro/Examples & Extras/Scripts/TMP_DigitValidator.cs.meta
0 → 100755
View file @
0f3088bc
fileFormatVersion: 2
guid: 1a7eb92a01ed499a987bde9def05fbce
timeCreated: 1473112765
licenseType: Pro
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
Assets/TextMesh Pro/Examples & Extras/Scripts/TMP_ExampleScript_01.cs
0 → 100755
View file @
0f3088bc
using
UnityEngine
;
using
UnityEngine.UI
;
using
System.Collections
;
using
TMPro
;
namespace
TMPro.Examples
{
public
class
TMP_ExampleScript_01
:
MonoBehaviour
{
public
enum
objectType
{
TextMeshPro
=
0
,
TextMeshProUGUI
=
1
};
public
objectType
ObjectType
;
public
bool
isStatic
;
private
TMP_Text
m_text
;
//private TMP_InputField m_inputfield;
private
const
string
k_label
=
"The count is <#0080ff>{0}</color>"
;
private
int
count
;
void
Awake
()
{
// Get a reference to the TMP text component if one already exists otherwise add one.
// This example show the convenience of having both TMP components derive from TMP_Text.
if
(
ObjectType
==
0
)
m_text
=
GetComponent
<
TextMeshPro
>()
??
gameObject
.
AddComponent
<
TextMeshPro
>();
else
m_text
=
GetComponent
<
TextMeshProUGUI
>()
??
gameObject
.
AddComponent
<
TextMeshProUGUI
>();
// Load a new font asset and assign it to the text object.
m_text
.
font
=
Resources
.
Load
<
TMP_FontAsset
>(
"Fonts & Materials/Anton SDF"
);
// Load a new material preset which was created with the context menu duplicate.
m_text
.
fontSharedMaterial
=
Resources
.
Load
<
Material
>(
"Fonts & Materials/Anton SDF - Drop Shadow"
);
// Set the size of the font.
m_text
.
fontSize
=
120
;
// Set the text
m_text
.
text
=
"A <#0080ff>simple</color> line of text."
;
// Get the preferred width and height based on the supplied width and height as opposed to the actual size of the current text container.
Vector2
size
=
m_text
.
GetPreferredValues
(
Mathf
.
Infinity
,
Mathf
.
Infinity
);
// Set the size of the RectTransform based on the new calculated values.
m_text
.
rectTransform
.
sizeDelta
=
new
Vector2
(
size
.
x
,
size
.
y
);
}
void
Update
()
{
if
(!
isStatic
)
{
m_text
.
SetText
(
k_label
,
count
%
1000
);
count
+=
1
;
}
}
}
}
Assets/TextMesh Pro/Examples & Extras/Scripts/TMP_ExampleScript_01.cs.meta
0 → 100755
View file @
0f3088bc
fileFormatVersion: 2
guid: 6f2c5b59b6874405865e2616e4ec276a
timeCreated: 1449625634
licenseType: Pro
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
Assets/TextMesh Pro/Examples & Extras/Scripts/TMP_FrameRateCounter.cs
0 → 100755
View file @
0f3088bc
using
UnityEngine
;
using
System.Collections
;
namespace
TMPro.Examples
{
public
class
TMP_FrameRateCounter
:
MonoBehaviour
{
public
float
UpdateInterval
=
5.0f
;
private
float
m_LastInterval
=
0
;
private
int
m_Frames
=
0
;
public
enum
FpsCounterAnchorPositions
{
TopLeft
,
BottomLeft
,
TopRight
,
BottomRight
};
public
FpsCounterAnchorPositions
AnchorPosition
=
FpsCounterAnchorPositions
.
TopRight
;
private
string
htmlColorTag
;
private
const
string
fpsLabel
=
"{0:2}</color> <#8080ff>FPS \n<#FF8000>{1:2} <#8080ff>MS"
;
private
TextMeshPro
m_TextMeshPro
;
private
Transform
m_frameCounter_transform
;
private
Camera
m_camera
;
private
FpsCounterAnchorPositions
last_AnchorPosition
;
void
Awake
()
{
if
(!
enabled
)
return
;
m_camera
=
Camera
.
main
;
Application
.
targetFrameRate
=
9999
;
GameObject
frameCounter
=
new
GameObject
(
"Frame Counter"
);
m_TextMeshPro
=
frameCounter
.
AddComponent
<
TextMeshPro
>();
m_TextMeshPro
.
font
=
Resources
.
Load
<
TMP_FontAsset
>(
"Fonts & Materials/LiberationSans SDF"
);
m_TextMeshPro
.
fontSharedMaterial
=
Resources
.
Load
<
Material
>(
"Fonts & Materials/LiberationSans SDF - Overlay"
);
m_frameCounter_transform
=
frameCounter
.
transform
;
m_frameCounter_transform
.
SetParent
(
m_camera
.
transform
);
m_frameCounter_transform
.
localRotation
=
Quaternion
.
identity
;
m_TextMeshPro
.
enableWordWrapping
=
false
;
m_TextMeshPro
.
fontSize
=
24
;
//m_TextMeshPro.FontColor = new Color32(255, 255, 255, 128);
//m_TextMeshPro.edgeWidth = .15f;
//m_TextMeshPro.isOverlay = true;
//m_TextMeshPro.FaceColor = new Color32(255, 128, 0, 0);
//m_TextMeshPro.EdgeColor = new Color32(0, 255, 0, 255);
//m_TextMeshPro.FontMaterial.renderQueue = 4000;
//m_TextMeshPro.CreateSoftShadowClone(new Vector2(1f, -1f));
Set_FrameCounter_Position
(
AnchorPosition
);
last_AnchorPosition
=
AnchorPosition
;
}
void
Start
()
{
m_LastInterval
=
Time
.
realtimeSinceStartup
;
m_Frames
=
0
;
}
void
Update
()
{
if
(
AnchorPosition
!=
last_AnchorPosition
)
Set_FrameCounter_Position
(
AnchorPosition
);
last_AnchorPosition
=
AnchorPosition
;
m_Frames
+=
1
;
float
timeNow
=
Time
.
realtimeSinceStartup
;
if
(
timeNow
>
m_LastInterval
+
UpdateInterval
)
{
// display two fractional digits (f2 format)
float
fps
=
m_Frames
/
(
timeNow
-
m_LastInterval
);
float
ms
=
1000.0f
/
Mathf
.
Max
(
fps
,
0.00001f
);
if
(
fps
<
30
)
htmlColorTag
=
"<color=yellow>"
;
else
if
(
fps
<
10
)
htmlColorTag
=
"<color=red>"
;
else
htmlColorTag
=
"<color=green>"
;
//string format = System.String.Format(htmlColorTag + "{0:F2} </color>FPS \n{1:F2} <#8080ff>MS",fps, ms);
//m_TextMeshPro.text = format;
m_TextMeshPro
.
SetText
(
htmlColorTag
+
fpsLabel
,
fps
,
ms
);
m_Frames
=
0
;
m_LastInterval
=
timeNow
;
}
}
void
Set_FrameCounter_Position
(
FpsCounterAnchorPositions
anchor_position
)
{
//Debug.Log("Changing frame counter anchor position.");
m_TextMeshPro
.
margin
=
new
Vector4
(
1f
,
1f
,
1f
,
1f
);
switch
(
anchor_position
)
{
case
FpsCounterAnchorPositions
.
TopLeft
:
m_TextMeshPro
.
alignment
=
TextAlignmentOptions
.
TopLeft
;
m_TextMeshPro
.
rectTransform
.
pivot
=
new
Vector2
(
0
,
1
);
m_frameCounter_transform
.
position
=
m_camera
.
ViewportToWorldPoint
(
new
Vector3
(
0
,
1
,
100.0f
));
break
;
case
FpsCounterAnchorPositions
.
BottomLeft
:
m_TextMeshPro
.
alignment
=
TextAlignmentOptions
.
BottomLeft
;
m_TextMeshPro
.
rectTransform
.
pivot
=
new
Vector2
(
0
,
0
);
m_frameCounter_transform
.
position
=
m_camera
.
ViewportToWorldPoint
(
new
Vector3
(
0
,
0
,
100.0f
));
break
;
case
FpsCounterAnchorPositions
.
TopRight
:
m_TextMeshPro
.
alignment
=
TextAlignmentOptions
.
TopRight
;
m_TextMeshPro
.
rectTransform
.
pivot
=
new
Vector2
(
1
,
1
);
m_frameCounter_transform
.
position
=
m_camera
.
ViewportToWorldPoint
(
new
Vector3
(
1
,
1
,
100.0f
));
break
;
case
FpsCounterAnchorPositions
.
BottomRight
:
m_TextMeshPro
.
alignment
=
TextAlignmentOptions
.
BottomRight
;
m_TextMeshPro
.
rectTransform
.
pivot
=
new
Vector2
(
1
,
0
);
m_frameCounter_transform
.
position
=
m_camera
.
ViewportToWorldPoint
(
new
Vector3
(
1
,
0
,
100.0f
));
break
;
}
}
}
}
Assets/TextMesh Pro/Examples & Extras/Scripts/TMP_FrameRateCounter.cs.meta
0 → 100755
View file @
0f3088bc
fileFormatVersion: 2
guid: 686ec78b56aa445795335fbadafcfaa4
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
Assets/TextMesh Pro/Examples & Extras/Scripts/TMP_PhoneNumberValidator.cs
0 → 100755
View file @
0f3088bc
using
UnityEngine
;
using
System.Collections
;
using
System
;
namespace
TMPro
{
/// <summary>
/// Example of a Custom Character Input Validator to only allow phone number in the (800) 555-1212 format.
/// </summary>
[
Serializable
]
//[CreateAssetMenu(fileName = "InputValidator - Phone Numbers.asset", menuName = "TextMeshPro/Input Validators/Phone Numbers")]
public
class
TMP_PhoneNumberValidator
:
TMP_InputValidator
{
// Custom text input validation function
public
override
char
Validate
(
ref
string
text
,
ref
int
pos
,
char
ch
)
{
Debug
.
Log
(
"Trying to validate..."
);
// Return unless the character is a valid digit
if
(
ch
<
'0'
&&
ch
>
'9'
)
return
(
char
)
0
;
int
length
=
text
.
Length
;
// Enforce Phone Number format for every character input.
for
(
int
i
=
0
;
i
<
length
+
1
;
i
++)
{
switch
(
i
)
{
case
0
:
if
(
i
==
length
)
text
=
"("
+
ch
;
pos
=
2
;
break
;
case
1
:
if
(
i
==
length
)
text
+=
ch
;
pos
=
2
;
break
;
case
2
:
if
(
i
==
length
)
text
+=
ch
;
pos
=
3
;
break
;
case
3
:
if
(
i
==
length
)
text
+=
ch
+
") "
;
pos
=
6
;
break
;
case
4
:
if
(
i
==
length
)
text
+=
") "
+
ch
;
pos
=
7
;
break
;
case
5
:
if
(
i
==
length
)
text
+=
" "
+
ch
;
pos
=
7
;
break
;
case
6
:
if
(
i
==
length
)
text
+=
ch
;
pos
=
7
;
break
;
case
7
:
if
(
i
==
length
)
text
+=
ch
;
pos
=
8
;
break
;
case
8
:
if
(
i
==
length
)
text
+=
ch
+
"-"
;
pos
=
10
;
break
;
case
9
:
if
(
i
==
length
)
text
+=
"-"
+
ch
;
pos
=
11
;
break
;
case
10
:
if
(
i
==
length
)
text
+=
ch
;
pos
=
11
;
break
;
case
11
:
if
(
i
==
length
)
text
+=
ch
;
pos
=
12
;
break
;
case
12
:
if
(
i
==
length
)
text
+=
ch
;
pos
=
13
;
break
;
case
13
:
if
(
i
==
length
)
text
+=
ch
;
pos
=
14
;
break
;
}
}
return
ch
;
}
}
}
Assets/TextMesh Pro/Examples & Extras/Scripts/TMP_PhoneNumberValidator.cs.meta
0 → 100755
View file @
0f3088bc
fileFormatVersion: 2
guid: 83680ab1a69f4102ac67d1459fe76e1f
timeCreated: 1473056437
licenseType: Pro
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
Assets/TextMesh Pro/Examples & Extras/Scripts/TMP_TextEventCheck.cs
0 → 100755
View file @
0f3088bc
using
UnityEngine
;
namespace
TMPro.Examples
{
public
class
TMP_TextEventCheck
:
MonoBehaviour
{
public
TMP_TextEventHandler
TextEventHandler
;
private
TMP_Text
m_TextComponent
;
void
OnEnable
()
{
if
(
TextEventHandler
!=
null
)
{
// Get a reference to the text component
m_TextComponent
=
TextEventHandler
.
GetComponent
<
TMP_Text
>();
TextEventHandler
.
onCharacterSelection
.
AddListener
(
OnCharacterSelection
);
TextEventHandler
.
onSpriteSelection
.
AddListener
(
OnSpriteSelection
);
TextEventHandler
.
onWordSelection
.
AddListener
(
OnWordSelection
);
TextEventHandler
.
onLineSelection
.
AddListener
(
OnLineSelection
);
TextEventHandler
.
onLinkSelection
.
AddListener
(
OnLinkSelection
);
}
}
void
OnDisable
()
{
if
(
TextEventHandler
!=
null
)
{
TextEventHandler
.
onCharacterSelection
.
RemoveListener
(
OnCharacterSelection
);
TextEventHandler
.
onSpriteSelection
.
RemoveListener
(
OnSpriteSelection
);
TextEventHandler
.
onWordSelection
.
RemoveListener
(
OnWordSelection
);
TextEventHandler
.
onLineSelection
.
RemoveListener
(
OnLineSelection
);
TextEventHandler
.
onLinkSelection
.
RemoveListener
(
OnLinkSelection
);
}
}
void
OnCharacterSelection
(
char
c
,
int
index
)
{
Debug
.
Log
(
"Character ["
+
c
+
"] at Index: "
+
index
+
" has been selected."
);
}
void
OnSpriteSelection
(
char
c
,
int
index
)
{
Debug
.
Log
(
"Sprite ["
+
c
+
"] at Index: "
+
index
+
" has been selected."
);
}
void
OnWordSelection
(
string
word
,
int
firstCharacterIndex
,
int
length
)
{
Debug
.
Log
(
"Word ["
+
word
+
"] with first character index of "
+
firstCharacterIndex
+
" and length of "
+
length
+
" has been selected."
);
}
void
OnLineSelection
(
string
lineText
,
int
firstCharacterIndex
,
int
length
)
{
Debug
.
Log
(
"Line ["
+
lineText
+
"] with first character index of "
+
firstCharacterIndex
+
" and length of "
+
length
+
" has been selected."
);
}
void
OnLinkSelection
(
string
linkID
,
string
linkText
,
int
linkIndex
)
{
if
(
m_TextComponent
!=
null
)
{
TMP_LinkInfo
linkInfo
=
m_TextComponent
.
textInfo
.
linkInfo
[
linkIndex
];
}
Debug
.
Log
(
"Link Index: "
+
linkIndex
+
" with ID ["
+
linkID
+
"] and Text \""
+
linkText
+
"\" has been selected."
);
}
}
}
Prev
1
…
9
10
11
12
13
14
Next
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment