test
This commit is contained in:
@@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 619aadd8f276341ca84d7ad5a9c6db21
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
@@ -0,0 +1,9 @@
|
||||
using System.Runtime.CompilerServices;
|
||||
|
||||
// Allow internal visibility for testing purposes.
|
||||
[assembly: InternalsVisibleTo("Unity.TextCore")]
|
||||
[assembly: InternalsVisibleTo("Unity.TextCore.FontEngine.Tools")]
|
||||
|
||||
[assembly: InternalsVisibleTo("Unity.FontEngine.Tests")]
|
||||
[assembly: InternalsVisibleTo("Unity.TextCore.Editor")]
|
||||
[assembly: InternalsVisibleTo("Unity.TextMeshPro.Editor")]
|
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 1c147d10db452eb4b854a35f84472017
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
@@ -0,0 +1,161 @@
|
||||
using UnityEngine;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
|
||||
|
||||
namespace TMPro
|
||||
{
|
||||
/// <summary>
|
||||
/// Alternative Action delegate with increased performance when adding or removing delegates.
|
||||
/// </summary>
|
||||
public class FastAction
|
||||
{
|
||||
LinkedList<System.Action> delegates = new LinkedList<System.Action>();
|
||||
|
||||
Dictionary<System.Action, LinkedListNode<System.Action>> lookup = new Dictionary<System.Action, LinkedListNode<System.Action>>();
|
||||
|
||||
public void Add(System.Action rhs)
|
||||
{
|
||||
if (lookup.ContainsKey(rhs)) return;
|
||||
|
||||
lookup[rhs] = delegates.AddLast(rhs);
|
||||
}
|
||||
|
||||
public void Remove(System.Action rhs)
|
||||
{
|
||||
LinkedListNode<System.Action> node;
|
||||
if (lookup.TryGetValue(rhs, out node))
|
||||
{
|
||||
lookup.Remove(rhs);
|
||||
delegates.Remove(node);
|
||||
}
|
||||
}
|
||||
|
||||
public void Call()
|
||||
{
|
||||
var node = delegates.First;
|
||||
while (node != null)
|
||||
{
|
||||
node.Value();
|
||||
node = node.Next;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Alternative Action delegate with increased performance when adding or removing delegates.
|
||||
/// </summary>
|
||||
/// <typeparam name="A">The parameter of the method that this delegate encapsulates.</typeparam>
|
||||
public class FastAction<A>
|
||||
{
|
||||
LinkedList<System.Action<A>> delegates = new LinkedList<System.Action<A>>();
|
||||
|
||||
Dictionary<System.Action<A>, LinkedListNode<System.Action<A>>> lookup = new Dictionary<System.Action<A>, LinkedListNode<System.Action<A>>>();
|
||||
|
||||
public void Add(System.Action<A> rhs)
|
||||
{
|
||||
if (lookup.ContainsKey(rhs)) return;
|
||||
|
||||
lookup[rhs] = delegates.AddLast(rhs);
|
||||
}
|
||||
|
||||
public void Remove(System.Action<A> rhs)
|
||||
{
|
||||
LinkedListNode<System.Action<A>> node;
|
||||
if (lookup.TryGetValue(rhs, out node))
|
||||
{
|
||||
lookup.Remove(rhs);
|
||||
delegates.Remove(node);
|
||||
}
|
||||
}
|
||||
|
||||
public void Call(A a)
|
||||
{
|
||||
var node = delegates.First;
|
||||
while (node != null)
|
||||
{
|
||||
node.Value(a);
|
||||
node = node.Next;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Alternative Action delegate with increased performance when adding or removing delegates.
|
||||
/// </summary>
|
||||
/// <typeparam name="A">The first parameter of the method that this delegate encapsulates.</typeparam>
|
||||
/// <typeparam name="B">The second parameter of the method that this delegate encapsulates.</typeparam>
|
||||
public class FastAction<A, B>
|
||||
{
|
||||
LinkedList<System.Action<A, B>> delegates = new LinkedList<System.Action<A, B>>();
|
||||
|
||||
Dictionary<System.Action<A, B>, LinkedListNode<System.Action<A, B>>> lookup = new Dictionary<System.Action<A, B>, LinkedListNode<System.Action<A, B>>>();
|
||||
|
||||
public void Add(System.Action<A, B> rhs)
|
||||
{
|
||||
if (lookup.ContainsKey(rhs)) return;
|
||||
|
||||
lookup[rhs] = delegates.AddLast(rhs);
|
||||
}
|
||||
|
||||
public void Remove(System.Action<A, B> rhs)
|
||||
{
|
||||
LinkedListNode<System.Action<A, B>> node;
|
||||
if (lookup.TryGetValue(rhs, out node))
|
||||
{
|
||||
lookup.Remove(rhs);
|
||||
delegates.Remove(node);
|
||||
}
|
||||
}
|
||||
|
||||
public void Call(A a, B b)
|
||||
{
|
||||
var node = delegates.First;
|
||||
while (node != null)
|
||||
{
|
||||
node.Value(a, b);
|
||||
node = node.Next;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Alternative Action delegate with increased performance when adding or removing delegates.
|
||||
/// </summary>
|
||||
/// <typeparam name="A">The first parameter of the method that this delegate encapsulates.</typeparam>
|
||||
/// <typeparam name="B">The second parameter of the method that this delegate encapsulates.</typeparam>
|
||||
/// <typeparam name="C">The third parameter of the method that this delegate encapsulates.</typeparam>
|
||||
public class FastAction<A, B, C>
|
||||
{
|
||||
LinkedList<System.Action<A, B, C>> delegates = new LinkedList<System.Action<A, B, C>>();
|
||||
|
||||
Dictionary<System.Action<A, B, C>, LinkedListNode<System.Action<A, B, C>>> lookup = new Dictionary<System.Action<A, B, C>, LinkedListNode<System.Action<A, B, C>>>();
|
||||
|
||||
public void Add(System.Action<A, B, C> rhs)
|
||||
{
|
||||
if (lookup.ContainsKey(rhs)) return;
|
||||
|
||||
lookup[rhs] = delegates.AddLast(rhs);
|
||||
}
|
||||
|
||||
public void Remove(System.Action<A, B, C> rhs)
|
||||
{
|
||||
LinkedListNode<System.Action<A, B, C>> node;
|
||||
if (lookup.TryGetValue(rhs, out node))
|
||||
{
|
||||
lookup.Remove(rhs);
|
||||
delegates.Remove(node);
|
||||
}
|
||||
}
|
||||
|
||||
public void Call(A a, B b, C c)
|
||||
{
|
||||
var node = delegates.First;
|
||||
while (node != null)
|
||||
{
|
||||
node.Value(a, b, c);
|
||||
node = node.Next;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@@ -0,0 +1,12 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 871f8edd56e84b8fb295b10cc3c78f36
|
||||
timeCreated: 1435956061
|
||||
licenseType: Store
|
||||
MonoImporter:
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
@@ -0,0 +1,15 @@
|
||||
|
||||
|
||||
namespace UnityEngine.TextCore
|
||||
{
|
||||
/// <summary>
|
||||
/// Enumeration of currently supported OpenType Layout features.
|
||||
/// </summary>
|
||||
public enum OTL_FeatureTag : uint
|
||||
{
|
||||
kern = 'k' << 24 | 'e' << 16 | 'r' << 8 | 'n',
|
||||
liga = 'l' << 24 | 'i' << 16 | 'g' << 8 | 'a',
|
||||
mark = 'm' << 24 | 'a' << 16 | 'r' << 8 | 'k',
|
||||
mkmk = 'm' << 24 | 'k' << 16 | 'm' << 8 | 'k',
|
||||
}
|
||||
}
|
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 326e2b1b31fc06d4fa884c803b27b46a
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
@@ -0,0 +1,159 @@
|
||||
using System;
|
||||
using UnityEngine;
|
||||
|
||||
|
||||
namespace TMPro
|
||||
{
|
||||
/// <summary>
|
||||
/// A GlyphAnchorPoint defines the position of an anchor point relative to the origin of a glyph.
|
||||
/// This data structure is used by the Mark-to-Base, Mark-to-Mark and Mark-to-Ligature OpenType font features.
|
||||
/// </summary>
|
||||
[Serializable]
|
||||
public struct GlyphAnchorPoint
|
||||
{
|
||||
/// <summary>
|
||||
/// The x coordinate of the anchor point relative to the glyph.
|
||||
/// </summary>
|
||||
public float xCoordinate { get { return m_XCoordinate; } set { m_XCoordinate = value; } }
|
||||
|
||||
/// <summary>
|
||||
/// The y coordinate of the anchor point relative to the glyph.
|
||||
/// </summary>
|
||||
public float yCoordinate { get { return m_YCoordinate; } set { m_YCoordinate = value; } }
|
||||
|
||||
// =============================================
|
||||
// Private backing fields for public properties.
|
||||
// =============================================
|
||||
|
||||
[SerializeField]
|
||||
private float m_XCoordinate;
|
||||
|
||||
[SerializeField]
|
||||
private float m_YCoordinate;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// A MarkPositionAdjustment defines the positional adjustment of a glyph relative to the anchor point of base glyph.
|
||||
/// This data structure is used by the Mark-to-Base, Mark-to-Mark and Mark-to-Ligature OpenType font features.
|
||||
/// </summary>
|
||||
[Serializable]
|
||||
public struct MarkPositionAdjustment
|
||||
{
|
||||
/// <summary>
|
||||
/// The horizontal positional adjustment of the glyph relative to the anchor point of its parent base glyph.
|
||||
/// </summary>
|
||||
public float xPositionAdjustment { get { return m_XPositionAdjustment; } set { m_XPositionAdjustment = value; } }
|
||||
|
||||
/// <summary>
|
||||
/// The vertical positional adjustment of the glyph relative to the anchor point of its parent base glyph.
|
||||
/// </summary>
|
||||
public float yPositionAdjustment { get { return m_YPositionAdjustment; } set { m_YPositionAdjustment = value; } }
|
||||
|
||||
/// <summary>
|
||||
/// Initializes and returns an instance of MarkPositionAdjustment
|
||||
/// </summary>
|
||||
/// <param name="x">The horizontal positional adjustment.</param>
|
||||
/// <param name="y">The vertical positional adjustment.</param>
|
||||
public MarkPositionAdjustment(float x, float y)
|
||||
{
|
||||
m_XPositionAdjustment = x;
|
||||
m_YPositionAdjustment = y;
|
||||
}
|
||||
|
||||
// =============================================
|
||||
// Private backing fields for public properties.
|
||||
// =============================================
|
||||
|
||||
[SerializeField]
|
||||
private float m_XPositionAdjustment;
|
||||
|
||||
[SerializeField]
|
||||
private float m_YPositionAdjustment;
|
||||
};
|
||||
|
||||
/// <summary>
|
||||
/// A MarkToBaseAdjustmentRecord defines the positional adjustment between a base glyph and mark glyph.
|
||||
/// </summary>
|
||||
[Serializable]
|
||||
public struct MarkToBaseAdjustmentRecord
|
||||
{
|
||||
/// <summary>
|
||||
/// The index of the base glyph.
|
||||
/// </summary>
|
||||
public uint baseGlyphID { get { return m_BaseGlyphID; } set { m_BaseGlyphID = value; } }
|
||||
|
||||
/// <summary>
|
||||
/// The position of the anchor point of the base glyph.
|
||||
/// </summary>
|
||||
public GlyphAnchorPoint baseGlyphAnchorPoint { get { return m_BaseGlyphAnchorPoint; } set { m_BaseGlyphAnchorPoint = value; } }
|
||||
|
||||
/// <summary>
|
||||
/// The index of the mark glyph.
|
||||
/// </summary>
|
||||
public uint markGlyphID { get { return m_MarkGlyphID; } set { m_MarkGlyphID = value; } }
|
||||
|
||||
/// <summary>
|
||||
/// The positional adjustment of the mark glyph relative to the anchor point of the base glyph.
|
||||
/// </summary>
|
||||
public MarkPositionAdjustment markPositionAdjustment { get { return m_MarkPositionAdjustment; } set { m_MarkPositionAdjustment = value; } }
|
||||
|
||||
// =============================================
|
||||
// Private backing fields for public properties.
|
||||
// =============================================
|
||||
|
||||
[SerializeField]
|
||||
private uint m_BaseGlyphID;
|
||||
|
||||
[SerializeField]
|
||||
private GlyphAnchorPoint m_BaseGlyphAnchorPoint;
|
||||
|
||||
[SerializeField]
|
||||
private uint m_MarkGlyphID;
|
||||
|
||||
[SerializeField]
|
||||
private MarkPositionAdjustment m_MarkPositionAdjustment;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// A MarkToMarkAdjustmentRecord defines the positional adjustment between two mark glyphs.
|
||||
/// </summary>
|
||||
[Serializable]
|
||||
public struct MarkToMarkAdjustmentRecord
|
||||
{
|
||||
/// <summary>
|
||||
/// The index of the base glyph.
|
||||
/// </summary>
|
||||
public uint baseMarkGlyphID { get { return m_BaseMarkGlyphID; } set { m_BaseMarkGlyphID = value; } }
|
||||
|
||||
/// <summary>
|
||||
/// The position of the anchor point of the base mark glyph.
|
||||
/// </summary>
|
||||
public GlyphAnchorPoint baseMarkGlyphAnchorPoint { get { return m_BaseMarkGlyphAnchorPoint; } set { m_BaseMarkGlyphAnchorPoint = value; } }
|
||||
|
||||
/// <summary>
|
||||
/// The index of the mark glyph.
|
||||
/// </summary>
|
||||
public uint combiningMarkGlyphID { get { return m_CombiningMarkGlyphID; } set { m_CombiningMarkGlyphID = value; } }
|
||||
|
||||
/// <summary>
|
||||
/// The positional adjustment of the combining mark glyph relative to the anchor point of the base mark glyph.
|
||||
/// </summary>
|
||||
public MarkPositionAdjustment combiningMarkPositionAdjustment { get { return m_CombiningMarkPositionAdjustment; } set { m_CombiningMarkPositionAdjustment = value; } }
|
||||
|
||||
// =============================================
|
||||
// Private backing fields for public properties.
|
||||
// =============================================
|
||||
|
||||
[SerializeField]
|
||||
private uint m_BaseMarkGlyphID;
|
||||
|
||||
[SerializeField]
|
||||
private GlyphAnchorPoint m_BaseMarkGlyphAnchorPoint;
|
||||
|
||||
[SerializeField]
|
||||
private uint m_CombiningMarkGlyphID;
|
||||
|
||||
[SerializeField]
|
||||
private MarkPositionAdjustment m_CombiningMarkPositionAdjustment;
|
||||
}
|
||||
}
|
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: a4bbbb1fed4e2b7448af9313d6d00536
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
@@ -0,0 +1,107 @@
|
||||
using System;
|
||||
using UnityEngine;
|
||||
|
||||
#pragma warning disable CS0660, CS0661
|
||||
|
||||
namespace TMPro
|
||||
{
|
||||
/// <summary>
|
||||
/// The SingleSubstitutionRecord defines the substitution of a single glyph by another.
|
||||
/// </summary>
|
||||
[Serializable]
|
||||
public struct SingleSubstitutionRecord
|
||||
{
|
||||
//
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// The MultipleSubstitutionRecord defines the substitution of a single glyph by multiple glyphs.
|
||||
/// </summary>
|
||||
[Serializable]
|
||||
public struct MultipleSubstitutionRecord
|
||||
{
|
||||
/// <summary>
|
||||
/// The index of the target glyph being substituted.
|
||||
/// </summary>
|
||||
public uint targetGlyphID { get { return m_TargetGlyphID; } set { m_TargetGlyphID = value; } }
|
||||
|
||||
/// <summary>
|
||||
/// Array that contains the index of the glyphs replacing the single target glyph.
|
||||
/// </summary>
|
||||
public uint[] substituteGlyphIDs { get { return m_SubstituteGlyphIDs; } set { m_SubstituteGlyphIDs = value; } }
|
||||
|
||||
// =============================================
|
||||
// Private backing fields for public properties.
|
||||
// =============================================
|
||||
|
||||
[SerializeField]
|
||||
private uint m_TargetGlyphID;
|
||||
|
||||
[SerializeField]
|
||||
private uint[] m_SubstituteGlyphIDs;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// The AlternateSubstitutionRecord defines the substitution of a single glyph by several potential alternative glyphs.
|
||||
/// </summary>
|
||||
[Serializable]
|
||||
public struct AlternateSubstitutionRecord
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// The LigatureSubstitutionRecord defines the substitution of multiple glyphs by a single glyph.
|
||||
/// </summary>
|
||||
[Serializable]
|
||||
public struct LigatureSubstitutionRecord
|
||||
{
|
||||
/// <summary>
|
||||
/// Array that contains the index of the glyphs being substituted.
|
||||
/// </summary>
|
||||
public uint[] componentGlyphIDs { get { return m_ComponentGlyphIDs; } set { m_ComponentGlyphIDs = value; } }
|
||||
|
||||
/// <summary>
|
||||
/// The index of the replacement glyph.
|
||||
/// </summary>
|
||||
public uint ligatureGlyphID { get { return m_LigatureGlyphID; } set { m_LigatureGlyphID = value; } }
|
||||
|
||||
// =============================================
|
||||
// Private backing fields for public properties.
|
||||
// =============================================
|
||||
|
||||
[SerializeField]
|
||||
private uint[] m_ComponentGlyphIDs;
|
||||
|
||||
[SerializeField]
|
||||
private uint m_LigatureGlyphID;
|
||||
|
||||
// =============================================
|
||||
// Operator overrides
|
||||
// =============================================
|
||||
|
||||
public static bool operator==(LigatureSubstitutionRecord lhs, LigatureSubstitutionRecord rhs)
|
||||
{
|
||||
if (lhs.ligatureGlyphID != rhs.m_LigatureGlyphID)
|
||||
return false;
|
||||
|
||||
int lhsComponentCount = lhs.m_ComponentGlyphIDs.Length;
|
||||
|
||||
if (lhsComponentCount != rhs.m_ComponentGlyphIDs.Length)
|
||||
return false;
|
||||
|
||||
for (int i = 0; i < lhsComponentCount; i++)
|
||||
{
|
||||
if (lhs.m_ComponentGlyphIDs[i] != rhs.m_ComponentGlyphIDs[i])
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
public static bool operator!=(LigatureSubstitutionRecord lhs, LigatureSubstitutionRecord rhs)
|
||||
{
|
||||
return !(lhs == rhs);
|
||||
}
|
||||
}
|
||||
}
|
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 77b2d47bca9376f4a8ae69084a485957
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
@@ -0,0 +1,17 @@
|
||||
|
||||
|
||||
namespace TMPro
|
||||
{
|
||||
/// <summary>
|
||||
/// Interface used for preprocessing and shaping of text.
|
||||
/// </summary>
|
||||
public interface ITextPreprocessor
|
||||
{
|
||||
/// <summary>
|
||||
/// Function used for preprocessing of text
|
||||
/// </summary>
|
||||
/// <param name="text">Source text to be processed</param>
|
||||
/// <returns>Processed text</returns>
|
||||
string PreprocessText(string text);
|
||||
}
|
||||
}
|
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: afc31ad767318c9488de260c166cd21d
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,12 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 11a6a034ab84493cbed6af5ae7aae78b
|
||||
timeCreated: 1449743129
|
||||
licenseType: Pro
|
||||
MonoImporter:
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
@@ -0,0 +1,108 @@
|
||||
using System;
|
||||
using UnityEngine;
|
||||
using UnityEngine.Serialization;
|
||||
using UnityEngine.TextCore;
|
||||
|
||||
namespace TMPro
|
||||
{
|
||||
// Base class inherited by the various TextMeshPro Assets.
|
||||
[Serializable]
|
||||
public abstract class TMP_Asset : ScriptableObject
|
||||
{
|
||||
/// <summary>
|
||||
/// The version of the text asset class.
|
||||
/// Version 1.1.0 introduces new data structure to be compatible with new font asset structure.
|
||||
/// </summary>
|
||||
public string version
|
||||
{
|
||||
get { return m_Version; }
|
||||
internal set { m_Version = value; }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Instance ID of the TMP Asset
|
||||
/// </summary>
|
||||
public int instanceID
|
||||
{
|
||||
get
|
||||
{
|
||||
if (m_InstanceID == 0)
|
||||
m_InstanceID = GetInstanceID();
|
||||
|
||||
return m_InstanceID;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// HashCode based on the name of the asset.
|
||||
/// </summary>
|
||||
public int hashCode
|
||||
{
|
||||
get
|
||||
{
|
||||
if (m_HashCode == 0)
|
||||
m_HashCode = TMP_TextUtilities.GetHashCode(name);
|
||||
|
||||
return m_HashCode;
|
||||
}
|
||||
set => m_HashCode = value;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Information about the face of the asset.
|
||||
/// </summary>
|
||||
public FaceInfo faceInfo
|
||||
{
|
||||
get { return m_FaceInfo; }
|
||||
set { m_FaceInfo = value; }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// The material used by this asset.
|
||||
/// </summary>
|
||||
public Material material
|
||||
{
|
||||
get => m_Material;
|
||||
set => m_Material = value;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// HashCode based on the name of the material assigned to this asset.
|
||||
/// </summary>
|
||||
public int materialHashCode
|
||||
{
|
||||
get
|
||||
{
|
||||
if (m_MaterialHashCode == 0)
|
||||
{
|
||||
if (m_Material == null)
|
||||
return 0;
|
||||
|
||||
m_MaterialHashCode = TMP_TextUtilities.GetSimpleHashCode(m_Material.name);
|
||||
}
|
||||
|
||||
return m_MaterialHashCode;
|
||||
}
|
||||
set => m_MaterialHashCode = value;
|
||||
}
|
||||
|
||||
// =============================================
|
||||
// Private backing fields for public properties.
|
||||
// =============================================
|
||||
|
||||
[SerializeField]
|
||||
internal string m_Version;
|
||||
|
||||
internal int m_InstanceID;
|
||||
|
||||
internal int m_HashCode;
|
||||
|
||||
[SerializeField]
|
||||
internal FaceInfo m_FaceInfo;
|
||||
|
||||
[SerializeField][FormerlySerializedAs("material")]
|
||||
internal Material m_Material;
|
||||
|
||||
internal int m_MaterialHashCode;
|
||||
}
|
||||
}
|
@@ -0,0 +1,12 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 3bda1886f58f4e0ab1139400b160c3ee
|
||||
timeCreated: 1459318952
|
||||
licenseType: Pro
|
||||
MonoImporter:
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
@@ -0,0 +1,70 @@
|
||||
using System;
|
||||
using UnityEngine.TextCore;
|
||||
|
||||
namespace TMPro
|
||||
{
|
||||
/// <summary>
|
||||
/// A basic element of text.
|
||||
/// </summary>
|
||||
[Serializable]
|
||||
public class TMP_Character : TMP_TextElement
|
||||
{
|
||||
/// <summary>
|
||||
/// Default constructor.
|
||||
/// </summary>
|
||||
public TMP_Character()
|
||||
{
|
||||
m_ElementType = TextElementType.Character;
|
||||
this.scale = 1.0f;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Constructor for new character
|
||||
/// </summary>
|
||||
/// <param name="unicode">Unicode value.</param>
|
||||
/// <param name="glyph">Glyph</param>
|
||||
public TMP_Character(uint unicode, Glyph glyph)
|
||||
{
|
||||
m_ElementType = TextElementType.Character;
|
||||
|
||||
this.unicode = unicode;
|
||||
this.textAsset = null;
|
||||
this.glyph = glyph;
|
||||
this.glyphIndex = glyph.index;
|
||||
this.scale = 1.0f;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Constructor for new character
|
||||
/// </summary>
|
||||
/// <param name="unicode">Unicode value.</param>
|
||||
/// <param name="fontAsset">The font asset to which this character belongs.</param>
|
||||
/// <param name="glyph">Glyph</param>
|
||||
public TMP_Character(uint unicode, TMP_FontAsset fontAsset, Glyph glyph)
|
||||
{
|
||||
m_ElementType = TextElementType.Character;
|
||||
|
||||
this.unicode = unicode;
|
||||
this.textAsset = fontAsset;
|
||||
this.glyph = glyph;
|
||||
this.glyphIndex = glyph.index;
|
||||
this.scale = 1.0f;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Constructor for new character
|
||||
/// </summary>
|
||||
/// <param name="unicode">Unicode value.</param>
|
||||
/// <param name="glyphIndex">Glyph index.</param>
|
||||
internal TMP_Character(uint unicode, uint glyphIndex)
|
||||
{
|
||||
m_ElementType = TextElementType.Character;
|
||||
|
||||
this.unicode = unicode;
|
||||
this.textAsset = null;
|
||||
this.glyph = null;
|
||||
this.glyphIndex = glyphIndex;
|
||||
this.scale = 1.0f;
|
||||
}
|
||||
}
|
||||
}
|
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 4ac5b6a65aaeb59478e3b78660e9f134
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
@@ -0,0 +1,223 @@
|
||||
using System.Diagnostics;
|
||||
using UnityEngine;
|
||||
using UnityEngine.TextCore;
|
||||
|
||||
|
||||
namespace TMPro
|
||||
{
|
||||
public struct TMP_Vertex
|
||||
{
|
||||
public Vector3 position;
|
||||
public Vector4 uv;
|
||||
public Vector2 uv2;
|
||||
//public Vector2 uv4;
|
||||
public Color32 color;
|
||||
|
||||
public static TMP_Vertex zero { get { return k_Zero; } }
|
||||
|
||||
//public Vector3 normal;
|
||||
//public Vector4 tangent;
|
||||
|
||||
static readonly TMP_Vertex k_Zero = new TMP_Vertex();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
public struct TMP_Offset
|
||||
{
|
||||
public float left { get { return m_Left; } set { m_Left = value; } }
|
||||
|
||||
public float right { get { return m_Right; } set { m_Right = value; } }
|
||||
|
||||
public float top { get { return m_Top; } set { m_Top = value; } }
|
||||
|
||||
public float bottom { get { return m_Bottom; } set { m_Bottom = value; } }
|
||||
|
||||
public float horizontal { get { return m_Left; } set { m_Left = value; m_Right = value; } }
|
||||
|
||||
public float vertical { get { return m_Top; } set { m_Top = value; m_Bottom = value; } }
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
public static TMP_Offset zero { get { return k_ZeroOffset; } }
|
||||
|
||||
// =============================================
|
||||
// Private backing fields for public properties.
|
||||
// =============================================
|
||||
|
||||
float m_Left;
|
||||
float m_Right;
|
||||
float m_Top;
|
||||
float m_Bottom;
|
||||
|
||||
static readonly TMP_Offset k_ZeroOffset = new TMP_Offset(0F, 0F, 0F, 0F);
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
/// <param name="left"></param>
|
||||
/// <param name="right"></param>
|
||||
/// <param name="top"></param>
|
||||
/// <param name="bottom"></param>
|
||||
public TMP_Offset(float left, float right, float top, float bottom)
|
||||
{
|
||||
m_Left = left;
|
||||
m_Right = right;
|
||||
m_Top = top;
|
||||
m_Bottom = bottom;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
/// <param name="horizontal"></param>
|
||||
/// <param name="vertical"></param>
|
||||
public TMP_Offset(float horizontal, float vertical)
|
||||
{
|
||||
m_Left = horizontal;
|
||||
m_Right = horizontal;
|
||||
m_Top = vertical;
|
||||
m_Bottom = vertical;
|
||||
}
|
||||
|
||||
public static bool operator ==(TMP_Offset lhs, TMP_Offset rhs)
|
||||
{
|
||||
return lhs.m_Left == rhs.m_Left &&
|
||||
lhs.m_Right == rhs.m_Right &&
|
||||
lhs.m_Top == rhs.m_Top &&
|
||||
lhs.m_Bottom == rhs.m_Bottom;
|
||||
}
|
||||
|
||||
public static bool operator !=(TMP_Offset lhs, TMP_Offset rhs)
|
||||
{
|
||||
return !(lhs == rhs);
|
||||
}
|
||||
|
||||
public static TMP_Offset operator *(TMP_Offset a, float b)
|
||||
{
|
||||
return new TMP_Offset(a.m_Left * b, a.m_Right * b, a.m_Top * b, a.m_Bottom * b);
|
||||
}
|
||||
|
||||
public override int GetHashCode()
|
||||
{
|
||||
return base.GetHashCode();
|
||||
}
|
||||
|
||||
public override bool Equals(object obj)
|
||||
{
|
||||
return base.Equals(obj);
|
||||
}
|
||||
|
||||
public bool Equals(TMP_Offset other)
|
||||
{
|
||||
return base.Equals(other);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
public struct HighlightState
|
||||
{
|
||||
public Color32 color;
|
||||
public TMP_Offset padding;
|
||||
|
||||
public HighlightState(Color32 color, TMP_Offset padding)
|
||||
{
|
||||
this.color = color;
|
||||
this.padding = padding;
|
||||
}
|
||||
|
||||
public static bool operator ==(HighlightState lhs, HighlightState rhs)
|
||||
{
|
||||
return lhs.color.Compare(rhs.color) && lhs.padding == rhs.padding;
|
||||
}
|
||||
|
||||
public static bool operator !=(HighlightState lhs, HighlightState rhs)
|
||||
{
|
||||
return !(lhs == rhs);
|
||||
}
|
||||
|
||||
public override int GetHashCode()
|
||||
{
|
||||
return base.GetHashCode();
|
||||
}
|
||||
|
||||
public override bool Equals(object obj)
|
||||
{
|
||||
return base.Equals(obj);
|
||||
}
|
||||
|
||||
public bool Equals(HighlightState other)
|
||||
{
|
||||
return base.Equals(other);
|
||||
}
|
||||
}
|
||||
/// <summary>
|
||||
/// Structure containing information about individual text elements (character or sprites).
|
||||
/// </summary>
|
||||
[DebuggerDisplay("Unicode '{character}' ({((uint)character).ToString(\"X\")})")]
|
||||
public struct TMP_CharacterInfo
|
||||
{
|
||||
public TMP_TextElementType elementType;
|
||||
|
||||
public char character; // Should be changed to an uint to handle UTF32
|
||||
|
||||
/// <summary>
|
||||
/// Index of the character in the source text.
|
||||
/// </summary>
|
||||
public int index;
|
||||
public int stringLength;
|
||||
|
||||
public TMP_TextElement textElement;
|
||||
public Glyph alternativeGlyph;
|
||||
public TMP_FontAsset fontAsset;
|
||||
public Material material;
|
||||
public int materialReferenceIndex;
|
||||
public bool isUsingAlternateTypeface;
|
||||
|
||||
public float pointSize;
|
||||
|
||||
//public short wordNumber;
|
||||
public int lineNumber;
|
||||
//public short charNumber;
|
||||
public int pageNumber;
|
||||
|
||||
|
||||
public int vertexIndex;
|
||||
public TMP_Vertex vertex_BL;
|
||||
public TMP_Vertex vertex_TL;
|
||||
public TMP_Vertex vertex_TR;
|
||||
public TMP_Vertex vertex_BR;
|
||||
|
||||
public Vector3 topLeft;
|
||||
public Vector3 bottomLeft;
|
||||
public Vector3 topRight;
|
||||
public Vector3 bottomRight;
|
||||
|
||||
public float origin;
|
||||
public float xAdvance;
|
||||
public float ascender;
|
||||
public float baseLine;
|
||||
public float descender;
|
||||
internal float adjustedAscender;
|
||||
internal float adjustedDescender;
|
||||
internal float adjustedHorizontalAdvance;
|
||||
|
||||
public float aspectRatio;
|
||||
public float scale;
|
||||
public Color32 color;
|
||||
public Color32 underlineColor;
|
||||
public int underlineVertexIndex;
|
||||
public Color32 strikethroughColor;
|
||||
public int strikethroughVertexIndex;
|
||||
public Color32 highlightColor;
|
||||
public HighlightState highlightState;
|
||||
public FontStyles style;
|
||||
public bool isVisible;
|
||||
//public bool isIgnoringAlignment;
|
||||
}
|
||||
}
|
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 90fe1c65e6bb3bc4e90862df7297719e
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
@@ -0,0 +1,68 @@
|
||||
using UnityEngine;
|
||||
using System.Collections;
|
||||
|
||||
namespace TMPro
|
||||
{
|
||||
public enum ColorMode
|
||||
{
|
||||
Single,
|
||||
HorizontalGradient,
|
||||
VerticalGradient,
|
||||
FourCornersGradient
|
||||
}
|
||||
|
||||
[System.Serializable][ExcludeFromPresetAttribute]
|
||||
public class TMP_ColorGradient : ScriptableObject
|
||||
{
|
||||
public ColorMode colorMode = ColorMode.FourCornersGradient;
|
||||
|
||||
public Color topLeft;
|
||||
public Color topRight;
|
||||
public Color bottomLeft;
|
||||
public Color bottomRight;
|
||||
|
||||
const ColorMode k_DefaultColorMode = ColorMode.FourCornersGradient;
|
||||
static readonly Color k_DefaultColor = Color.white;
|
||||
|
||||
/// <summary>
|
||||
/// Default Constructor which sets each of the colors as white.
|
||||
/// </summary>
|
||||
public TMP_ColorGradient()
|
||||
{
|
||||
colorMode = k_DefaultColorMode;
|
||||
topLeft = k_DefaultColor;
|
||||
topRight = k_DefaultColor;
|
||||
bottomLeft = k_DefaultColor;
|
||||
bottomRight = k_DefaultColor;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Constructor allowing to set the default color of the Color Gradient.
|
||||
/// </summary>
|
||||
/// <param name="color"></param>
|
||||
public TMP_ColorGradient(Color color)
|
||||
{
|
||||
colorMode = k_DefaultColorMode;
|
||||
topLeft = color;
|
||||
topRight = color;
|
||||
bottomLeft = color;
|
||||
bottomRight = color;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// The vertex colors at the corners of the characters.
|
||||
/// </summary>
|
||||
/// <param name="color0">Top left color.</param>
|
||||
/// <param name="color1">Top right color.</param>
|
||||
/// <param name="color2">Bottom left color.</param>
|
||||
/// <param name="color3">Bottom right color.</param>
|
||||
public TMP_ColorGradient(Color color0, Color color1, Color color2, Color color3)
|
||||
{
|
||||
colorMode = k_DefaultColorMode;
|
||||
this.topLeft = color0;
|
||||
this.topRight = color1;
|
||||
this.bottomLeft = color2;
|
||||
this.bottomRight = color3;
|
||||
}
|
||||
}
|
||||
}
|
@@ -0,0 +1,12 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 54d21f6ece3b46479f0c328f8c6007e0
|
||||
timeCreated: 1468187202
|
||||
licenseType: Pro
|
||||
MonoImporter:
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
@@ -0,0 +1,74 @@
|
||||
using UnityEngine;
|
||||
using System.Collections;
|
||||
|
||||
|
||||
namespace TMPro
|
||||
{
|
||||
// Class used to convert scenes and objects saved in version 0.1.44 to the new Text Container
|
||||
public static class TMP_Compatibility
|
||||
{
|
||||
public enum AnchorPositions { TopLeft, Top, TopRight, Left, Center, Right, BottomLeft, Bottom, BottomRight, BaseLine, None };
|
||||
|
||||
/// <summary>
|
||||
/// Function used to convert text alignment option enumeration format.
|
||||
/// </summary>
|
||||
/// <param name="oldValue"></param>
|
||||
/// <returns></returns>
|
||||
public static TextAlignmentOptions ConvertTextAlignmentEnumValues(TextAlignmentOptions oldValue)
|
||||
{
|
||||
switch ((int)oldValue)
|
||||
{
|
||||
case 0:
|
||||
return TextAlignmentOptions.TopLeft;
|
||||
case 1:
|
||||
return TextAlignmentOptions.Top;
|
||||
case 2:
|
||||
return TextAlignmentOptions.TopRight;
|
||||
case 3:
|
||||
return TextAlignmentOptions.TopJustified;
|
||||
case 4:
|
||||
return TextAlignmentOptions.Left;
|
||||
case 5:
|
||||
return TextAlignmentOptions.Center;
|
||||
case 6:
|
||||
return TextAlignmentOptions.Right;
|
||||
case 7:
|
||||
return TextAlignmentOptions.Justified;
|
||||
case 8:
|
||||
return TextAlignmentOptions.BottomLeft;
|
||||
case 9:
|
||||
return TextAlignmentOptions.Bottom;
|
||||
case 10:
|
||||
return TextAlignmentOptions.BottomRight;
|
||||
case 11:
|
||||
return TextAlignmentOptions.BottomJustified;
|
||||
case 12:
|
||||
return TextAlignmentOptions.BaselineLeft;
|
||||
case 13:
|
||||
return TextAlignmentOptions.Baseline;
|
||||
case 14:
|
||||
return TextAlignmentOptions.BaselineRight;
|
||||
case 15:
|
||||
return TextAlignmentOptions.BaselineJustified;
|
||||
case 16:
|
||||
return TextAlignmentOptions.MidlineLeft;
|
||||
case 17:
|
||||
return TextAlignmentOptions.Midline;
|
||||
case 18:
|
||||
return TextAlignmentOptions.MidlineRight;
|
||||
case 19:
|
||||
return TextAlignmentOptions.MidlineJustified;
|
||||
case 20:
|
||||
return TextAlignmentOptions.CaplineLeft;
|
||||
case 21:
|
||||
return TextAlignmentOptions.Capline;
|
||||
case 22:
|
||||
return TextAlignmentOptions.CaplineRight;
|
||||
case 23:
|
||||
return TextAlignmentOptions.CaplineJustified;
|
||||
}
|
||||
|
||||
return TextAlignmentOptions.TopLeft;
|
||||
}
|
||||
}
|
||||
}
|
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 21364f754cf9b9b47a60742332d4af56
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
@@ -0,0 +1,246 @@
|
||||
using UnityEngine;
|
||||
using UnityEngine.Events;
|
||||
using System.Collections;
|
||||
|
||||
|
||||
namespace TMPro
|
||||
{
|
||||
// Base interface for tweeners,
|
||||
// using an interface instead of
|
||||
// an abstract class as we want the
|
||||
// tweens to be structs.
|
||||
internal interface ITweenValue
|
||||
{
|
||||
void TweenValue(float floatPercentage);
|
||||
bool ignoreTimeScale { get; }
|
||||
float duration { get; }
|
||||
bool ValidTarget();
|
||||
}
|
||||
|
||||
// Color tween class, receives the
|
||||
// TweenValue callback and then sets
|
||||
// the value on the target.
|
||||
internal struct ColorTween : ITweenValue
|
||||
{
|
||||
public enum ColorTweenMode
|
||||
{
|
||||
All,
|
||||
RGB,
|
||||
Alpha
|
||||
}
|
||||
|
||||
public class ColorTweenCallback : UnityEvent<Color> { }
|
||||
|
||||
private ColorTweenCallback m_Target;
|
||||
private Color m_StartColor;
|
||||
private Color m_TargetColor;
|
||||
private ColorTweenMode m_TweenMode;
|
||||
|
||||
private float m_Duration;
|
||||
private bool m_IgnoreTimeScale;
|
||||
|
||||
public Color startColor
|
||||
{
|
||||
get { return m_StartColor; }
|
||||
set { m_StartColor = value; }
|
||||
}
|
||||
|
||||
public Color targetColor
|
||||
{
|
||||
get { return m_TargetColor; }
|
||||
set { m_TargetColor = value; }
|
||||
}
|
||||
|
||||
public ColorTweenMode tweenMode
|
||||
{
|
||||
get { return m_TweenMode; }
|
||||
set { m_TweenMode = value; }
|
||||
}
|
||||
|
||||
public float duration
|
||||
{
|
||||
get { return m_Duration; }
|
||||
set { m_Duration = value; }
|
||||
}
|
||||
|
||||
public bool ignoreTimeScale
|
||||
{
|
||||
get { return m_IgnoreTimeScale; }
|
||||
set { m_IgnoreTimeScale = value; }
|
||||
}
|
||||
|
||||
public void TweenValue(float floatPercentage)
|
||||
{
|
||||
if (!ValidTarget())
|
||||
return;
|
||||
|
||||
var newColor = Color.Lerp(m_StartColor, m_TargetColor, floatPercentage);
|
||||
|
||||
if (m_TweenMode == ColorTweenMode.Alpha)
|
||||
{
|
||||
newColor.r = m_StartColor.r;
|
||||
newColor.g = m_StartColor.g;
|
||||
newColor.b = m_StartColor.b;
|
||||
}
|
||||
else if (m_TweenMode == ColorTweenMode.RGB)
|
||||
{
|
||||
newColor.a = m_StartColor.a;
|
||||
}
|
||||
m_Target.Invoke(newColor);
|
||||
}
|
||||
|
||||
public void AddOnChangedCallback(UnityAction<Color> callback)
|
||||
{
|
||||
if (m_Target == null)
|
||||
m_Target = new ColorTweenCallback();
|
||||
|
||||
m_Target.AddListener(callback);
|
||||
}
|
||||
|
||||
public bool GetIgnoreTimescale()
|
||||
{
|
||||
return m_IgnoreTimeScale;
|
||||
}
|
||||
|
||||
public float GetDuration()
|
||||
{
|
||||
return m_Duration;
|
||||
}
|
||||
|
||||
public bool ValidTarget()
|
||||
{
|
||||
return m_Target != null;
|
||||
}
|
||||
}
|
||||
|
||||
// Float tween class, receives the
|
||||
// TweenValue callback and then sets
|
||||
// the value on the target.
|
||||
internal struct FloatTween : ITweenValue
|
||||
{
|
||||
public class FloatTweenCallback : UnityEvent<float> { }
|
||||
|
||||
private FloatTweenCallback m_Target;
|
||||
private float m_StartValue;
|
||||
private float m_TargetValue;
|
||||
|
||||
private float m_Duration;
|
||||
private bool m_IgnoreTimeScale;
|
||||
|
||||
public float startValue
|
||||
{
|
||||
get { return m_StartValue; }
|
||||
set { m_StartValue = value; }
|
||||
}
|
||||
|
||||
public float targetValue
|
||||
{
|
||||
get { return m_TargetValue; }
|
||||
set { m_TargetValue = value; }
|
||||
}
|
||||
|
||||
public float duration
|
||||
{
|
||||
get { return m_Duration; }
|
||||
set { m_Duration = value; }
|
||||
}
|
||||
|
||||
public bool ignoreTimeScale
|
||||
{
|
||||
get { return m_IgnoreTimeScale; }
|
||||
set { m_IgnoreTimeScale = value; }
|
||||
}
|
||||
|
||||
public void TweenValue(float floatPercentage)
|
||||
{
|
||||
if (!ValidTarget())
|
||||
return;
|
||||
|
||||
var newValue = Mathf.Lerp(m_StartValue, m_TargetValue, floatPercentage);
|
||||
m_Target.Invoke(newValue);
|
||||
}
|
||||
|
||||
public void AddOnChangedCallback(UnityAction<float> callback)
|
||||
{
|
||||
if (m_Target == null)
|
||||
m_Target = new FloatTweenCallback();
|
||||
|
||||
m_Target.AddListener(callback);
|
||||
}
|
||||
|
||||
public bool GetIgnoreTimescale()
|
||||
{
|
||||
return m_IgnoreTimeScale;
|
||||
}
|
||||
|
||||
public float GetDuration()
|
||||
{
|
||||
return m_Duration;
|
||||
}
|
||||
|
||||
public bool ValidTarget()
|
||||
{
|
||||
return m_Target != null;
|
||||
}
|
||||
}
|
||||
|
||||
// Tween runner, executes the given tween.
|
||||
// The coroutine will live within the given
|
||||
// behaviour container.
|
||||
internal class TweenRunner<T> where T : struct, ITweenValue
|
||||
{
|
||||
protected MonoBehaviour m_CoroutineContainer;
|
||||
protected IEnumerator m_Tween;
|
||||
|
||||
// utility function for starting the tween
|
||||
private static IEnumerator Start(T tweenInfo)
|
||||
{
|
||||
if (!tweenInfo.ValidTarget())
|
||||
yield break;
|
||||
|
||||
var elapsedTime = 0.0f;
|
||||
while (elapsedTime < tweenInfo.duration)
|
||||
{
|
||||
elapsedTime += tweenInfo.ignoreTimeScale ? Time.unscaledDeltaTime : Time.deltaTime;
|
||||
var percentage = Mathf.Clamp01(elapsedTime / tweenInfo.duration);
|
||||
tweenInfo.TweenValue(percentage);
|
||||
yield return null;
|
||||
}
|
||||
tweenInfo.TweenValue(1.0f);
|
||||
}
|
||||
|
||||
public void Init(MonoBehaviour coroutineContainer)
|
||||
{
|
||||
m_CoroutineContainer = coroutineContainer;
|
||||
}
|
||||
|
||||
public void StartTween(T info)
|
||||
{
|
||||
if (m_CoroutineContainer == null)
|
||||
{
|
||||
Debug.LogWarning("Coroutine container not configured... did you forget to call Init?");
|
||||
return;
|
||||
}
|
||||
|
||||
StopTween();
|
||||
|
||||
if (!m_CoroutineContainer.gameObject.activeInHierarchy)
|
||||
{
|
||||
info.TweenValue(1.0f);
|
||||
return;
|
||||
}
|
||||
|
||||
m_Tween = Start(info);
|
||||
m_CoroutineContainer.StartCoroutine(m_Tween);
|
||||
}
|
||||
|
||||
public void StopTween()
|
||||
{
|
||||
if (m_Tween != null)
|
||||
{
|
||||
m_CoroutineContainer.StopCoroutine(m_Tween);
|
||||
m_Tween = null;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@@ -0,0 +1,12 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 658c1fb149e7498aa072b0c0f3bf13f0
|
||||
timeCreated: 1464850953
|
||||
licenseType: Pro
|
||||
MonoImporter:
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
@@ -0,0 +1,424 @@
|
||||
using UnityEngine;
|
||||
using System.Collections;
|
||||
using UnityEngine.UI;
|
||||
|
||||
#if UNITY_EDITOR
|
||||
using UnityEditor;
|
||||
#endif
|
||||
|
||||
|
||||
namespace TMPro
|
||||
{
|
||||
|
||||
public static class TMP_DefaultControls
|
||||
{
|
||||
public struct Resources
|
||||
{
|
||||
public Sprite standard;
|
||||
public Sprite background;
|
||||
public Sprite inputField;
|
||||
public Sprite knob;
|
||||
public Sprite checkmark;
|
||||
public Sprite dropdown;
|
||||
public Sprite mask;
|
||||
}
|
||||
|
||||
private const float kWidth = 160f;
|
||||
private const float kThickHeight = 30f;
|
||||
private const float kThinHeight = 20f;
|
||||
private static Vector2 s_TextElementSize = new Vector2(100f, 100f);
|
||||
private static Vector2 s_ThickElementSize = new Vector2(kWidth, kThickHeight);
|
||||
private static Vector2 s_ThinElementSize = new Vector2(kWidth, kThinHeight);
|
||||
//private static Vector2 s_ImageElementSize = new Vector2(100f, 100f);
|
||||
private static Color s_DefaultSelectableColor = new Color(1f, 1f, 1f, 1f);
|
||||
//private static Color s_PanelColor = new Color(1f, 1f, 1f, 0.392f);
|
||||
private static Color s_TextColor = new Color(50f / 255f, 50f / 255f, 50f / 255f, 1f);
|
||||
|
||||
|
||||
private static GameObject CreateUIElementRoot(string name, Vector2 size)
|
||||
{
|
||||
GameObject root;
|
||||
|
||||
#if UNITY_EDITOR
|
||||
root = ObjectFactory.CreateGameObject(name, typeof(RectTransform));
|
||||
var rt = root.GetComponent<RectTransform>();
|
||||
rt.sizeDelta = size;
|
||||
#else
|
||||
root = new GameObject(name);
|
||||
RectTransform rectTransform = root.AddComponent<RectTransform>();
|
||||
rectTransform.sizeDelta = size;
|
||||
#endif
|
||||
|
||||
return root;
|
||||
}
|
||||
|
||||
static GameObject CreateUIObject(string name, GameObject parent)
|
||||
{
|
||||
GameObject go;
|
||||
#if UNITY_EDITOR
|
||||
go = ObjectFactory.CreateGameObject(name, typeof(RectTransform));
|
||||
#else
|
||||
go = new GameObject(name);
|
||||
go.AddComponent<RectTransform>();
|
||||
#endif
|
||||
SetParentAndAlign(go, parent);
|
||||
return go;
|
||||
}
|
||||
|
||||
private static void SetDefaultTextValues(TMP_Text lbl)
|
||||
{
|
||||
// Set text values we want across UI elements in default controls.
|
||||
// Don't set values which are the same as the default values for the Text component,
|
||||
// since there's no point in that, and it's good to keep them as consistent as possible.
|
||||
lbl.color = s_TextColor;
|
||||
lbl.fontSize = 14;
|
||||
}
|
||||
|
||||
private static void SetDefaultColorTransitionValues(Selectable slider)
|
||||
{
|
||||
ColorBlock colors = slider.colors;
|
||||
colors.highlightedColor = new Color(0.882f, 0.882f, 0.882f);
|
||||
colors.pressedColor = new Color(0.698f, 0.698f, 0.698f);
|
||||
colors.disabledColor = new Color(0.521f, 0.521f, 0.521f);
|
||||
}
|
||||
|
||||
private static void SetParentAndAlign(GameObject child, GameObject parent)
|
||||
{
|
||||
if (parent == null)
|
||||
return;
|
||||
|
||||
child.transform.SetParent(parent.transform, false);
|
||||
SetLayerRecursively(child, parent.layer);
|
||||
}
|
||||
|
||||
private static void SetLayerRecursively(GameObject go, int layer)
|
||||
{
|
||||
go.layer = layer;
|
||||
Transform t = go.transform;
|
||||
for (int i = 0; i < t.childCount; i++)
|
||||
SetLayerRecursively(t.GetChild(i).gameObject, layer);
|
||||
}
|
||||
|
||||
// Actual controls
|
||||
|
||||
public static GameObject CreateScrollbar(Resources resources)
|
||||
{
|
||||
// Create GOs Hierarchy
|
||||
GameObject scrollbarRoot = CreateUIElementRoot("Scrollbar", s_ThinElementSize);
|
||||
|
||||
GameObject sliderArea = CreateUIObject("Sliding Area", scrollbarRoot);
|
||||
GameObject handle = CreateUIObject("Handle", sliderArea);
|
||||
|
||||
Image bgImage = AddComponent<Image>(scrollbarRoot);
|
||||
bgImage.sprite = resources.background;
|
||||
bgImage.type = Image.Type.Sliced;
|
||||
bgImage.color = s_DefaultSelectableColor;
|
||||
|
||||
Image handleImage = AddComponent<Image>(handle);
|
||||
handleImage.sprite = resources.standard;
|
||||
handleImage.type = Image.Type.Sliced;
|
||||
handleImage.color = s_DefaultSelectableColor;
|
||||
|
||||
RectTransform sliderAreaRect = sliderArea.GetComponent<RectTransform>();
|
||||
sliderAreaRect.sizeDelta = new Vector2(-20, -20);
|
||||
sliderAreaRect.anchorMin = Vector2.zero;
|
||||
sliderAreaRect.anchorMax = Vector2.one;
|
||||
|
||||
RectTransform handleRect = handle.GetComponent<RectTransform>();
|
||||
handleRect.sizeDelta = new Vector2(20, 20);
|
||||
|
||||
Scrollbar scrollbar = AddComponent<Scrollbar>(scrollbarRoot);
|
||||
scrollbar.handleRect = handleRect;
|
||||
scrollbar.targetGraphic = handleImage;
|
||||
SetDefaultColorTransitionValues(scrollbar);
|
||||
|
||||
return scrollbarRoot;
|
||||
}
|
||||
|
||||
public static GameObject CreateButton(Resources resources)
|
||||
{
|
||||
GameObject buttonRoot = CreateUIElementRoot("Button", s_ThickElementSize);
|
||||
|
||||
GameObject childText;
|
||||
#if UNITY_EDITOR
|
||||
childText = ObjectFactory.CreateGameObject("Text (TMP)", typeof(RectTransform));
|
||||
#else
|
||||
childText = new GameObject("Text (TMP)");
|
||||
childText.AddComponent<RectTransform>();
|
||||
#endif
|
||||
|
||||
SetParentAndAlign(childText, buttonRoot);
|
||||
|
||||
Image image = AddComponent<Image>(buttonRoot);
|
||||
image.sprite = resources.standard;
|
||||
image.type = Image.Type.Sliced;
|
||||
image.color = s_DefaultSelectableColor;
|
||||
|
||||
Button bt = AddComponent<Button>(buttonRoot);
|
||||
SetDefaultColorTransitionValues(bt);
|
||||
|
||||
TextMeshProUGUI text = AddComponent<TextMeshProUGUI>(childText);
|
||||
text.text = "Button";
|
||||
text.alignment = TextAlignmentOptions.Center;
|
||||
SetDefaultTextValues(text);
|
||||
|
||||
RectTransform textRectTransform = childText.GetComponent<RectTransform>();
|
||||
textRectTransform.anchorMin = Vector2.zero;
|
||||
textRectTransform.anchorMax = Vector2.one;
|
||||
textRectTransform.sizeDelta = Vector2.zero;
|
||||
|
||||
return buttonRoot;
|
||||
}
|
||||
|
||||
public static GameObject CreateText(Resources resources)
|
||||
{
|
||||
GameObject go = null;
|
||||
|
||||
#if UNITY_EDITOR
|
||||
go = ObjectFactory.CreateGameObject("Text (TMP)", typeof(TextMeshProUGUI));
|
||||
#else
|
||||
go = CreateUIElementRoot("Text (TMP)", s_TextElementSize);
|
||||
go.AddComponent<TextMeshProUGUI>();
|
||||
#endif
|
||||
|
||||
return go;
|
||||
}
|
||||
|
||||
public static GameObject CreateInputField(Resources resources)
|
||||
{
|
||||
GameObject root = CreateUIElementRoot("InputField (TMP)", s_ThickElementSize);
|
||||
|
||||
GameObject textArea = CreateUIObject("Text Area", root);
|
||||
GameObject childPlaceholder = CreateUIObject("Placeholder", textArea);
|
||||
GameObject childText = CreateUIObject("Text", textArea);
|
||||
|
||||
Image image = AddComponent<Image>(root);
|
||||
image.sprite = resources.inputField;
|
||||
image.type = Image.Type.Sliced;
|
||||
image.color = s_DefaultSelectableColor;
|
||||
|
||||
TMP_InputField inputField = AddComponent<TMP_InputField>(root);
|
||||
SetDefaultColorTransitionValues(inputField);
|
||||
|
||||
RectMask2D rectMask = AddComponent<RectMask2D>(textArea);
|
||||
rectMask.padding = new Vector4(-8, -5, -8, -5);
|
||||
|
||||
RectTransform textAreaRectTransform = textArea.GetComponent<RectTransform>();
|
||||
textAreaRectTransform.anchorMin = Vector2.zero;
|
||||
textAreaRectTransform.anchorMax = Vector2.one;
|
||||
textAreaRectTransform.sizeDelta = Vector2.zero;
|
||||
textAreaRectTransform.offsetMin = new Vector2(10, 6);
|
||||
textAreaRectTransform.offsetMax = new Vector2(-10, -7);
|
||||
|
||||
|
||||
TextMeshProUGUI text = AddComponent<TextMeshProUGUI>(childText);
|
||||
text.text = "";
|
||||
text.textWrappingMode = TextWrappingModes.NoWrap;
|
||||
text.extraPadding = true;
|
||||
text.richText = true;
|
||||
SetDefaultTextValues(text);
|
||||
|
||||
TextMeshProUGUI placeholder = AddComponent<TextMeshProUGUI>(childPlaceholder);
|
||||
placeholder.text = "Enter text...";
|
||||
placeholder.fontSize = 14;
|
||||
placeholder.fontStyle = FontStyles.Italic;
|
||||
placeholder.textWrappingMode = TextWrappingModes.NoWrap;
|
||||
placeholder.extraPadding = true;
|
||||
|
||||
// Make placeholder color half as opaque as normal text color.
|
||||
Color placeholderColor = text.color;
|
||||
placeholderColor.a *= 0.5f;
|
||||
placeholder.color = placeholderColor;
|
||||
|
||||
// Add Layout component to placeholder.
|
||||
AddComponent<LayoutElement>(placeholder.gameObject).ignoreLayout = true;
|
||||
|
||||
RectTransform textRectTransform = childText.GetComponent<RectTransform>();
|
||||
textRectTransform.anchorMin = Vector2.zero;
|
||||
textRectTransform.anchorMax = Vector2.one;
|
||||
textRectTransform.sizeDelta = Vector2.zero;
|
||||
textRectTransform.offsetMin = new Vector2(0, 0);
|
||||
textRectTransform.offsetMax = new Vector2(0, 0);
|
||||
|
||||
RectTransform placeholderRectTransform = childPlaceholder.GetComponent<RectTransform>();
|
||||
placeholderRectTransform.anchorMin = Vector2.zero;
|
||||
placeholderRectTransform.anchorMax = Vector2.one;
|
||||
placeholderRectTransform.sizeDelta = Vector2.zero;
|
||||
placeholderRectTransform.offsetMin = new Vector2(0, 0);
|
||||
placeholderRectTransform.offsetMax = new Vector2(0, 0);
|
||||
|
||||
inputField.textViewport = textAreaRectTransform;
|
||||
inputField.textComponent = text;
|
||||
inputField.placeholder = placeholder;
|
||||
inputField.fontAsset = text.font;
|
||||
|
||||
return root;
|
||||
}
|
||||
|
||||
public static GameObject CreateDropdown(Resources resources)
|
||||
{
|
||||
GameObject root = CreateUIElementRoot("Dropdown", s_ThickElementSize);
|
||||
|
||||
GameObject label = CreateUIObject("Label", root);
|
||||
GameObject arrow = CreateUIObject("Arrow", root);
|
||||
GameObject template = CreateUIObject("Template", root);
|
||||
GameObject viewport = CreateUIObject("Viewport", template);
|
||||
GameObject content = CreateUIObject("Content", viewport);
|
||||
GameObject item = CreateUIObject("Item", content);
|
||||
GameObject itemBackground = CreateUIObject("Item Background", item);
|
||||
GameObject itemCheckmark = CreateUIObject("Item Checkmark", item);
|
||||
GameObject itemLabel = CreateUIObject("Item Label", item);
|
||||
|
||||
// Sub controls.
|
||||
|
||||
GameObject scrollbar = CreateScrollbar(resources);
|
||||
scrollbar.name = "Scrollbar";
|
||||
SetParentAndAlign(scrollbar, template);
|
||||
|
||||
Scrollbar scrollbarScrollbar = scrollbar.GetComponent<Scrollbar>();
|
||||
scrollbarScrollbar.SetDirection(Scrollbar.Direction.BottomToTop, true);
|
||||
|
||||
RectTransform vScrollbarRT = scrollbar.GetComponent<RectTransform>();
|
||||
vScrollbarRT.anchorMin = Vector2.right;
|
||||
vScrollbarRT.anchorMax = Vector2.one;
|
||||
vScrollbarRT.pivot = Vector2.one;
|
||||
vScrollbarRT.sizeDelta = new Vector2(vScrollbarRT.sizeDelta.x, 0);
|
||||
|
||||
// Setup item UI components.
|
||||
|
||||
TextMeshProUGUI itemLabelText = AddComponent<TextMeshProUGUI>(itemLabel);
|
||||
SetDefaultTextValues(itemLabelText);
|
||||
itemLabelText.alignment = TextAlignmentOptions.Left;
|
||||
|
||||
Image itemBackgroundImage = AddComponent<Image>(itemBackground);
|
||||
itemBackgroundImage.color = new Color32(245, 245, 245, 255);
|
||||
|
||||
Image itemCheckmarkImage = AddComponent<Image>(itemCheckmark);
|
||||
itemCheckmarkImage.sprite = resources.checkmark;
|
||||
|
||||
Toggle itemToggle = AddComponent<Toggle>(item);
|
||||
itemToggle.targetGraphic = itemBackgroundImage;
|
||||
itemToggle.graphic = itemCheckmarkImage;
|
||||
itemToggle.isOn = true;
|
||||
|
||||
// Setup template UI components.
|
||||
|
||||
Image templateImage = AddComponent<Image>(template);
|
||||
templateImage.sprite = resources.standard;
|
||||
templateImage.type = Image.Type.Sliced;
|
||||
|
||||
ScrollRect templateScrollRect = AddComponent<ScrollRect>(template);
|
||||
templateScrollRect.content = (RectTransform)content.transform;
|
||||
templateScrollRect.viewport = (RectTransform)viewport.transform;
|
||||
templateScrollRect.horizontal = false;
|
||||
templateScrollRect.movementType = ScrollRect.MovementType.Clamped;
|
||||
templateScrollRect.verticalScrollbar = scrollbarScrollbar;
|
||||
templateScrollRect.verticalScrollbarVisibility = ScrollRect.ScrollbarVisibility.AutoHideAndExpandViewport;
|
||||
templateScrollRect.verticalScrollbarSpacing = -3;
|
||||
|
||||
Mask scrollRectMask = AddComponent<Mask>(viewport);
|
||||
scrollRectMask.showMaskGraphic = false;
|
||||
|
||||
Image viewportImage = AddComponent<Image>(viewport);
|
||||
viewportImage.sprite = resources.mask;
|
||||
viewportImage.type = Image.Type.Sliced;
|
||||
|
||||
// Setup dropdown UI components.
|
||||
|
||||
TextMeshProUGUI labelText = AddComponent<TextMeshProUGUI>(label);
|
||||
SetDefaultTextValues(labelText);
|
||||
labelText.alignment = TextAlignmentOptions.Left;
|
||||
|
||||
Image arrowImage = AddComponent<Image>(arrow);
|
||||
arrowImage.sprite = resources.dropdown;
|
||||
|
||||
Image backgroundImage = AddComponent<Image>(root);
|
||||
backgroundImage.sprite = resources.standard;
|
||||
backgroundImage.color = s_DefaultSelectableColor;
|
||||
backgroundImage.type = Image.Type.Sliced;
|
||||
|
||||
TMP_Dropdown dropdown = AddComponent<TMP_Dropdown>(root);
|
||||
dropdown.targetGraphic = backgroundImage;
|
||||
SetDefaultColorTransitionValues(dropdown);
|
||||
dropdown.template = template.GetComponent<RectTransform>();
|
||||
dropdown.captionText = labelText;
|
||||
dropdown.itemText = itemLabelText;
|
||||
|
||||
// Setting default Item list.
|
||||
itemLabelText.text = "Option A";
|
||||
dropdown.options.Add(new TMP_Dropdown.OptionData {text = "Option A" });
|
||||
dropdown.options.Add(new TMP_Dropdown.OptionData {text = "Option B" });
|
||||
dropdown.options.Add(new TMP_Dropdown.OptionData {text = "Option C" });
|
||||
dropdown.RefreshShownValue();
|
||||
|
||||
// Set up RectTransforms.
|
||||
|
||||
RectTransform labelRT = label.GetComponent<RectTransform>();
|
||||
labelRT.anchorMin = Vector2.zero;
|
||||
labelRT.anchorMax = Vector2.one;
|
||||
labelRT.offsetMin = new Vector2(10, 6);
|
||||
labelRT.offsetMax = new Vector2(-25, -7);
|
||||
|
||||
RectTransform arrowRT = arrow.GetComponent<RectTransform>();
|
||||
arrowRT.anchorMin = new Vector2(1, 0.5f);
|
||||
arrowRT.anchorMax = new Vector2(1, 0.5f);
|
||||
arrowRT.sizeDelta = new Vector2(20, 20);
|
||||
arrowRT.anchoredPosition = new Vector2(-15, 0);
|
||||
|
||||
RectTransform templateRT = template.GetComponent<RectTransform>();
|
||||
templateRT.anchorMin = new Vector2(0, 0);
|
||||
templateRT.anchorMax = new Vector2(1, 0);
|
||||
templateRT.pivot = new Vector2(0.5f, 1);
|
||||
templateRT.anchoredPosition = new Vector2(0, 2);
|
||||
templateRT.sizeDelta = new Vector2(0, 150);
|
||||
|
||||
RectTransform viewportRT = viewport.GetComponent<RectTransform>();
|
||||
viewportRT.anchorMin = new Vector2(0, 0);
|
||||
viewportRT.anchorMax = new Vector2(1, 1);
|
||||
viewportRT.sizeDelta = new Vector2(-18, 0);
|
||||
viewportRT.pivot = new Vector2(0, 1);
|
||||
|
||||
RectTransform contentRT = content.GetComponent<RectTransform>();
|
||||
contentRT.anchorMin = new Vector2(0f, 1);
|
||||
contentRT.anchorMax = new Vector2(1f, 1);
|
||||
contentRT.pivot = new Vector2(0.5f, 1);
|
||||
contentRT.anchoredPosition = new Vector2(0, 0);
|
||||
contentRT.sizeDelta = new Vector2(0, 28);
|
||||
|
||||
RectTransform itemRT = item.GetComponent<RectTransform>();
|
||||
itemRT.anchorMin = new Vector2(0, 0.5f);
|
||||
itemRT.anchorMax = new Vector2(1, 0.5f);
|
||||
itemRT.sizeDelta = new Vector2(0, 20);
|
||||
|
||||
RectTransform itemBackgroundRT = itemBackground.GetComponent<RectTransform>();
|
||||
itemBackgroundRT.anchorMin = Vector2.zero;
|
||||
itemBackgroundRT.anchorMax = Vector2.one;
|
||||
itemBackgroundRT.sizeDelta = Vector2.zero;
|
||||
|
||||
RectTransform itemCheckmarkRT = itemCheckmark.GetComponent<RectTransform>();
|
||||
itemCheckmarkRT.anchorMin = new Vector2(0, 0.5f);
|
||||
itemCheckmarkRT.anchorMax = new Vector2(0, 0.5f);
|
||||
itemCheckmarkRT.sizeDelta = new Vector2(20, 20);
|
||||
itemCheckmarkRT.anchoredPosition = new Vector2(10, 0);
|
||||
|
||||
RectTransform itemLabelRT = itemLabel.GetComponent<RectTransform>();
|
||||
itemLabelRT.anchorMin = Vector2.zero;
|
||||
itemLabelRT.anchorMax = Vector2.one;
|
||||
itemLabelRT.offsetMin = new Vector2(20, 1);
|
||||
itemLabelRT.offsetMax = new Vector2(-10, -2);
|
||||
|
||||
template.SetActive(false);
|
||||
|
||||
return root;
|
||||
}
|
||||
|
||||
private static T AddComponent<T>(GameObject go) where T : Component
|
||||
{
|
||||
#if UNITY_EDITOR
|
||||
return ObjectFactory.AddComponent<T>(go);
|
||||
#else
|
||||
return go.AddComponent<T>();
|
||||
#endif
|
||||
}
|
||||
}
|
||||
}
|
@@ -0,0 +1,12 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 322392995be44d23a3c86cfd972f838f
|
||||
timeCreated: 1446378357
|
||||
licenseType: Pro
|
||||
MonoImporter:
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 7b743370ac3e4ec2a1668f5455a8ef8a
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {fileID: 2800000, guid: a7ec9e7ad8b847b7ae4510af83c5d868, type: 3}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
@@ -0,0 +1,188 @@
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
using UnityEngine.TextCore.LowLevel;
|
||||
|
||||
|
||||
namespace TMPro
|
||||
{
|
||||
internal class TMP_DynamicFontAssetUtilities
|
||||
{
|
||||
private static TMP_DynamicFontAssetUtilities s_Instance = new TMP_DynamicFontAssetUtilities();
|
||||
|
||||
private Dictionary<ulong, FontReference> s_SystemFontLookup;
|
||||
private string[] s_SystemFontPaths;
|
||||
private uint s_RegularStyleNameHashCode = 1291372090;
|
||||
|
||||
public struct FontReference
|
||||
{
|
||||
public string familyName;
|
||||
public string styleName;
|
||||
public int faceIndex;
|
||||
public string filePath;
|
||||
public ulong hashCode;
|
||||
|
||||
/// <summary>
|
||||
/// Constructor for new FontReference
|
||||
/// </summary>
|
||||
/// <param name="faceNameAndStyle">String that combines the family name with style name</param>
|
||||
/// <param name="index">Index of the font face and style.</param>
|
||||
public FontReference(string fontFilePath, string faceNameAndStyle, int index)
|
||||
{
|
||||
familyName = null;
|
||||
styleName = null;
|
||||
faceIndex = index;
|
||||
uint familyNameHashCode = 0;
|
||||
uint styleNameHashCode = 0;
|
||||
filePath = fontFilePath;
|
||||
|
||||
int length = faceNameAndStyle.Length;
|
||||
char[] conversionArray = new char[length];
|
||||
|
||||
int readingFlag = 0;
|
||||
int writingIndex = 0;
|
||||
|
||||
for (int i = 0; i < length; i++)
|
||||
{
|
||||
char c = faceNameAndStyle[i];
|
||||
|
||||
// Read family name
|
||||
if (readingFlag == 0)
|
||||
{
|
||||
bool isSeparator = i + 2 < length && c == ' ' && faceNameAndStyle[i + 1] == '-' && faceNameAndStyle[i + 2] == ' ';
|
||||
|
||||
if (isSeparator)
|
||||
{
|
||||
readingFlag = 1;
|
||||
this.familyName = new string(conversionArray, 0, writingIndex);
|
||||
i += 2;
|
||||
writingIndex = 0;
|
||||
continue;
|
||||
}
|
||||
|
||||
familyNameHashCode = (familyNameHashCode << 5) + familyNameHashCode ^ TMP_TextUtilities.ToUpperFast(c);
|
||||
conversionArray[writingIndex++] = c;
|
||||
continue;
|
||||
}
|
||||
|
||||
// Read style name
|
||||
if (readingFlag == 1)
|
||||
{
|
||||
styleNameHashCode = (styleNameHashCode << 5) + styleNameHashCode ^ TMP_TextUtilities.ToUpperFast(c);
|
||||
conversionArray[writingIndex++] = c;
|
||||
|
||||
if (i + 1 == length)
|
||||
this.styleName = new string(conversionArray, 0, writingIndex);
|
||||
}
|
||||
}
|
||||
|
||||
hashCode = (ulong)styleNameHashCode << 32 | familyNameHashCode;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void InitializeSystemFontReferenceCache()
|
||||
{
|
||||
if (s_SystemFontLookup == null)
|
||||
s_SystemFontLookup = new Dictionary<ulong, FontReference>();
|
||||
else
|
||||
s_SystemFontLookup.Clear();
|
||||
|
||||
if (s_SystemFontPaths == null)
|
||||
s_SystemFontPaths = Font.GetPathsToOSFonts();
|
||||
|
||||
for (int i = 0; i < s_SystemFontPaths.Length; i++)
|
||||
{
|
||||
// Load font at the given path
|
||||
FontEngineError error = FontEngine.LoadFontFace(s_SystemFontPaths[i]);
|
||||
if (error != FontEngineError.Success)
|
||||
{
|
||||
Debug.LogWarning("Error [" + error + "] trying to load the font at path [" + s_SystemFontPaths[i] + "].");
|
||||
continue;
|
||||
}
|
||||
|
||||
// Get font faces and styles for this font
|
||||
string[] fontFaces = FontEngine.GetFontFaces();
|
||||
|
||||
// Iterate over each font face
|
||||
for (int j = 0; j < fontFaces.Length; j++)
|
||||
{
|
||||
FontReference fontRef = new FontReference(s_SystemFontPaths[i], fontFaces[j], j);
|
||||
|
||||
if (s_SystemFontLookup.ContainsKey(fontRef.hashCode))
|
||||
{
|
||||
//Debug.Log("<color=#FFFF80>[" + i + "]</color> Family Name <color=#FFFF80>[" + fontRef.familyName + "]</color> Style Name <color=#FFFF80>[" + fontRef.styleName + "]</color> Index [" + fontRef.faceIndex + "] HashCode [" + fontRef.hashCode + "] Path [" + fontRef.filePath + "].");
|
||||
continue;
|
||||
}
|
||||
|
||||
// Add font reference to lookup dictionary
|
||||
s_SystemFontLookup.Add(fontRef.hashCode, fontRef);
|
||||
|
||||
Debug.Log("[" + i + "] Family Name [" + fontRef.familyName + "] Style Name [" + fontRef.styleName + "] Index [" + fontRef.faceIndex + "] HashCode [" + fontRef.hashCode + "] Path [" + fontRef.filePath + "].");
|
||||
}
|
||||
|
||||
// Unload current font face.
|
||||
FontEngine.UnloadFontFace();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
/// <param name="familyName"></param>
|
||||
/// <param name="fontRef"></param>
|
||||
/// <returns></returns>
|
||||
public static bool TryGetSystemFontReference(string familyName, out FontReference fontRef)
|
||||
{
|
||||
return s_Instance.TryGetSystemFontReferenceInternal(familyName, null, out fontRef);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
/// <param name="familyName"></param>
|
||||
/// <param name="styleName"></param>
|
||||
/// <param name="fontRef"></param>
|
||||
/// <returns></returns>
|
||||
public static bool TryGetSystemFontReference(string familyName, string styleName, out FontReference fontRef)
|
||||
{
|
||||
return s_Instance.TryGetSystemFontReferenceInternal(familyName, styleName, out fontRef);
|
||||
}
|
||||
|
||||
bool TryGetSystemFontReferenceInternal(string familyName, string styleName, out FontReference fontRef)
|
||||
{
|
||||
if (s_SystemFontLookup == null)
|
||||
InitializeSystemFontReferenceCache();
|
||||
|
||||
fontRef = new FontReference();
|
||||
|
||||
// Compute family name hash code
|
||||
uint familyNameHashCode = TMP_TextUtilities.GetHashCodeCaseInSensitive(familyName);
|
||||
uint styleNameHashCode = string.IsNullOrEmpty(styleName) ? s_RegularStyleNameHashCode : TMP_TextUtilities.GetHashCodeCaseInSensitive(styleName);
|
||||
ulong key = (ulong)styleNameHashCode << 32 | familyNameHashCode;
|
||||
|
||||
// Lookup font reference
|
||||
if (s_SystemFontLookup.ContainsKey(key))
|
||||
{
|
||||
fontRef = s_SystemFontLookup[key];
|
||||
return true;
|
||||
}
|
||||
|
||||
// Return if specified family and style name is not found.
|
||||
if (styleNameHashCode != s_RegularStyleNameHashCode)
|
||||
return false;
|
||||
|
||||
// Return first potential reference for the given family name
|
||||
foreach (KeyValuePair<ulong, FontReference> pair in s_SystemFontLookup)
|
||||
{
|
||||
if (pair.Value.familyName == familyName)
|
||||
{
|
||||
fontRef = pair.Value;
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: aaf9006568d76504f982305b517fb490
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 71c1514a6bd24e1e882cebbe1904ce04
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {fileID: 2800000, guid: ee148e281f3c41c5b4ff5f8a5afe5a6c, type: 3}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
@@ -0,0 +1,465 @@
|
||||
using UnityEngine;
|
||||
using UnityEngine.Serialization;
|
||||
using UnityEngine.TextCore;
|
||||
using UnityEngine.TextCore.LowLevel;
|
||||
using System;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
|
||||
|
||||
namespace TMPro
|
||||
{
|
||||
/// <summary>
|
||||
/// Class that contains the basic information about the font.
|
||||
/// </summary>
|
||||
[Serializable]
|
||||
public class FaceInfo_Legacy
|
||||
{
|
||||
public string Name;
|
||||
public float PointSize;
|
||||
public float Scale;
|
||||
|
||||
public int CharacterCount;
|
||||
|
||||
public float LineHeight;
|
||||
public float Baseline;
|
||||
public float Ascender;
|
||||
public float CapHeight;
|
||||
public float Descender;
|
||||
public float CenterLine;
|
||||
|
||||
public float SuperscriptOffset;
|
||||
public float SubscriptOffset;
|
||||
public float SubSize;
|
||||
|
||||
public float Underline;
|
||||
public float UnderlineThickness;
|
||||
|
||||
public float strikethrough;
|
||||
public float strikethroughThickness;
|
||||
|
||||
public float TabWidth;
|
||||
|
||||
public float Padding;
|
||||
public float AtlasWidth;
|
||||
public float AtlasHeight;
|
||||
}
|
||||
|
||||
|
||||
// Class which contains the Glyph Info / Character definition for each character contained in the font asset.
|
||||
[Serializable]
|
||||
public class TMP_Glyph : TMP_TextElement_Legacy
|
||||
{
|
||||
/// <summary>
|
||||
/// Function to create a deep copy of a GlyphInfo.
|
||||
/// </summary>
|
||||
/// <param name="source"></param>
|
||||
/// <returns></returns>
|
||||
public static TMP_Glyph Clone(TMP_Glyph source)
|
||||
{
|
||||
TMP_Glyph copy = new TMP_Glyph();
|
||||
|
||||
copy.id = source.id;
|
||||
copy.x = source.x;
|
||||
copy.y = source.y;
|
||||
copy.width = source.width;
|
||||
copy.height = source.height;
|
||||
copy.xOffset = source.xOffset;
|
||||
copy.yOffset = source.yOffset;
|
||||
copy.xAdvance = source.xAdvance;
|
||||
copy.scale = source.scale;
|
||||
|
||||
return copy;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// Structure which holds the font creation settings
|
||||
[Serializable]
|
||||
public struct FontAssetCreationSettings
|
||||
{
|
||||
public string sourceFontFileName;
|
||||
public string sourceFontFileGUID;
|
||||
public int faceIndex;
|
||||
public int pointSizeSamplingMode;
|
||||
public int pointSize;
|
||||
public int padding;
|
||||
public int paddingMode;
|
||||
public int packingMode;
|
||||
public int atlasWidth;
|
||||
public int atlasHeight;
|
||||
public int characterSetSelectionMode;
|
||||
public string characterSequence;
|
||||
public string referencedFontAssetGUID;
|
||||
public string referencedTextAssetGUID;
|
||||
public int fontStyle;
|
||||
public float fontStyleModifier;
|
||||
public int renderMode;
|
||||
public bool includeFontFeatures;
|
||||
|
||||
internal FontAssetCreationSettings(string sourceFontFileGUID, int pointSize, int pointSizeSamplingMode, int padding, int packingMode, int atlasWidth, int atlasHeight, int characterSelectionMode, string characterSet, int renderMode)
|
||||
{
|
||||
this.sourceFontFileName = string.Empty;
|
||||
this.sourceFontFileGUID = sourceFontFileGUID;
|
||||
this.faceIndex = 0;
|
||||
this.pointSize = pointSize;
|
||||
this.pointSizeSamplingMode = pointSizeSamplingMode;
|
||||
this.padding = padding;
|
||||
this.paddingMode = 2;
|
||||
this.packingMode = packingMode;
|
||||
this.atlasWidth = atlasWidth;
|
||||
this.atlasHeight = atlasHeight;
|
||||
this.characterSequence = characterSet;
|
||||
this.characterSetSelectionMode = characterSelectionMode;
|
||||
this.renderMode = renderMode;
|
||||
|
||||
this.referencedFontAssetGUID = string.Empty;
|
||||
this.referencedTextAssetGUID = string.Empty;
|
||||
this.fontStyle = 0;
|
||||
this.fontStyleModifier = 0;
|
||||
this.includeFontFeatures = false;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Contains the font assets for the regular and italic styles associated with a given font weight.
|
||||
/// </summary>
|
||||
[Serializable]
|
||||
public struct TMP_FontWeightPair
|
||||
{
|
||||
public TMP_FontAsset regularTypeface;
|
||||
public TMP_FontAsset italicTypeface;
|
||||
}
|
||||
|
||||
|
||||
public struct KerningPairKey
|
||||
{
|
||||
public uint ascii_Left;
|
||||
public uint ascii_Right;
|
||||
public uint key;
|
||||
|
||||
public KerningPairKey(uint ascii_left, uint ascii_right)
|
||||
{
|
||||
ascii_Left = ascii_left;
|
||||
ascii_Right = ascii_right;
|
||||
key = (ascii_right << 16) + ascii_left;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Positional adjustments of a glyph
|
||||
/// </summary>
|
||||
[Serializable]
|
||||
public struct GlyphValueRecord_Legacy
|
||||
{
|
||||
public float xPlacement;
|
||||
public float yPlacement;
|
||||
public float xAdvance;
|
||||
public float yAdvance;
|
||||
|
||||
internal GlyphValueRecord_Legacy(UnityEngine.TextCore.LowLevel.GlyphValueRecord valueRecord)
|
||||
{
|
||||
this.xPlacement = valueRecord.xPlacement;
|
||||
this.yPlacement = valueRecord.yPlacement;
|
||||
this.xAdvance = valueRecord.xAdvance;
|
||||
this.yAdvance = valueRecord.yAdvance;
|
||||
}
|
||||
|
||||
public static GlyphValueRecord_Legacy operator +(GlyphValueRecord_Legacy a, GlyphValueRecord_Legacy b)
|
||||
{
|
||||
GlyphValueRecord_Legacy c;
|
||||
c.xPlacement = a.xPlacement + b.xPlacement;
|
||||
c.yPlacement = a.yPlacement + b.yPlacement;
|
||||
c.xAdvance = a.xAdvance + b.xAdvance;
|
||||
c.yAdvance = a.yAdvance + b.yAdvance;
|
||||
|
||||
return c;
|
||||
}
|
||||
}
|
||||
|
||||
[Serializable]
|
||||
public class KerningPair
|
||||
{
|
||||
/// <summary>
|
||||
/// The first glyph part of a kerning pair.
|
||||
/// </summary>
|
||||
public uint firstGlyph
|
||||
{
|
||||
get { return m_FirstGlyph; }
|
||||
set { m_FirstGlyph = value; }
|
||||
}
|
||||
[FormerlySerializedAs("AscII_Left")]
|
||||
[SerializeField]
|
||||
private uint m_FirstGlyph;
|
||||
|
||||
/// <summary>
|
||||
/// The positional adjustment of the first glyph.
|
||||
/// </summary>
|
||||
public GlyphValueRecord_Legacy firstGlyphAdjustments
|
||||
{
|
||||
get { return m_FirstGlyphAdjustments; }
|
||||
}
|
||||
[SerializeField]
|
||||
private GlyphValueRecord_Legacy m_FirstGlyphAdjustments;
|
||||
|
||||
/// <summary>
|
||||
/// The second glyph part of a kerning pair.
|
||||
/// </summary>
|
||||
public uint secondGlyph
|
||||
{
|
||||
get { return m_SecondGlyph; }
|
||||
set { m_SecondGlyph = value; }
|
||||
}
|
||||
[FormerlySerializedAs("AscII_Right")]
|
||||
[SerializeField]
|
||||
private uint m_SecondGlyph;
|
||||
|
||||
/// <summary>
|
||||
/// The positional adjustment of the second glyph.
|
||||
/// </summary>
|
||||
public GlyphValueRecord_Legacy secondGlyphAdjustments
|
||||
{
|
||||
get { return m_SecondGlyphAdjustments; }
|
||||
}
|
||||
[SerializeField]
|
||||
private GlyphValueRecord_Legacy m_SecondGlyphAdjustments;
|
||||
|
||||
[FormerlySerializedAs("XadvanceOffset")]
|
||||
public float xOffset;
|
||||
|
||||
internal static KerningPair empty = new KerningPair(0, new GlyphValueRecord_Legacy(), 0, new GlyphValueRecord_Legacy());
|
||||
|
||||
/// <summary>
|
||||
/// Determines if the Character Spacing property of the text object will affect the kerning pair.
|
||||
/// This is mostly relevant when using Diacritical marks to prevent Character Spacing from altering the spacing.
|
||||
/// </summary>
|
||||
public bool ignoreSpacingAdjustments
|
||||
{
|
||||
get { return m_IgnoreSpacingAdjustments; }
|
||||
}
|
||||
[SerializeField]
|
||||
private bool m_IgnoreSpacingAdjustments = false;
|
||||
|
||||
public KerningPair()
|
||||
{
|
||||
m_FirstGlyph = 0;
|
||||
m_FirstGlyphAdjustments = new GlyphValueRecord_Legacy();
|
||||
|
||||
m_SecondGlyph = 0;
|
||||
m_SecondGlyphAdjustments = new GlyphValueRecord_Legacy();
|
||||
}
|
||||
|
||||
public KerningPair(uint left, uint right, float offset)
|
||||
{
|
||||
firstGlyph = left;
|
||||
m_SecondGlyph = right;
|
||||
xOffset = offset;
|
||||
}
|
||||
|
||||
public KerningPair(uint firstGlyph, GlyphValueRecord_Legacy firstGlyphAdjustments, uint secondGlyph, GlyphValueRecord_Legacy secondGlyphAdjustments)
|
||||
{
|
||||
m_FirstGlyph = firstGlyph;
|
||||
m_FirstGlyphAdjustments = firstGlyphAdjustments;
|
||||
m_SecondGlyph = secondGlyph;
|
||||
m_SecondGlyphAdjustments = secondGlyphAdjustments;
|
||||
}
|
||||
|
||||
internal void ConvertLegacyKerningData()
|
||||
{
|
||||
m_FirstGlyphAdjustments.xAdvance = xOffset;
|
||||
//xOffset = 0;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
[Serializable]
|
||||
public class KerningTable
|
||||
{
|
||||
public List<KerningPair> kerningPairs;
|
||||
|
||||
public KerningTable()
|
||||
{
|
||||
kerningPairs = new List<KerningPair>();
|
||||
}
|
||||
|
||||
|
||||
public void AddKerningPair()
|
||||
{
|
||||
if (kerningPairs.Count == 0)
|
||||
{
|
||||
kerningPairs.Add(new KerningPair(0, 0, 0));
|
||||
}
|
||||
else
|
||||
{
|
||||
uint left = kerningPairs.Last().firstGlyph;
|
||||
uint right = kerningPairs.Last().secondGlyph;
|
||||
float xoffset = kerningPairs.Last().xOffset;
|
||||
|
||||
kerningPairs.Add(new KerningPair(left, right, xoffset));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Add Kerning Pair
|
||||
/// </summary>
|
||||
/// <param name="first">First glyph</param>
|
||||
/// <param name="second">Second glyph</param>
|
||||
/// <param name="offset">xAdvance value</param>
|
||||
/// <returns></returns>
|
||||
public int AddKerningPair(uint first, uint second, float offset)
|
||||
{
|
||||
int index = kerningPairs.FindIndex(item => item.firstGlyph == first && item.secondGlyph == second);
|
||||
|
||||
if (index == -1)
|
||||
{
|
||||
kerningPairs.Add(new KerningPair(first, second, offset));
|
||||
return 0;
|
||||
}
|
||||
|
||||
// Return -1 if Kerning Pair already exists.
|
||||
return -1;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Add Glyph pair adjustment record
|
||||
/// </summary>
|
||||
/// <param name="firstGlyph">The first glyph</param>
|
||||
/// <param name="firstGlyphAdjustments">Adjustment record for the first glyph</param>
|
||||
/// <param name="secondGlyph">The second glyph</param>
|
||||
/// <param name="secondGlyphAdjustments">Adjustment record for the second glyph</param>
|
||||
/// <returns></returns>
|
||||
public int AddGlyphPairAdjustmentRecord(uint first, GlyphValueRecord_Legacy firstAdjustments, uint second, GlyphValueRecord_Legacy secondAdjustments)
|
||||
{
|
||||
int index = kerningPairs.FindIndex(item => item.firstGlyph == first && item.secondGlyph == second);
|
||||
|
||||
if (index == -1)
|
||||
{
|
||||
kerningPairs.Add(new KerningPair(first, firstAdjustments, second, secondAdjustments));
|
||||
return 0;
|
||||
}
|
||||
|
||||
// Return -1 if Kerning Pair already exists.
|
||||
return -1;
|
||||
}
|
||||
|
||||
public void RemoveKerningPair(int left, int right)
|
||||
{
|
||||
int index = kerningPairs.FindIndex(item => item.firstGlyph == left && item.secondGlyph == right);
|
||||
|
||||
if (index != -1)
|
||||
kerningPairs.RemoveAt(index);
|
||||
}
|
||||
|
||||
|
||||
public void RemoveKerningPair(int index)
|
||||
{
|
||||
kerningPairs.RemoveAt(index);
|
||||
}
|
||||
|
||||
|
||||
public void SortKerningPairs()
|
||||
{
|
||||
// Sort List of Kerning Info
|
||||
if (kerningPairs.Count > 0)
|
||||
kerningPairs = kerningPairs.OrderBy(s => s.firstGlyph).ThenBy(s => s.secondGlyph).ToList();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public static class TMP_FontUtilities
|
||||
{
|
||||
private static List<int> k_searchedFontAssets;
|
||||
|
||||
/// <summary>
|
||||
/// Search through the given font and its fallbacks for the specified character.
|
||||
/// </summary>
|
||||
/// <param name="font">The font asset to search for the given character.</param>
|
||||
/// <param name="unicode">The character to find.</param>
|
||||
/// <param name="character">out parameter containing the glyph for the specified character (if found).</param>
|
||||
/// <returns></returns>
|
||||
public static TMP_FontAsset SearchForCharacter(TMP_FontAsset font, uint unicode, out TMP_Character character)
|
||||
{
|
||||
if (k_searchedFontAssets == null)
|
||||
k_searchedFontAssets = new List<int>();
|
||||
|
||||
k_searchedFontAssets.Clear();
|
||||
|
||||
return SearchForCharacterInternal(font, unicode, out character);
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Search through the given list of fonts and their possible fallbacks for the specified character.
|
||||
/// </summary>
|
||||
/// <param name="fonts"></param>
|
||||
/// <param name="unicode"></param>
|
||||
/// <param name="character"></param>
|
||||
/// <returns></returns>
|
||||
public static TMP_FontAsset SearchForCharacter(List<TMP_FontAsset> fonts, uint unicode, out TMP_Character character)
|
||||
{
|
||||
return SearchForCharacterInternal(fonts, unicode, out character);
|
||||
}
|
||||
|
||||
|
||||
private static TMP_FontAsset SearchForCharacterInternal(TMP_FontAsset font, uint unicode, out TMP_Character character)
|
||||
{
|
||||
character = null;
|
||||
|
||||
if (font == null) return null;
|
||||
|
||||
if (font.characterLookupTable.TryGetValue(unicode, out character))
|
||||
{
|
||||
if (character.textAsset != null)
|
||||
return font;
|
||||
|
||||
// Remove character from lookup table
|
||||
font.characterLookupTable.Remove(unicode);
|
||||
}
|
||||
|
||||
if (font.fallbackFontAssetTable != null && font.fallbackFontAssetTable.Count > 0)
|
||||
{
|
||||
for (int i = 0; i < font.fallbackFontAssetTable.Count && character == null; i++)
|
||||
{
|
||||
TMP_FontAsset temp = font.fallbackFontAssetTable[i];
|
||||
if (temp == null) continue;
|
||||
|
||||
int id = temp.GetInstanceID();
|
||||
|
||||
// Skip over the fallback font asset in the event it is null or if already searched.
|
||||
if (k_searchedFontAssets.Contains(id)) continue;
|
||||
|
||||
// Add to list of font assets already searched.
|
||||
k_searchedFontAssets.Add(id);
|
||||
|
||||
temp = SearchForCharacterInternal(temp, unicode, out character);
|
||||
|
||||
if (temp != null)
|
||||
return temp;
|
||||
}
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
private static TMP_FontAsset SearchForCharacterInternal(List<TMP_FontAsset> fonts, uint unicode, out TMP_Character character)
|
||||
{
|
||||
character = null;
|
||||
|
||||
if (fonts != null && fonts.Count > 0)
|
||||
{
|
||||
for (int i = 0; i < fonts.Count; i++)
|
||||
{
|
||||
TMP_FontAsset fontAsset = SearchForCharacterInternal(fonts[i], unicode, out character);
|
||||
|
||||
if (fontAsset != null)
|
||||
return fontAsset;
|
||||
}
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
@@ -0,0 +1,10 @@
|
||||
fileFormatVersion: 2
|
||||
guid: f695b5f9415c40b39ae877eaff41c96e
|
||||
MonoImporter:
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
@@ -0,0 +1,497 @@
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine.TextCore;
|
||||
using UnityEngine.TextCore.LowLevel;
|
||||
|
||||
|
||||
namespace TMPro
|
||||
{
|
||||
public class TMP_FontAssetUtilities
|
||||
{
|
||||
private static readonly TMP_FontAssetUtilities s_Instance = new TMP_FontAssetUtilities();
|
||||
|
||||
/// <summary>
|
||||
/// Default constructor
|
||||
/// </summary>
|
||||
static TMP_FontAssetUtilities() { }
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Get a singleton instance of the Font Asset Utilities class.
|
||||
/// </summary>
|
||||
public static TMP_FontAssetUtilities instance
|
||||
{
|
||||
get { return s_Instance; }
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// HashSet containing instance ID of font assets already searched.
|
||||
/// </summary>
|
||||
private static HashSet<int> k_SearchedAssets;
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Returns the text element (character) for the given unicode value taking into consideration the requested font style and weight.
|
||||
/// Function searches the source font asset, its list of font assets assigned as alternative typefaces and potentially its fallbacks.
|
||||
/// The font asset out parameter contains a reference to the font asset containing the character.
|
||||
/// The typeface type indicates whether the returned font asset is the source font asset, an alternative typeface or fallback font asset.
|
||||
/// </summary>
|
||||
/// <param name="unicode">The unicode value of the requested character</param>
|
||||
/// <param name="sourceFontAsset">The font asset to be searched</param>
|
||||
/// <param name="includeFallbacks">Include the fallback font assets in the search</param>
|
||||
/// <param name="fontStyle">The font style</param>
|
||||
/// <param name="fontWeight">The font weight</param>
|
||||
/// <param name="isAlternativeTypeface">Indicates if the OUT font asset is an alternative typeface or fallback font asset</param>
|
||||
/// <param name="fontAsset">The font asset that contains the requested character</param>
|
||||
/// <returns></returns>
|
||||
public static TMP_Character GetCharacterFromFontAsset(uint unicode, TMP_FontAsset sourceFontAsset, bool includeFallbacks, FontStyles fontStyle, FontWeight fontWeight, out bool isAlternativeTypeface)
|
||||
{
|
||||
if (includeFallbacks)
|
||||
{
|
||||
if (k_SearchedAssets == null)
|
||||
k_SearchedAssets = new HashSet<int>();
|
||||
else
|
||||
k_SearchedAssets.Clear();
|
||||
}
|
||||
|
||||
return GetCharacterFromFontAsset_Internal(unicode, sourceFontAsset, includeFallbacks, fontStyle, fontWeight, out isAlternativeTypeface);
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Internal function returning the text element character for the given unicode value taking into consideration the font style and weight.
|
||||
/// Function searches the source font asset, list of font assets assigned as alternative typefaces and list of fallback font assets.
|
||||
/// </summary>
|
||||
private static TMP_Character GetCharacterFromFontAsset_Internal(uint unicode, TMP_FontAsset sourceFontAsset, bool includeFallbacks, FontStyles fontStyle, FontWeight fontWeight, out bool isAlternativeTypeface)
|
||||
{
|
||||
isAlternativeTypeface = false;
|
||||
TMP_Character character = null;
|
||||
|
||||
#region FONT WEIGHT AND FONT STYLE HANDLING
|
||||
// Determine if a font weight or style is used. If so check if an alternative typeface is assigned for the given weight and / or style.
|
||||
bool isItalic = (fontStyle & FontStyles.Italic) == FontStyles.Italic;
|
||||
|
||||
if (isItalic || fontWeight != FontWeight.Regular)
|
||||
{
|
||||
// Get reference to the font weight pairs of the given font asset.
|
||||
TMP_FontWeightPair[] fontWeights = sourceFontAsset.fontWeightTable;
|
||||
|
||||
int fontWeightIndex = 4;
|
||||
switch (fontWeight)
|
||||
{
|
||||
case FontWeight.Thin:
|
||||
fontWeightIndex = 1;
|
||||
break;
|
||||
case FontWeight.ExtraLight:
|
||||
fontWeightIndex = 2;
|
||||
break;
|
||||
case FontWeight.Light:
|
||||
fontWeightIndex = 3;
|
||||
break;
|
||||
case FontWeight.Regular:
|
||||
fontWeightIndex = 4;
|
||||
break;
|
||||
case FontWeight.Medium:
|
||||
fontWeightIndex = 5;
|
||||
break;
|
||||
case FontWeight.SemiBold:
|
||||
fontWeightIndex = 6;
|
||||
break;
|
||||
case FontWeight.Bold:
|
||||
fontWeightIndex = 7;
|
||||
break;
|
||||
case FontWeight.Heavy:
|
||||
fontWeightIndex = 8;
|
||||
break;
|
||||
case FontWeight.Black:
|
||||
fontWeightIndex = 9;
|
||||
break;
|
||||
}
|
||||
|
||||
TMP_FontAsset temp = isItalic ? fontWeights[fontWeightIndex].italicTypeface : fontWeights[fontWeightIndex].regularTypeface;
|
||||
|
||||
if (temp != null)
|
||||
{
|
||||
if (temp.characterLookupTable.TryGetValue(unicode, out character))
|
||||
{
|
||||
if (character.textAsset != null)
|
||||
{
|
||||
isAlternativeTypeface = true;
|
||||
return character;
|
||||
}
|
||||
|
||||
// Remove character from lookup table
|
||||
temp.characterLookupTable.Remove(unicode);
|
||||
}
|
||||
|
||||
if (temp.atlasPopulationMode == AtlasPopulationMode.Dynamic || temp.atlasPopulationMode == AtlasPopulationMode.DynamicOS)
|
||||
{
|
||||
if (temp.TryAddCharacterInternal(unicode, out character))
|
||||
{
|
||||
isAlternativeTypeface = true;
|
||||
|
||||
return character;
|
||||
}
|
||||
|
||||
// Check if the source font file contains the requested character.
|
||||
//if (TryGetCharacterFromFontFile(unicode, fontAsset, out characterData))
|
||||
//{
|
||||
// isAlternativeTypeface = true;
|
||||
|
||||
// return characterData;
|
||||
//}
|
||||
|
||||
// If we find the requested character, we add it to the font asset character table
|
||||
// and return its character data.
|
||||
// We also add this character to the list of characters we will need to add to the font atlas.
|
||||
// We assume the font atlas has room otherwise this font asset should not be marked as dynamic.
|
||||
// Alternatively, we could also add multiple pages of font atlas textures (feature consideration).
|
||||
}
|
||||
|
||||
// At this point, we were not able to find the requested character in the alternative typeface
|
||||
// so we check the source font asset and its potential fallbacks.
|
||||
}
|
||||
}
|
||||
#endregion
|
||||
|
||||
// Search the source font asset for the requested character.
|
||||
if (sourceFontAsset.characterLookupTable.TryGetValue(unicode, out character))
|
||||
{
|
||||
if (character.textAsset != null)
|
||||
return character;
|
||||
|
||||
// Remove character from lookup table
|
||||
sourceFontAsset.characterLookupTable.Remove(unicode);
|
||||
}
|
||||
|
||||
if (sourceFontAsset.atlasPopulationMode == AtlasPopulationMode.Dynamic || sourceFontAsset.atlasPopulationMode == AtlasPopulationMode.DynamicOS)
|
||||
{
|
||||
if (sourceFontAsset.TryAddCharacterInternal(unicode, out character))
|
||||
return character;
|
||||
}
|
||||
|
||||
// Search fallback font assets if we still don't have a valid character and include fallback is set to true.
|
||||
if (character == null && includeFallbacks && sourceFontAsset.fallbackFontAssetTable != null)
|
||||
{
|
||||
// Get reference to the list of fallback font assets.
|
||||
List<TMP_FontAsset> fallbackFontAssets = sourceFontAsset.fallbackFontAssetTable;
|
||||
int fallbackCount = fallbackFontAssets.Count;
|
||||
|
||||
if (fallbackCount == 0)
|
||||
return null;
|
||||
|
||||
for (int i = 0; i < fallbackCount; i++)
|
||||
{
|
||||
TMP_FontAsset temp = fallbackFontAssets[i];
|
||||
|
||||
if (temp == null)
|
||||
continue;
|
||||
|
||||
int id = temp.instanceID;
|
||||
|
||||
// Try adding font asset to search list. If already present skip to the next one otherwise check if it contains the requested character.
|
||||
if (k_SearchedAssets.Add(id) == false)
|
||||
continue;
|
||||
|
||||
// Add reference to this search query
|
||||
//sourceFontAsset.FallbackSearchQueryLookup.Add(id);
|
||||
|
||||
character = GetCharacterFromFontAsset_Internal(unicode, temp, true, fontStyle, fontWeight, out isAlternativeTypeface);
|
||||
|
||||
if (character != null)
|
||||
return character;
|
||||
}
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Returns the text element (character) for the given unicode value taking into consideration the requested font style and weight.
|
||||
/// Function searches the provided list of font assets, the list of font assets assigned as alternative typefaces to them as well as their fallbacks.
|
||||
/// The font asset out parameter contains a reference to the font asset containing the character.
|
||||
/// The typeface type indicates whether the returned font asset is the source font asset, an alternative typeface or fallback font asset.
|
||||
/// </summary>
|
||||
/// <param name="unicode">The unicode value of the requested character</param>
|
||||
/// <param name="sourceFontAsset">The font asset originating the search query</param>
|
||||
/// <param name="fontAssets">The list of font assets to search</param>
|
||||
/// <param name="includeFallbacks">Determines if the fallback of each font assets on the list will be searched</param>
|
||||
/// <param name="fontStyle">The font style</param>
|
||||
/// <param name="fontWeight">The font weight</param>
|
||||
/// <param name="isAlternativeTypeface">Determines if the OUT font asset is an alternative typeface or fallback font asset</param>
|
||||
/// <returns></returns>
|
||||
public static TMP_Character GetCharacterFromFontAssets(uint unicode, TMP_FontAsset sourceFontAsset, List<TMP_FontAsset> fontAssets, bool includeFallbacks, FontStyles fontStyle, FontWeight fontWeight, out bool isAlternativeTypeface)
|
||||
{
|
||||
isAlternativeTypeface = false;
|
||||
|
||||
// Make sure font asset list is valid
|
||||
if (fontAssets == null || fontAssets.Count == 0)
|
||||
return null;
|
||||
|
||||
if (includeFallbacks)
|
||||
{
|
||||
if (k_SearchedAssets == null)
|
||||
k_SearchedAssets = new HashSet<int>();
|
||||
else
|
||||
k_SearchedAssets.Clear();
|
||||
}
|
||||
|
||||
int fontAssetCount = fontAssets.Count;
|
||||
|
||||
for (int i = 0; i < fontAssetCount; i++)
|
||||
{
|
||||
TMP_FontAsset fontAsset = fontAssets[i];
|
||||
|
||||
if (fontAsset == null) continue;
|
||||
|
||||
// Add reference to this search query
|
||||
//sourceFontAsset.FallbackSearchQueryLookup.Add(fontAsset.instanceID);
|
||||
|
||||
TMP_Character character = GetCharacterFromFontAsset_Internal(unicode, fontAsset, includeFallbacks, fontStyle, fontWeight, out isAlternativeTypeface);
|
||||
|
||||
if (character != null)
|
||||
return character;
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
internal static TMP_TextElement GetTextElementFromTextAssets(uint unicode, TMP_FontAsset sourceFontAsset, List<TMP_Asset> textAssets, bool includeFallbacks, FontStyles fontStyle, FontWeight fontWeight, out bool isAlternativeTypeface)
|
||||
{
|
||||
isAlternativeTypeface = false;
|
||||
|
||||
// Make sure font asset list is valid
|
||||
if (textAssets == null || textAssets.Count == 0)
|
||||
return null;
|
||||
|
||||
if (includeFallbacks)
|
||||
{
|
||||
if (k_SearchedAssets == null)
|
||||
k_SearchedAssets = new HashSet<int>();
|
||||
else
|
||||
k_SearchedAssets.Clear();
|
||||
}
|
||||
|
||||
int textAssetCount = textAssets.Count;
|
||||
|
||||
for (int i = 0; i < textAssetCount; i++)
|
||||
{
|
||||
TMP_Asset textAsset = textAssets[i];
|
||||
|
||||
if (textAsset == null) continue;
|
||||
|
||||
if (textAsset.GetType() == typeof(TMP_FontAsset))
|
||||
{
|
||||
TMP_FontAsset fontAsset = textAsset as TMP_FontAsset;
|
||||
TMP_Character character = GetCharacterFromFontAsset_Internal(unicode, fontAsset, includeFallbacks, fontStyle, fontWeight, out isAlternativeTypeface);
|
||||
|
||||
if (character != null)
|
||||
return character;
|
||||
}
|
||||
else
|
||||
{
|
||||
TMP_SpriteAsset spriteAsset = textAsset as TMP_SpriteAsset;
|
||||
TMP_SpriteCharacter spriteCharacter = GetSpriteCharacterFromSpriteAsset_Internal(unicode, spriteAsset, true);
|
||||
|
||||
if (spriteCharacter != null)
|
||||
return spriteCharacter;
|
||||
}
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
// =====================================================================
|
||||
// SPRITE ASSET - Functions
|
||||
// =====================================================================
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
/// <param name="unicode"></param>
|
||||
/// <param name="spriteAsset"></param>
|
||||
/// <param name="includeFallbacks"></param>
|
||||
/// <returns></returns>
|
||||
public static TMP_SpriteCharacter GetSpriteCharacterFromSpriteAsset(uint unicode, TMP_SpriteAsset spriteAsset, bool includeFallbacks)
|
||||
{
|
||||
// Make sure we have a valid sprite asset to search
|
||||
if (spriteAsset == null)
|
||||
return null;
|
||||
|
||||
TMP_SpriteCharacter spriteCharacter;
|
||||
|
||||
// Search sprite asset for potential sprite character for the given unicode value
|
||||
if (spriteAsset.spriteCharacterLookupTable.TryGetValue(unicode, out spriteCharacter))
|
||||
return spriteCharacter;
|
||||
|
||||
if (includeFallbacks)
|
||||
{
|
||||
// Clear searched assets
|
||||
if (k_SearchedAssets == null)
|
||||
k_SearchedAssets = new HashSet<int>();
|
||||
else
|
||||
k_SearchedAssets.Clear();
|
||||
|
||||
// Add current sprite asset to already searched assets.
|
||||
k_SearchedAssets.Add(spriteAsset.instanceID);
|
||||
|
||||
List<TMP_SpriteAsset> fallbackSpriteAsset = spriteAsset.fallbackSpriteAssets;
|
||||
|
||||
if (fallbackSpriteAsset != null && fallbackSpriteAsset.Count > 0)
|
||||
{
|
||||
int fallbackCount = fallbackSpriteAsset.Count;
|
||||
|
||||
for (int i = 0; i < fallbackCount; i++)
|
||||
{
|
||||
TMP_SpriteAsset temp = fallbackSpriteAsset[i];
|
||||
|
||||
if (temp == null)
|
||||
continue;
|
||||
|
||||
int id = temp.instanceID;
|
||||
|
||||
// Try adding asset to search list. If already present skip to the next one otherwise check if it contains the requested character.
|
||||
if (k_SearchedAssets.Add(id) == false)
|
||||
continue;
|
||||
|
||||
spriteCharacter = GetSpriteCharacterFromSpriteAsset_Internal(unicode, temp, true);
|
||||
|
||||
if (spriteCharacter != null)
|
||||
return spriteCharacter;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
/// <param name="unicode"></param>
|
||||
/// <param name="spriteAsset"></param>
|
||||
/// <param name="includeFallbacks"></param>
|
||||
/// <returns></returns>
|
||||
static TMP_SpriteCharacter GetSpriteCharacterFromSpriteAsset_Internal(uint unicode, TMP_SpriteAsset spriteAsset, bool includeFallbacks)
|
||||
{
|
||||
TMP_SpriteCharacter spriteCharacter;
|
||||
|
||||
// Search sprite asset for potential sprite character for the given unicode value
|
||||
if (spriteAsset.spriteCharacterLookupTable.TryGetValue(unicode, out spriteCharacter))
|
||||
return spriteCharacter;
|
||||
|
||||
if (includeFallbacks)
|
||||
{
|
||||
List<TMP_SpriteAsset> fallbackSpriteAsset = spriteAsset.fallbackSpriteAssets;
|
||||
|
||||
if (fallbackSpriteAsset != null && fallbackSpriteAsset.Count > 0)
|
||||
{
|
||||
int fallbackCount = fallbackSpriteAsset.Count;
|
||||
|
||||
for (int i = 0; i < fallbackCount; i++)
|
||||
{
|
||||
TMP_SpriteAsset temp = fallbackSpriteAsset[i];
|
||||
|
||||
if (temp == null)
|
||||
continue;
|
||||
|
||||
int id = temp.instanceID;
|
||||
|
||||
// Try adding asset to search list. If already present skip to the next one otherwise check if it contains the requested character.
|
||||
if (k_SearchedAssets.Add(id) == false)
|
||||
continue;
|
||||
|
||||
spriteCharacter = GetSpriteCharacterFromSpriteAsset_Internal(unicode, temp, true);
|
||||
|
||||
if (spriteCharacter != null)
|
||||
return spriteCharacter;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
// =====================================================================
|
||||
// FONT ENGINE & FONT FILE MANAGEMENT - Fields, Properties and Functions
|
||||
// =====================================================================
|
||||
|
||||
/*
|
||||
private static bool k_IsFontEngineInitialized;
|
||||
|
||||
private static bool TryGetCharacterFromFontFile(uint unicode, TMP_FontAsset fontAsset, out TMP_Character character)
|
||||
{
|
||||
character = null;
|
||||
|
||||
// Initialize Font Engine library if not already initialized
|
||||
if (k_IsFontEngineInitialized == false)
|
||||
{
|
||||
FontEngineError error = FontEngine.InitializeFontEngine();
|
||||
|
||||
if (error == 0)
|
||||
k_IsFontEngineInitialized = true;
|
||||
}
|
||||
|
||||
// Load the font face for the given font asset.
|
||||
// TODO: Add manager to keep track of which font faces are currently loaded.
|
||||
FontEngine.LoadFontFace(fontAsset.sourceFontFile, fontAsset.faceInfo.pointSize);
|
||||
|
||||
Glyph glyph = null;
|
||||
uint glyphIndex = FontEngine.GetGlyphIndex(unicode);
|
||||
|
||||
// Check if glyph is already contained in the font asset as the same glyph might be referenced by multiple character.
|
||||
if (fontAsset.glyphLookupTable.TryGetValue(glyphIndex, out glyph))
|
||||
{
|
||||
character = fontAsset.AddCharacter_Internal(unicode, glyph);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
GlyphLoadFlags glyphLoadFlags = ((GlyphRasterModes)fontAsset.atlasRenderMode & GlyphRasterModes.RASTER_MODE_HINTED) == GlyphRasterModes.RASTER_MODE_HINTED ? GlyphLoadFlags.LOAD_RENDER : GlyphLoadFlags.LOAD_RENDER | GlyphLoadFlags.LOAD_NO_HINTING;
|
||||
|
||||
if (FontEngine.TryGetGlyphWithUnicodeValue(unicode, glyphLoadFlags, out glyph))
|
||||
{
|
||||
// Add new character to font asset (if needed)
|
||||
character = fontAsset.AddCharacter_Internal(unicode, glyph);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
public static bool TryGetGlyphFromFontFile(uint glyphIndex, TMP_FontAsset fontAsset, out Glyph glyph)
|
||||
{
|
||||
glyph = null;
|
||||
|
||||
// Initialize Font Engine library if not already initialized
|
||||
if (k_IsFontEngineInitialized == false)
|
||||
{
|
||||
FontEngineError error = FontEngine.InitializeFontEngine();
|
||||
|
||||
if (error == 0)
|
||||
k_IsFontEngineInitialized = true;
|
||||
}
|
||||
|
||||
// Load the font face for the given font asset.
|
||||
// TODO: Add manager to keep track of which font faces are currently loaded.
|
||||
FontEngine.LoadFontFace(fontAsset.sourceFontFile, fontAsset.faceInfo.pointSize);
|
||||
|
||||
GlyphLoadFlags glyphLoadFlags = ((GlyphRasterModes)fontAsset.atlasRenderMode & GlyphRasterModes.RASTER_MODE_HINTED) == GlyphRasterModes.RASTER_MODE_HINTED ? GlyphLoadFlags.LOAD_RENDER : GlyphLoadFlags.LOAD_RENDER | GlyphLoadFlags.LOAD_NO_HINTING;
|
||||
|
||||
if (FontEngine.TryGetGlyphWithIndexValue(glyphIndex, glyphLoadFlags, out glyph))
|
||||
{
|
||||
// Add new glyph to font asset (if needed)
|
||||
//fontAsset.AddGlyph_Internal(glyph);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
*/
|
||||
}
|
||||
}
|
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 0a017569bfe174e4890797b4d64cbabc
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
@@ -0,0 +1,146 @@
|
||||
using System;
|
||||
using System.Linq;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
using UnityEngine.TextCore.LowLevel;
|
||||
|
||||
|
||||
namespace TMPro
|
||||
{
|
||||
/// <summary>
|
||||
/// Table that contains the various font features available for the given font asset.
|
||||
/// </summary>
|
||||
[Serializable]
|
||||
public class TMP_FontFeatureTable
|
||||
{
|
||||
/// <summary>
|
||||
/// List that contains the glyph multiple substitution records.
|
||||
/// </summary>
|
||||
public List<MultipleSubstitutionRecord> multipleSubstitutionRecords
|
||||
{
|
||||
get { return m_MultipleSubstitutionRecords; }
|
||||
set { m_MultipleSubstitutionRecords = value; }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// List that contains the glyph ligature records.
|
||||
/// </summary>
|
||||
public List<LigatureSubstitutionRecord> ligatureRecords
|
||||
{
|
||||
get { return m_LigatureSubstitutionRecords; }
|
||||
set { m_LigatureSubstitutionRecords = value; }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// List that contains the glyph pair adjustment records.
|
||||
/// </summary>
|
||||
public List<GlyphPairAdjustmentRecord> glyphPairAdjustmentRecords
|
||||
{
|
||||
get { return m_GlyphPairAdjustmentRecords; }
|
||||
set { m_GlyphPairAdjustmentRecords = value; }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
public List<MarkToBaseAdjustmentRecord> MarkToBaseAdjustmentRecords
|
||||
{
|
||||
get { return m_MarkToBaseAdjustmentRecords; }
|
||||
set { m_MarkToBaseAdjustmentRecords = value; }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
public List<MarkToMarkAdjustmentRecord> MarkToMarkAdjustmentRecords
|
||||
{
|
||||
get { return m_MarkToMarkAdjustmentRecords; }
|
||||
set { m_MarkToMarkAdjustmentRecords = value; }
|
||||
}
|
||||
|
||||
// =============================================
|
||||
// Private backing fields for public properties.
|
||||
// =============================================
|
||||
|
||||
[SerializeField]
|
||||
internal List<MultipleSubstitutionRecord> m_MultipleSubstitutionRecords;
|
||||
|
||||
[SerializeField]
|
||||
internal List<LigatureSubstitutionRecord> m_LigatureSubstitutionRecords;
|
||||
|
||||
[SerializeField]
|
||||
internal List<GlyphPairAdjustmentRecord> m_GlyphPairAdjustmentRecords;
|
||||
|
||||
[SerializeField]
|
||||
internal List<MarkToBaseAdjustmentRecord> m_MarkToBaseAdjustmentRecords;
|
||||
|
||||
[SerializeField]
|
||||
internal List<MarkToMarkAdjustmentRecord> m_MarkToMarkAdjustmentRecords;
|
||||
|
||||
|
||||
// =============================================
|
||||
// Lookup data structures.
|
||||
// =============================================
|
||||
|
||||
internal Dictionary<uint, List<LigatureSubstitutionRecord>> m_LigatureSubstitutionRecordLookup;
|
||||
|
||||
internal Dictionary<uint, GlyphPairAdjustmentRecord> m_GlyphPairAdjustmentRecordLookup;
|
||||
|
||||
internal Dictionary<uint, MarkToBaseAdjustmentRecord> m_MarkToBaseAdjustmentRecordLookup;
|
||||
|
||||
internal Dictionary<uint, MarkToMarkAdjustmentRecord> m_MarkToMarkAdjustmentRecordLookup;
|
||||
|
||||
// =============================================
|
||||
// Constructor(s)
|
||||
// =============================================
|
||||
|
||||
public TMP_FontFeatureTable()
|
||||
{
|
||||
m_LigatureSubstitutionRecords = new List<LigatureSubstitutionRecord>();
|
||||
m_LigatureSubstitutionRecordLookup = new Dictionary<uint, List<LigatureSubstitutionRecord>>();
|
||||
|
||||
m_GlyphPairAdjustmentRecords = new List<GlyphPairAdjustmentRecord>();
|
||||
m_GlyphPairAdjustmentRecordLookup = new Dictionary<uint, GlyphPairAdjustmentRecord>();
|
||||
|
||||
m_MarkToBaseAdjustmentRecords = new List<MarkToBaseAdjustmentRecord>();
|
||||
m_MarkToBaseAdjustmentRecordLookup = new Dictionary<uint, MarkToBaseAdjustmentRecord>();
|
||||
|
||||
m_MarkToMarkAdjustmentRecords = new List<MarkToMarkAdjustmentRecord>();
|
||||
m_MarkToMarkAdjustmentRecordLookup = new Dictionary<uint, MarkToMarkAdjustmentRecord>();
|
||||
}
|
||||
|
||||
// =============================================
|
||||
// Utility Functions
|
||||
// =============================================
|
||||
|
||||
/// <summary>
|
||||
/// Sort the glyph pair adjustment records by glyph index.
|
||||
/// </summary>
|
||||
public void SortGlyphPairAdjustmentRecords()
|
||||
{
|
||||
// Sort List of Kerning Info
|
||||
if (m_GlyphPairAdjustmentRecords.Count > 0)
|
||||
m_GlyphPairAdjustmentRecords = m_GlyphPairAdjustmentRecords.OrderBy(s => s.firstAdjustmentRecord.glyphIndex).ThenBy(s => s.secondAdjustmentRecord.glyphIndex).ToList();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Sort the Mark-to-Base Adjustment Table records.
|
||||
/// </summary>
|
||||
public void SortMarkToBaseAdjustmentRecords()
|
||||
{
|
||||
// Sort List of Kerning Info
|
||||
if (m_MarkToBaseAdjustmentRecords.Count > 0)
|
||||
m_MarkToBaseAdjustmentRecords = m_MarkToBaseAdjustmentRecords.OrderBy(s => s.baseGlyphID).ThenBy(s => s.markGlyphID).ToList();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Sort the Mark-to-Mark Adjustment Table records.
|
||||
/// </summary>
|
||||
public void SortMarkToMarkAdjustmentRecords()
|
||||
{
|
||||
// Sort List of Kerning Info
|
||||
if (m_MarkToMarkAdjustmentRecords.Count > 0)
|
||||
m_MarkToMarkAdjustmentRecords = m_MarkToMarkAdjustmentRecords.OrderBy(s => s.baseMarkGlyphID).ThenBy(s => s.combiningMarkGlyphID).ToList();
|
||||
}
|
||||
}
|
||||
}
|
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 5ea9f573d4b800a49b9d83a1f61c0a88
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
@@ -0,0 +1,227 @@
|
||||
using System;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
using UnityEngine.TextCore.LowLevel;
|
||||
|
||||
|
||||
namespace TMPro
|
||||
{
|
||||
[Flags]
|
||||
public enum FontFeatureLookupFlags
|
||||
{
|
||||
None = 0x0,
|
||||
IgnoreLigatures = 0x004,
|
||||
IgnoreSpacingAdjustments = 0x100,
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// The values used to adjust the position of a glyph or set of glyphs.
|
||||
/// </summary>
|
||||
[Serializable]
|
||||
public struct TMP_GlyphValueRecord
|
||||
{
|
||||
/// <summary>
|
||||
/// The positional adjustment affecting the horizontal bearing X of the glyph.
|
||||
/// </summary>
|
||||
public float xPlacement { get { return m_XPlacement; } set { m_XPlacement = value; } }
|
||||
|
||||
/// <summary>
|
||||
/// The positional adjustment affecting the horizontal bearing Y of the glyph.
|
||||
/// </summary>
|
||||
public float yPlacement { get { return m_YPlacement; } set { m_YPlacement = value; } }
|
||||
|
||||
/// <summary>
|
||||
/// The positional adjustment affecting the horizontal advance of the glyph.
|
||||
/// </summary>
|
||||
public float xAdvance { get { return m_XAdvance; } set { m_XAdvance = value; } }
|
||||
|
||||
/// <summary>
|
||||
/// The positional adjustment affecting the vertical advance of the glyph.
|
||||
/// </summary>
|
||||
public float yAdvance { get { return m_YAdvance; } set { m_YAdvance = value; } }
|
||||
|
||||
// =============================================
|
||||
// Private backing fields for public properties.
|
||||
// =============================================
|
||||
|
||||
[SerializeField]
|
||||
internal float m_XPlacement;
|
||||
|
||||
[SerializeField]
|
||||
internal float m_YPlacement;
|
||||
|
||||
[SerializeField]
|
||||
internal float m_XAdvance;
|
||||
|
||||
[SerializeField]
|
||||
internal float m_YAdvance;
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Constructor
|
||||
/// </summary>
|
||||
/// <param name="xPlacement">The positional adjustment affecting the horizontal bearing X of the glyph.</param>
|
||||
/// <param name="yPlacement">The positional adjustment affecting the horizontal bearing Y of the glyph.</param>
|
||||
/// <param name="xAdvance">The positional adjustment affecting the horizontal advance of the glyph.</param>
|
||||
/// <param name="yAdvance">The positional adjustment affecting the vertical advance of the glyph.</param>
|
||||
public TMP_GlyphValueRecord(float xPlacement, float yPlacement, float xAdvance, float yAdvance)
|
||||
{
|
||||
m_XPlacement = xPlacement;
|
||||
m_YPlacement = yPlacement;
|
||||
m_XAdvance = xAdvance;
|
||||
m_YAdvance = yAdvance;
|
||||
}
|
||||
|
||||
internal TMP_GlyphValueRecord(GlyphValueRecord_Legacy valueRecord)
|
||||
{
|
||||
m_XPlacement = valueRecord.xPlacement;
|
||||
m_YPlacement = valueRecord.yPlacement;
|
||||
m_XAdvance = valueRecord.xAdvance;
|
||||
m_YAdvance = valueRecord.yAdvance;
|
||||
}
|
||||
|
||||
internal TMP_GlyphValueRecord(GlyphValueRecord valueRecord)
|
||||
{
|
||||
m_XPlacement = valueRecord.xPlacement;
|
||||
m_YPlacement = valueRecord.yPlacement;
|
||||
m_XAdvance = valueRecord.xAdvance;
|
||||
m_YAdvance = valueRecord.yAdvance;
|
||||
}
|
||||
|
||||
public static TMP_GlyphValueRecord operator +(TMP_GlyphValueRecord a, TMP_GlyphValueRecord b)
|
||||
{
|
||||
TMP_GlyphValueRecord c;
|
||||
c.m_XPlacement = a.xPlacement + b.xPlacement;
|
||||
c.m_YPlacement = a.yPlacement + b.yPlacement;
|
||||
c.m_XAdvance = a.xAdvance + b.xAdvance;
|
||||
c.m_YAdvance = a.yAdvance + b.yAdvance;
|
||||
|
||||
return c;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// The positional adjustment values of a glyph.
|
||||
/// </summary>
|
||||
[Serializable]
|
||||
public struct TMP_GlyphAdjustmentRecord
|
||||
{
|
||||
/// <summary>
|
||||
/// The index of the glyph in the source font file.
|
||||
/// </summary>
|
||||
public uint glyphIndex { get { return m_GlyphIndex; } set { m_GlyphIndex = value; } }
|
||||
|
||||
/// <summary>
|
||||
/// The GlyphValueRecord contains the positional adjustments of the glyph.
|
||||
/// </summary>
|
||||
public TMP_GlyphValueRecord glyphValueRecord { get { return m_GlyphValueRecord; } set { m_GlyphValueRecord = value; } }
|
||||
|
||||
// =============================================
|
||||
// Private backing fields for public properties.
|
||||
// =============================================
|
||||
|
||||
[SerializeField]
|
||||
internal uint m_GlyphIndex;
|
||||
|
||||
[SerializeField]
|
||||
internal TMP_GlyphValueRecord m_GlyphValueRecord;
|
||||
|
||||
/// <summary>
|
||||
/// Constructor
|
||||
/// </summary>
|
||||
/// <param name="glyphIndex">The index of the glyph in the source font file.</param>
|
||||
/// <param name="glyphValueRecord">The GlyphValueRecord contains the positional adjustments of the glyph.</param>
|
||||
public TMP_GlyphAdjustmentRecord(uint glyphIndex, TMP_GlyphValueRecord glyphValueRecord)
|
||||
{
|
||||
m_GlyphIndex = glyphIndex;
|
||||
m_GlyphValueRecord = glyphValueRecord;
|
||||
}
|
||||
|
||||
internal TMP_GlyphAdjustmentRecord(GlyphAdjustmentRecord adjustmentRecord)
|
||||
{
|
||||
m_GlyphIndex = adjustmentRecord.glyphIndex;
|
||||
m_GlyphValueRecord = new TMP_GlyphValueRecord(adjustmentRecord.glyphValueRecord);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// The positional adjustment values for a pair of glyphs.
|
||||
/// </summary>
|
||||
[Serializable]
|
||||
public class TMP_GlyphPairAdjustmentRecord
|
||||
{
|
||||
/// <summary>
|
||||
/// Contains the positional adjustment values for the first glyph.
|
||||
/// </summary>
|
||||
public TMP_GlyphAdjustmentRecord firstAdjustmentRecord { get { return m_FirstAdjustmentRecord; } set { m_FirstAdjustmentRecord = value; } }
|
||||
|
||||
/// <summary>
|
||||
/// Contains the positional adjustment values for the second glyph.
|
||||
/// </summary>
|
||||
public TMP_GlyphAdjustmentRecord secondAdjustmentRecord { get { return m_SecondAdjustmentRecord; } set { m_SecondAdjustmentRecord = value; } }
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
public FontFeatureLookupFlags featureLookupFlags { get { return m_FeatureLookupFlags; } set { m_FeatureLookupFlags = value; } }
|
||||
|
||||
// =============================================
|
||||
// Private backing fields for public properties.
|
||||
// =============================================
|
||||
|
||||
[SerializeField]
|
||||
internal TMP_GlyphAdjustmentRecord m_FirstAdjustmentRecord;
|
||||
|
||||
[SerializeField]
|
||||
internal TMP_GlyphAdjustmentRecord m_SecondAdjustmentRecord;
|
||||
|
||||
[SerializeField]
|
||||
internal FontFeatureLookupFlags m_FeatureLookupFlags;
|
||||
|
||||
/// <summary>
|
||||
/// Constructor
|
||||
/// </summary>
|
||||
/// <param name="firstAdjustmentRecord">First glyph adjustment record.</param>
|
||||
/// <param name="secondAdjustmentRecord">Second glyph adjustment record.</param>
|
||||
public TMP_GlyphPairAdjustmentRecord(TMP_GlyphAdjustmentRecord firstAdjustmentRecord, TMP_GlyphAdjustmentRecord secondAdjustmentRecord)
|
||||
{
|
||||
m_FirstAdjustmentRecord = firstAdjustmentRecord;
|
||||
m_SecondAdjustmentRecord = secondAdjustmentRecord;
|
||||
m_FeatureLookupFlags = FontFeatureLookupFlags.None;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Internal constructor
|
||||
/// </summary>
|
||||
/// <param name="firstAdjustmentRecord"></param>
|
||||
/// <param name="secondAdjustmentRecord"></param>
|
||||
internal TMP_GlyphPairAdjustmentRecord(GlyphPairAdjustmentRecord glyphPairAdjustmentRecord)
|
||||
{
|
||||
m_FirstAdjustmentRecord = new TMP_GlyphAdjustmentRecord(glyphPairAdjustmentRecord.firstAdjustmentRecord);
|
||||
m_SecondAdjustmentRecord = new TMP_GlyphAdjustmentRecord(glyphPairAdjustmentRecord.secondAdjustmentRecord);
|
||||
m_FeatureLookupFlags = FontFeatureLookupFlags.None;
|
||||
}
|
||||
}
|
||||
|
||||
public struct GlyphPairKey
|
||||
{
|
||||
public uint firstGlyphIndex;
|
||||
public uint secondGlyphIndex;
|
||||
public uint key;
|
||||
|
||||
public GlyphPairKey(uint firstGlyphIndex, uint secondGlyphIndex)
|
||||
{
|
||||
this.firstGlyphIndex = firstGlyphIndex;
|
||||
this.secondGlyphIndex = secondGlyphIndex;
|
||||
key = secondGlyphIndex << 16 | firstGlyphIndex;
|
||||
}
|
||||
|
||||
internal GlyphPairKey(TMP_GlyphPairAdjustmentRecord record)
|
||||
{
|
||||
firstGlyphIndex = record.firstAdjustmentRecord.glyphIndex;
|
||||
secondGlyphIndex = record.secondAdjustmentRecord.glyphIndex;
|
||||
key = secondGlyphIndex << 16 | firstGlyphIndex;
|
||||
}
|
||||
}
|
||||
}
|
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 27df3b12f30d0b74a9b10a3968c402ff
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 2da0c512f12947e489f739169773d7ca
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {fileID: 2800000, guid: 3ee40aa79cd242a5b53b0b0ca4f13f0f, type: 3}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
@@ -0,0 +1,15 @@
|
||||
using UnityEngine;
|
||||
using System.Collections;
|
||||
|
||||
|
||||
namespace TMPro
|
||||
{
|
||||
/// <summary>
|
||||
/// Custom text input validator where user can implement their own custom character validation.
|
||||
/// </summary>
|
||||
[System.Serializable]
|
||||
public abstract class TMP_InputValidator : ScriptableObject
|
||||
{
|
||||
public abstract char Validate(ref string text, ref int pos, char ch);
|
||||
}
|
||||
}
|
@@ -0,0 +1,12 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 79ff392d1bde4ad78a3836a4a480392d
|
||||
timeCreated: 1473021069
|
||||
licenseType: Pro
|
||||
MonoImporter:
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
@@ -0,0 +1,52 @@
|
||||
namespace TMPro
|
||||
{
|
||||
|
||||
/// <summary>
|
||||
/// Structure which contains information about the individual lines of text.
|
||||
/// </summary>
|
||||
public struct TMP_LineInfo
|
||||
{
|
||||
internal int controlCharacterCount;
|
||||
|
||||
public int characterCount;
|
||||
public int visibleCharacterCount;
|
||||
public int spaceCount;
|
||||
public int visibleSpaceCount;
|
||||
public int wordCount;
|
||||
public int firstCharacterIndex;
|
||||
public int firstVisibleCharacterIndex;
|
||||
public int lastCharacterIndex;
|
||||
public int lastVisibleCharacterIndex;
|
||||
|
||||
public float length;
|
||||
public float lineHeight;
|
||||
public float ascender;
|
||||
public float baseline;
|
||||
public float descender;
|
||||
public float maxAdvance;
|
||||
|
||||
public float width;
|
||||
public float marginLeft;
|
||||
public float marginRight;
|
||||
|
||||
public HorizontalAlignmentOptions alignment;
|
||||
public Extents lineExtents;
|
||||
|
||||
/// <summary>
|
||||
/// Function returning the current line of text.
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
//public string GetLineText()
|
||||
//{
|
||||
// string word = string.Empty;
|
||||
// TMP_CharacterInfo[] charInfo = textComponent.textInfo.characterInfo;
|
||||
|
||||
// for (int i = firstCharacterIndex; i < lastCharacterIndex + 1; i++)
|
||||
// {
|
||||
// word += charInfo[i].character;
|
||||
// }
|
||||
|
||||
// return word;
|
||||
//}
|
||||
}
|
||||
}
|
@@ -0,0 +1,12 @@
|
||||
fileFormatVersion: 2
|
||||
guid: b6e75d7f429a4e7e9e1ffb4f85cff49f
|
||||
timeCreated: 1464310403
|
||||
licenseType: Pro
|
||||
MonoImporter:
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
@@ -0,0 +1,21 @@
|
||||
using System.Collections.Generic;
|
||||
|
||||
|
||||
namespace TMPro
|
||||
{
|
||||
internal static class TMP_ListPool<T>
|
||||
{
|
||||
// Object pool to avoid allocations.
|
||||
private static readonly TMP_ObjectPool<List<T>> s_ListPool = new TMP_ObjectPool<List<T>>(null, l => l.Clear());
|
||||
|
||||
public static List<T> Get()
|
||||
{
|
||||
return s_ListPool.Get();
|
||||
}
|
||||
|
||||
public static void Release(List<T> toRelease)
|
||||
{
|
||||
s_ListPool.Release(toRelease);
|
||||
}
|
||||
}
|
||||
}
|
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user