Skip to content

Commit

Permalink
! Upload new version v2.0
Browse files Browse the repository at this point in the history
  • Loading branch information
nosstanislav committed Mar 5, 2019
1 parent df8b6e3 commit 2cc6ae9
Show file tree
Hide file tree
Showing 61 changed files with 1,970 additions and 547 deletions.
4 changes: 2 additions & 2 deletions Assets/LocalizeService.meta

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Binary file modified Assets/LocalizeService/Demo/Demo.unity
Binary file not shown.
2 changes: 1 addition & 1 deletion Assets/LocalizeService/Demo/Demo.unity.meta

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

50 changes: 34 additions & 16 deletions Assets/LocalizeService/Demo/LocolizeTest.cs
Original file line number Diff line number Diff line change
@@ -1,38 +1,56 @@
using SunCubeStudio.Localization;
using System;
using Localization;
using UnityEngine;
using UnityEngine.UI;

// For DEMO VIEW
public class LocolizeTest : MonoBehaviour
{
public Text CurrentText;
public Toggle Localization1;
public Toggle Localization2;
public Toggle Localization3;

private void Start()
{
CurrentText.text = string.Format("Current localization - {0}", LocalizationService.Instance.Localization);
Localization1.onValueChanged.AddListener(OnLocalization1Set);
Localization2.onValueChanged.AddListener(OnLocalization2Set);
Localization3.onValueChanged.AddListener(OnLocalization3Set);

CheckLocalization();
}

public void English()
private void CheckLocalization()
{
LocalizationService.Instance.Localization = "English";
if (LocalizationService.Instance == null) return;

switch (LocalizationService.Instance.Localization)
{
case "Russian":
Localization2.isOn = true;
break;
case "English":
Localization1.isOn = true;
break;
case "French":
Localization3.isOn = true;
break;
}
}

CurrentText.text = string.Format("Current localization {0}",
LocalizationService.Instance.GetTextByKeyWithLocalize("localization1", "English"));
private void OnLocalization1Set(bool value)
{
if (!value) return;
LocalizationService.Instance.Localization = "English";
}
public void Russian()
private void OnLocalization2Set(bool value)
{
if (!value) return;
LocalizationService.Instance.Localization = "Russian";

CurrentText.text = string.Format("Current localization {0}",
LocalizationService.Instance.GetTextByKeyWithLocalize("localization2", "English"));
}

public void French()
private void OnLocalization3Set(bool value)
{
if (!value) return;
LocalizationService.Instance.Localization = "French";

CurrentText.text = string.Format("Current localization {0}",
LocalizationService.Instance.GetTextByKeyWithLocalize("localization3", "English"));
}

}
Binary file not shown.
56 changes: 0 additions & 56 deletions Assets/LocalizeService/Demo/TexturesDemo/France-Flag-icon.png.meta

This file was deleted.

Binary file not shown.

This file was deleted.

Binary file not shown.

This file was deleted.

Binary file not shown.
56 changes: 0 additions & 56 deletions Assets/LocalizeService/Demo/TexturesDemo/Russia-Flag-icon.png.meta

This file was deleted.

2 changes: 1 addition & 1 deletion Assets/LocalizeService/Plugins.meta

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion Assets/LocalizeService/Plugins/Core.meta

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

11 changes: 5 additions & 6 deletions Assets/LocalizeService/Plugins/Core/MonoSingleton.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

public class MonoSingleton<T> : MonoBehaviour where T : MonoBehaviour
{

private static T s_Instance;
private static bool s_IsDestroyed;

Expand Down Expand Up @@ -32,15 +31,15 @@ public static T Instance

protected virtual void OnDestroy()
{
if (s_Instance)
Destroy(s_Instance);

s_Instance = null;
s_IsDestroyed = true;

if (s_Instance)
Destroy(s_Instance);
}

public bool IsLive()
public static bool IsLive
{
return s_IsDestroyed;
get { return !s_IsDestroyed; }
}
}
2 changes: 1 addition & 1 deletion Assets/LocalizeService/Plugins/Core/MonoSingleton.cs.meta

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion Assets/LocalizeService/Plugins/Core/SafetyAction.cs.meta

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

31 changes: 31 additions & 0 deletions Assets/LocalizeService/Plugins/Core/TypeHelper.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
using System;
using System.Collections.Generic;
using System.Reflection;

public class TypeHelper
{
public static Dictionary<string, Type> _fastTypes = new Dictionary<string, Type>();

public static Type GetTypeByName(string name, string assemblyName)
{
if (_fastTypes.ContainsKey(name))
return _fastTypes[name];

foreach (Assembly assembly in AppDomain.CurrentDomain.GetAssemblies())
{
if (!assembly.FullName.Contains(assemblyName))
continue;

foreach (Type type in assembly.GetTypes())
{
if (type.Name == name)
{
_fastTypes.Add(name, type);
return type;
}
}
}

return null;
}
}
12 changes: 12 additions & 0 deletions Assets/LocalizeService/Plugins/Core/TypeHelper.cs.meta

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

9 changes: 4 additions & 5 deletions Assets/LocalizeService/Resources/Localization/English.csv
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
Id,English
title,Localization\n Service
text,"This package is designed to show the localization of text in your applications. Simple interface. Text of localization located in the .CSV file format. Works with several possible types of text output in Unity(MeshText and UIText), there is also has the opportunity to get text value of the code."
shorttext,This package is designed to show the localization of text...
Id,English
title,Localization Service
text,"This package is designed to show the localization of text in your applications. Simple interface. Text of localization located in the .CSV file format. Works with several possible types of text output in Unity3d (MeshText and UIText), there is also has the opportunity to get text value of the code."
autors,Sun Cube
localization1,English
localization2,Russian
localization3,French
localization3,French
Loading

0 comments on commit 2cc6ae9

Please sign in to comment.