Skip to content

Commit 20ea253

Browse files
committed
Use 'LeanLocalization' for Localization.
1 parent 45d54b4 commit 20ea253

File tree

136 files changed

+8629
-412
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

136 files changed

+8629
-412
lines changed

Assets/Lean.meta

Lines changed: 8 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Assets/Lean/Common.meta

Lines changed: 9 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Assets/Lean/Common/Extras.meta

Lines changed: 8 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Lines changed: 101 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,101 @@
1+
using UnityEngine;
2+
using FSA = UnityEngine.Serialization.FormerlySerializedAsAttribute;
3+
4+
namespace Lean.Common
5+
{
6+
/// <summary>This component allows you to destroy a GameObject.</summary>
7+
[HelpURL(LeanHelper.HelpUrlPrefix + "LeanDestroy")]
8+
[AddComponentMenu(LeanHelper.ComponentPathPrefix + "Destroy")]
9+
public class LeanDestroy : MonoBehaviour
10+
{
11+
public enum ExecuteType
12+
{
13+
OnFirstFrame,
14+
AfterDelay,
15+
AfterDelayUnscaled,
16+
Manually
17+
}
18+
19+
/// <summary>This allows you to control when the <b>Target</b> GameObject will be destroyed.
20+
/// OnFirstFrame = As soon as Update runs (this component must be enabled).
21+
/// AfterDelay = After the specified amount of <b>Seconds</b> has elapsed.
22+
/// AfterDelayUnscaled = The same as AfterDelay, but using unscaledDeltaTime.
23+
/// Manually = You must manually call the <b>DestroyNow</b> method.</summary>
24+
public ExecuteType Execute { set { execute = value; } get { return execute; } } [SerializeField] private ExecuteType execute = ExecuteType.Manually;
25+
26+
/// <summary>The GameObject that will be destroyed.
27+
/// None/null = This GameObject.</summary>
28+
public GameObject Target { set { target = value; } get { return target; } } [FSA("Target")] [SerializeField] private GameObject target;
29+
30+
/// <summary>The amount of seconds remaining until the GameObject is destroyed.</summary>
31+
public float Seconds { set { seconds = value; } get { return seconds; } } [FSA("Seconds")] [SerializeField] private float seconds = -1.0f;
32+
33+
protected virtual void Update()
34+
{
35+
switch (execute)
36+
{
37+
case ExecuteType.OnFirstFrame:
38+
{
39+
DestroyNow();
40+
}
41+
break;
42+
43+
case ExecuteType.AfterDelay:
44+
{
45+
seconds -= Time.deltaTime;
46+
47+
if (seconds <= 0.0f)
48+
{
49+
DestroyNow();
50+
}
51+
}
52+
break;
53+
54+
case ExecuteType.AfterDelayUnscaled:
55+
{
56+
seconds -= Time.unscaledDeltaTime;
57+
58+
if (seconds <= 0.0f)
59+
{
60+
DestroyNow();
61+
}
62+
}
63+
break;
64+
}
65+
}
66+
67+
/// <summary>You can manually call this method to destroy the specified GameObject immediately.</summary>
68+
public void DestroyNow()
69+
{
70+
execute = ExecuteType.Manually;
71+
72+
Destroy(target != null ? target : gameObject);
73+
}
74+
}
75+
}
76+
77+
#if UNITY_EDITOR
78+
namespace Lean.Common.Editor
79+
{
80+
using TARGET = LeanDestroy;
81+
82+
[UnityEditor.CanEditMultipleObjects]
83+
[UnityEditor.CustomEditor(typeof(TARGET))]
84+
public class LeanDestroy_Editor : LeanEditor
85+
{
86+
protected override void OnInspector()
87+
{
88+
TARGET tgt; TARGET[] tgts; GetTargets(out tgt, out tgts);
89+
90+
Draw("target", "The GameObject that will be destroyed.\n\nNone/null = This GameObject.");
91+
Draw("execute", "This allows you to control when the <b>Target</b> GameObject will be destroyed.\n\nOnFirstFrame = As soon as Update runs (this component must be enabled).\n\nAfterDelay = After the specified amount of <b>Seconds</b> has elapsed.\n\nAfterDelayUnscaled = The same as AfterDelay, but using unscaledDeltaTime.\n\nManually = You must manually call the <b>DestroyNow</b> method.");
92+
if (Any(tgts, t => t.Execute == LeanDestroy.ExecuteType.AfterDelay || t.Execute == LeanDestroy.ExecuteType.AfterDelayUnscaled))
93+
{
94+
BeginIndent();
95+
Draw("seconds", "The amount of seconds remaining until the GameObject is destroyed.");
96+
EndIndent();
97+
}
98+
}
99+
}
100+
}
101+
#endif

Assets/Lean/Common/Extras/LeanDestroy.cs.meta

Lines changed: 12 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Lines changed: 145 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,145 @@
1+
using UnityEngine;
2+
using UnityEngine.Events;
3+
4+
namespace Lean.Common
5+
{
6+
/// <summary>This component allows you to convert values like ints and floats into formatted text that can be shown in the UI. To use this component, simply call one of the <b>SetString</b> methods, and it will output the formatted string to the <b>OnString</b> event, which can be connected to UI text, etc.</b></summary>
7+
[HelpURL(LeanHelper.HelpUrlPrefix + "LeanFormatString")]
8+
[AddComponentMenu(LeanHelper.ComponentPathPrefix + "Format String")]
9+
public class LeanFormatString : MonoBehaviour
10+
{
11+
[System.Serializable] public class StringEvent : UnityEvent<string> {}
12+
13+
/// <summary>The final text will use this string formatting, where {0} is the first value, {1} is the second, etc. Formatting uses standard <b>string.Format</b> style.</summary>
14+
public string Format { set { format = value; } get { return format; } } [SerializeField] [Multiline] private string format = "Current Value = {0}";
15+
16+
/// <summary>Based on the <b>Send</b> setting, this event will be invoked.
17+
/// String = The .</summary>
18+
public StringEvent OnString { get { if (onString == null) onString = new StringEvent(); return onString; } } [SerializeField] private StringEvent onString;
19+
20+
/// <summary>This method will convert the input arguments into a formatted string, and output it to the <b>OnString</b> event.</summary>
21+
public void SetString(string a)
22+
{
23+
SendString(a);
24+
}
25+
26+
/// <summary>This method will convert the input arguments into a formatted string, and output it to the <b>OnString</b> event.</summary>
27+
public void SetString(string a, string b)
28+
{
29+
SendString(a, b);
30+
}
31+
32+
/// <summary>This method will convert the input arguments into a formatted string, and output it to the <b>OnString</b> event.</summary>
33+
public void SetString(int a)
34+
{
35+
SendString(a);
36+
}
37+
38+
/// <summary>This method will convert the input arguments into a formatted string, and output it to the <b>OnString</b> event.</summary>
39+
public void SetString(int a, int b)
40+
{
41+
SendString(a, b);
42+
}
43+
44+
/// <summary>This method will convert the input arguments into a formatted string, and output it to the <b>OnString</b> event.</summary>
45+
public void SetString(float a)
46+
{
47+
SendString(a);
48+
}
49+
50+
/// <summary>This method will convert the input arguments into a formatted string, and output it to the <b>OnString</b> event.</summary>
51+
public void SetString(float a, float b)
52+
{
53+
SendString(a, b);
54+
}
55+
56+
/// <summary>This method will convert the input arguments into a formatted string, and output it to the <b>OnString</b> event.</summary>
57+
public void SetString(Vector2 a)
58+
{
59+
SendString(a);
60+
}
61+
62+
/// <summary>This method will convert the input arguments into a formatted string, and output it to the <b>OnString</b> event.</summary>
63+
public void SetString(Vector2 a, Vector2 b)
64+
{
65+
SendString(a, b);
66+
}
67+
68+
/// <summary>This method will convert the input arguments into a formatted string, and output it to the <b>OnString</b> event.</summary>
69+
public void SetString(Vector3 a)
70+
{
71+
SendString(a);
72+
}
73+
74+
/// <summary>This method will convert the input arguments into a formatted string, and output it to the <b>OnString</b> event.</summary>
75+
public void SetString(Vector3 a, Vector3 b)
76+
{
77+
SendString(a, b);
78+
}
79+
80+
/// <summary>This method will convert the input arguments into a formatted string, and output it to the <b>OnString</b> event.</summary>
81+
public void SetString(Vector4 a)
82+
{
83+
SendString(a);
84+
}
85+
86+
/// <summary>This method will convert the input arguments into a formatted string, and output it to the <b>OnString</b> event.</summary>
87+
public void SetString(Vector4 a, Vector4 b)
88+
{
89+
SendString(a, b);
90+
}
91+
92+
/// <summary>This method will convert the input arguments into a formatted string, and output it to the <b>OnString</b> event.</summary>
93+
public void SetString(float a, int b)
94+
{
95+
SendString(a, b);
96+
}
97+
98+
/// <summary>This method will convert the input arguments into a formatted string, and output it to the <b>OnString</b> event.</summary>
99+
public void SetString(int a, float b)
100+
{
101+
SendString(a, b);
102+
}
103+
104+
private void SendString(object a)
105+
{
106+
if (onString != null)
107+
{
108+
onString.Invoke(string.Format(format, a));
109+
}
110+
}
111+
112+
private void SendString(object a, object b)
113+
{
114+
if (onString != null)
115+
{
116+
onString.Invoke(string.Format(format, a, b));
117+
}
118+
}
119+
}
120+
}
121+
122+
#if UNITY_EDITOR
123+
namespace Lean.Common.Editor
124+
{
125+
using TARGET = LeanFormatString;
126+
127+
[UnityEditor.CanEditMultipleObjects]
128+
[UnityEditor.CustomEditor(typeof(TARGET))]
129+
public class LeanFormatString_Editor : LeanEditor
130+
{
131+
protected override void OnInspector()
132+
{
133+
TARGET tgt; TARGET[] tgts; GetTargets(out tgt, out tgts);
134+
135+
BeginError(Any(tgts, t => string.IsNullOrEmpty(t.Format)));
136+
Draw("format", "The final text will use this string formatting, where {0} is the first value, {1} is the second, etc. Formatting uses standard <b>string.Format</b> style.");
137+
EndError();
138+
139+
Separator();
140+
141+
Draw("onString");
142+
}
143+
}
144+
}
145+
#endif

Assets/Lean/Common/Extras/LeanFormatString.cs.meta

Lines changed: 8 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)