-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathLocalizationGenerator.cs
76 lines (65 loc) · 1.21 KB
/
LocalizationGenerator.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
using UnityEngine;
using UnityEngine.UI;
using System.Collections;
public class LocalizationComponent : MonoBehaviour
{
[SerializeField] private Text _target;
[SerializeField] private int _hash;
[SerializeField] private bool _isCustom;
[Header("Custom Field")]
[SerializeField] private string _content;
private string[] custom;
private int last_id;
public int hash
{
get { return _hash; }
}
public Text target
{
get { return _target; }
}
public bool isCustom
{
get { return _isCustom; }
}
public string content
{
get { return _content; }
}
public void SetComponent()
{
Text t = GetComponent<Text>();
if (t == null)
{
_target = null;
_hash = 0;
_isCustom = false;
}
else
{
_target = t;
if (_content != null && _content.Trim().Length > 0)
{
_hash = content.GetHashCode();
_isCustom = true;
}
else
{
_hash = t.text.GetHashCode();
_isCustom = false;
}
}
}
public void SetCustomLoad(string text)
{
_content = text;
custom = text.Split(new char[] { '|' });
_target.text = custom[last_id];
}
public void SetCustom(int index)
{
if (index < 0 || index > custom.Length - 1) return;
_target.text = custom[index];
last_id = index;
}
}