-
Notifications
You must be signed in to change notification settings - Fork 362
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
32 changed files
with
834 additions
and
219 deletions.
There are no files selected for viewing
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
50 changes: 50 additions & 0 deletions
50
Assets/LoxodonFramework/Scripts/Framework/Localizations/RectTypeConverter.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
using System; | ||
using System.Text.RegularExpressions; | ||
using UnityEngine; | ||
|
||
namespace Loxodon.Framework.Localizations | ||
{ | ||
public class RectTypeConverter : ITypeConverter | ||
{ | ||
public bool Support(string typeName) | ||
{ | ||
switch (typeName) | ||
{ | ||
case "rect": | ||
return true; | ||
default: | ||
return false; | ||
} | ||
} | ||
|
||
public Type GetType(string typeName) | ||
{ | ||
switch (typeName) | ||
{ | ||
case "rect": | ||
return typeof(Rect); | ||
default: | ||
throw new NotSupportedException(); | ||
} | ||
} | ||
|
||
public object Convert(Type type, object value) | ||
{ | ||
if (type == null) | ||
throw new NotSupportedException(); | ||
|
||
try | ||
{ | ||
var val = Regex.Replace(((string)value).Trim(), @"(^\()|(\)$)", ""); | ||
string[] s = val.Split(new char[] { ',' }, StringSplitOptions.RemoveEmptyEntries); | ||
if (s.Length == 4) | ||
return new Rect(float.Parse(s[0]), float.Parse(s[1]), float.Parse(s[2]), float.Parse(s[3])); | ||
|
||
} | ||
catch (Exception) | ||
{ | ||
} | ||
throw new FormatException(string.Format("The '{0}' is illegal Rect.", value)); | ||
} | ||
} | ||
} |
12 changes: 12 additions & 0 deletions
12
Assets/LoxodonFramework/Scripts/Framework/Localizations/RectTypeConverter.cs.meta
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
24 changes: 24 additions & 0 deletions
24
...ts/LoxodonFramework/Scripts/Framework/Localizations/UI/LocalizedAudioSourceInResources.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
using Loxodon.Framework.Localizations; | ||
using System; | ||
using System.Collections; | ||
using UnityEngine; | ||
|
||
namespace Loxodon.Framework.Localizations | ||
{ | ||
[RequireComponent(typeof(AudioSource))] | ||
public class LocalizedAudioSourceInResources : AbstractLocalized<AudioSource> | ||
{ | ||
protected override void OnValueChanged(object sender, EventArgs e) | ||
{ | ||
string path = (string)this.value.Value; | ||
this.StartCoroutine(DoLoad(path)); | ||
} | ||
|
||
protected virtual IEnumerator DoLoad(string path) | ||
{ | ||
var result = Resources.LoadAsync<AudioClip>(path); | ||
yield return result; | ||
this.target.clip = (AudioClip)result.asset; | ||
} | ||
} | ||
} |
12 changes: 12 additions & 0 deletions
12
...xodonFramework/Scripts/Framework/Localizations/UI/LocalizedAudioSourceInResources.cs.meta
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
25 changes: 25 additions & 0 deletions
25
Assets/LoxodonFramework/Scripts/Framework/Localizations/UI/LocalizedImageInResources.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
using Loxodon.Framework.Localizations; | ||
using System; | ||
using System.Collections; | ||
using UnityEngine; | ||
using UnityEngine.UI; | ||
|
||
namespace Loxodon.Framework.Localizations | ||
{ | ||
[RequireComponent(typeof(Image))] | ||
public class LocalizedImageInResources : AbstractLocalized<Image> | ||
{ | ||
protected override void OnValueChanged(object sender, EventArgs e) | ||
{ | ||
string path = (string)this.value.Value; | ||
this.StartCoroutine(DoLoad(path)); | ||
} | ||
|
||
protected virtual IEnumerator DoLoad(string path) | ||
{ | ||
var result = Resources.LoadAsync<Sprite>(path); | ||
yield return result; | ||
this.target.sprite = (Sprite)result.asset; | ||
} | ||
} | ||
} |
12 changes: 12 additions & 0 deletions
12
Assets/LoxodonFramework/Scripts/Framework/Localizations/UI/LocalizedImageInResources.cs.meta
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Oops, something went wrong.