# 启用 IResLoader 子类

MyLocalization 需要在Unity Editor 模式下和游戏运行模式下都需要加载资源,或转换资源路径, 所以需要在两个时机点给 MyLocalization 赋值 IResLoader 子类:

1. **C# 代码编译后**需要**立刻**赋值
2. **游戏刚启动后**需要**立刻**赋值

**C# 代码编译后, 会调用添加** UnityEditor.Callbacks.**DidReloadScripts 标签**的方法. 如 ResourceLoader 中的AutoAssign 方法:

```csharp
#if UNITY_EDITOR && Using_ResourceLoader
        [UnityEditor.Callbacks.DidReloadScripts(200)]
        public static void AutoAssign() {
            LocalizationSetting.loader = new ResourceLoader();
        }
#endif
```

参照此代码在用户实现 IResLoader 接口的子非静态类中添加类似代码即可.

**游戏刚启动后, 在某一个立刻会执行的 MonoBehaviour类的Awake 方法中**给 LocalizationSetting.loader = new XXXLoader();  赋值即可. (可参考 Demo 中的 ReLoaderSetter.cs 类写法和使用方式也行)

*(必要时调整一下代码运行顺序, 将赋值的类的运行顺序调得更加靠前.)*


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://fuliufuliu.gitbook.io/mylocalization-decument/v1.3/mylocalization-zhong-wen-wen-dang/jia-zai-dang-qian-yu-yan-zi-yuan/qi-yong-iresloader-zi-lei.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
