Skip to content

Commit 4134ed1

Browse files
committed
2 parents 382fd49 + 9d3bb93 commit 4134ed1

File tree

8 files changed

+226
-9
lines changed

8 files changed

+226
-9
lines changed

docs/Docs/Text组件.md

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
# 初始化
2+
在游戏启动脚本中进行初始化:
3+
``` csharp
4+
using WooLocalization;
5+
using UnityEngine;
6+
public class LocalizationInitializer : MonoBehaviour
7+
{
8+
public LocalizationData localizationData; // 赋值你的本地化数据
9+
private void Start()
10+
{
11+
// 设置记录器(用于保存当前语言设置)
12+
Localization.SetRecorder(new DefaultRecorder());
13+
// 设置本地化数据源
14+
Localization.SetContext(localizationData);
15+
// 设置默认语言
16+
Localization.SetDefaultLocalizationType(Languages.zh_CHS);
17+
}
18+
}
19+
```
20+
21+
# 创建本地化数据
22+
在 Project 窗口右键创建LocalizationData文件并配置数据
23+
24+
# 添加本地化组件
25+
给 UI 文本组件添加 LocalizationText 或 LocalizationTMP_Text 组件
26+
27+
# Text/TMP 组件
28+
* Context 设置文件
29+
* Text
30+
* mode
31+
* 1.Normal:无操作
32+
* 2.New Key:输入Key和Value后点击Execute可以更新
33+
* 3.Replace Value:重新修改当前key的值
34+
* Preview 当前语言的Key与Value
35+
* key
36+
* 此组件的key
37+
* FormatArgs
38+
* 添加占位符的内容
39+
* Font
40+
* 设置字体
41+
* FontSize
42+
* 设置字体大小
43+
* Color
44+
* 设置文字颜色
45+
* Material
46+
* 设置材质球
47+
* 每个属性中的mode选项
48+
* 1.default :默认资源配置
49+
* 2.Custom :
50+
* 3.Asset : 配置此资源的Asset文件
51+
![](../_media/Component-Text.png)

docs/Docs/代码形式.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
# 代码
2+
当不使用组件方式时如何使用
3+
``` csharp
4+
//调用静态类获取信息
5+
text.text=Localization.GetLocalization("Key")
6+
```

docs/Docs/其他资源使用.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
# 其他类型资源本地化
2+
* 假如你有其他类型资源需要本地化处理,如Image,Prefab,Font
3+
* 1.创建对应资源Asset文件,并配置数据
4+
* 2.添加对应Localization组件,如:Sprite资源添加Localization_Image组件
5+
* 3.Localization_Image组件 - 勾选Sprite - mode选择Asset - asset选择对应文件即可
6+
* 4.使用ActorTest组件

docs/Docs/创建基础配置.md

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
# 创建方法
2+
右键Project窗口 - Creat - Localization Data
3+
4+
# 界面功能介绍
5+
* Clear Data
6+
* 一键清除所有数据
7+
* Merge
8+
* 合并选择的LocalizationData文件
9+
* Read Excel
10+
* 从Excel文件夹中读取数据
11+
* Read From CSV / Write to CSV
12+
* 从本地路径中读写CSV文件
13+
* NewLanguage
14+
* 添加新语言
15+
* Language
16+
* 选择语言
17+
* Key
18+
* 用于在代码中引用对应文本的标识符
19+
* VAL
20+
* 用于在所需语言中显示的实际文本
21+
22+
# 其他类型资源文件
23+
Color、Font、Float等数据内容都可通过创建不同类型文件进行配置
24+
25+
![tupian](../_media/LocalizationData.png)

docs/Docs/翻译.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
# 使用有道翻译
2+
* 点击Register跳转注册 点击Code&Language跳转Api接入界面
3+
* 填入Appid和AppSecret
4+
* 选择Asset文件右键 点击Translate 中指定翻译
5+
![](../_media/有道翻译.png)

docs/Docs/自定义扩展.md

Lines changed: 109 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,109 @@
1+
# Localization-Asset文件扩展 以Texture举例
2+
``` csharp
3+
using UnityEngine;
4+
namespace WooLocalization
5+
{
6+
[CreateAssetMenu(menuName = "WooLocalization/TextureActorAsset")]
7+
public class TextureActorAsset : ActorAsset<Texture>
8+
{
9+
}
10+
}
11+
12+
using UnityEditor;
13+
using UnityEngine;
14+
namespace WooLocalization
15+
{
16+
[CustomEditor(typeof(TextureActorAsset))]
17+
class TextureActorAssetEditor : ActorAssetEditor<Texture, TextureActorAsset>
18+
{
19+
protected override float GetRowHeight()
20+
{
21+
return 60;
22+
}
23+
24+
protected override Texture DrawField(Rect pos, Texture src)
25+
{
26+
float min = Mathf.Min(pos.width, pos.height);
27+
pos.size = Vector2.one * min;
28+
return EditorGUI.ObjectField(pos, src, typeof(Texture), false) as Texture;
29+
}
30+
31+
}
32+
}
33+
```
34+
# 组件扩展 以Texture举例
35+
```csharp
36+
using System.Collections.Generic;
37+
using UnityEngine;
38+
39+
namespace WooLocalization
40+
{
41+
[DisallowMultipleComponent]
42+
public class LocalizationTexture : LocalizationBehavior
43+
{
44+
public class TextureActor : LocalizationMapActor<LocalizationBehavior, Texture>
45+
{
46+
private Texture ins;
47+
public TextureActor(bool enable) : base(enable)
48+
{
49+
}
50+
public override Texture GetDefault() => default;
51+
protected override void Execute(string language, LocalizationBehavior component)
52+
{
53+
#if UNITY_EDITOR
54+
if (!Application.isPlaying) return;
55+
56+
if (UnityEditor.SceneManagement.EditorSceneManager.IsPreviewSceneObject(component)) return;
57+
#endif
58+
var texture = GetValue(language);
59+
if (texture != null)
60+
{
61+
}
62+
}
63+
}
64+
public TextureActor Texture = new TextureActor(true);
65+
protected override List<ILocalizationActor> GetActors()
66+
{
67+
return new List<ILocalizationActor>() {
68+
Texture
69+
};
70+
}
71+
}
72+
}
73+
74+
75+
using System;
76+
using UnityEditor;
77+
using UnityEngine;
78+
using static WooLocalization.LocalizationTexture;
79+
80+
namespace WooLocalization
81+
{
82+
83+
[CustomEditor(typeof(LocalizationTexture))]
84+
class LocalizationTextureEditor : LocalizationBehaviorEditor<LocalizationTexture>
85+
{
86+
[LocalizationActorEditorAttribute]
87+
88+
class TextureActorEditor : LocalizationMapActorEditor<LocalizationTexture.TextureActor, Texture, LocalizationBehavior>
89+
{
90+
protected override Type GetAssetType() => typeof(TextureActorAsset);
91+
92+
protected override bool NeedExecute() => false;
93+
94+
}
95+
}
96+
}
97+
```
98+
99+
# ActorTest扩展 以Texture举例
100+
```csharp
101+
public class ActorTest : WooLocalization.LocalizationBehavior
102+
{
103+
protected override List<ILocalizationActor> GetActors()
104+
{
105+
return new List<ILocalizationActor>() {_texture };
106+
}
107+
public ObjectActor<Texture> _texture = new ObjectActor<Texture>(true);
108+
}
109+
```

docs/Docs/设置默认配置.md

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
# GenKeys
2+
点击后生成key、sprite、Languages的字段和方法脚本
3+
4+
# Localization Window
5+
* CSVRegex
6+
* 正则表达式相关内容
7+
* Translator
8+
* 有道翻译
9+
* 点击跳转有道界面注册登录 并申请应用获取id sercet 输入Appid 和AppSecret
10+
* DefaultData
11+
* 设置语言映射和语言
12+
* ImportTMPExtend
13+
* 添加TMP相关脚本
14+
15+
![](../_media/LocalizationWindow.png)
16+

docs/_sidebar.md

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,11 @@
33

44
- [安装](Docs/install.md)
55
- [测试](Docs/test.md)
6-
- [简介](Docs/简介.md)
7-
- [快速使用](Docs/快速使用.md)
8-
- [LocalizationData](Docs/LocalizationData.md)
9-
- [Tools](Docs/Tools.md)
10-
- [组件](Docs/组件.md)
11-
- [初始化](Docs/初始化.md)
12-
- [Demo](Docs/Demo.md)
13-
- [API](Docs/API.md)
14-
- [快速使用](Docs/快速使用.md)
6+
- [创建基础配置](Docs/创建基础配置.md)
7+
- [设置默认配置](Docs/设置默认配置.md)
8+
- [Text组件](Docs/Text组件.md)
9+
- [其他资源使用](Docs/其他资源使用.md)
10+
- [代码形式](Docs/代码形式.md)
11+
- [翻译](Docs/翻译.md)
12+
- [自定义扩展](Docs/自定义扩展.md)
13+

0 commit comments

Comments
 (0)