50 lines
1.2 KiB
C#
50 lines
1.2 KiB
C#
using System;
|
|
using UnityEngine;
|
|
using UnityEngine.Localization;
|
|
using UnityEngine.UI;
|
|
|
|
namespace AibisDream
|
|
{
|
|
[CreateAssetMenu(menuName = "Style/Text Anima Style")]
|
|
public class TextAnimaStyle : ScriptableObject
|
|
{
|
|
public TextSpeed enSpeed;
|
|
public TextSpeed cnSpeed;
|
|
|
|
public float enCharSpace;
|
|
public float cnCharSpace;
|
|
|
|
[Serializable]
|
|
public struct TextSpeed
|
|
{
|
|
public float slowCharSpeed;
|
|
public float normalCharSpeed;
|
|
public float fastCharSpeed;
|
|
}
|
|
|
|
public float GetTextSpeed(TextSpeedEnum speedEnum, Locale locale)
|
|
{
|
|
var textSpeed = locale.Identifier.Code switch
|
|
{
|
|
"en" => enSpeed,
|
|
"zh-Hans" => cnSpeed,
|
|
_ => cnSpeed,
|
|
};
|
|
return speedEnum switch
|
|
{
|
|
TextSpeedEnum.Slow => textSpeed.slowCharSpeed,
|
|
TextSpeedEnum.Normal => textSpeed.normalCharSpeed,
|
|
TextSpeedEnum.Fast => textSpeed.fastCharSpeed,
|
|
_ => textSpeed.normalCharSpeed,
|
|
};
|
|
}
|
|
}
|
|
|
|
public enum TextSpeedEnum
|
|
{
|
|
Slow,
|
|
Normal,
|
|
Fast
|
|
}
|
|
}
|