Browse Source

Update: README

AnnulusGames 11 months ago
parent
commit
d79debaa92
3 changed files with 92 additions and 20 deletions
  1. 46 10
      README.md
  2. 46 10
      README_JA.md
  3. BIN
      docs/img-lua-importer.png

+ 46 - 10
README.md

@@ -48,16 +48,7 @@ Install-Package LuaCSharp
 
 ### Unity
 
-Lua-CSharp can also be used in Unity (works with both Mono and IL2CPP).
-
-### Requirements
-
-* Unity 2021.3 or higher
-
-### Installation
-
-1. Install [NugetForUnity](https://github.com/GlitchEnzo/NuGetForUnity).
-2. Open the NuGet window by going to `NuGet > Manage NuGet Packages`, search for the `LuaCSharp` package, and install it.
+You can also use Lua-CSharp with Unity. For details, see the [Lua.Unity](#luaunity) section.
 
 ## Quick Start
 
@@ -487,6 +478,51 @@ catch (LuaRuntimeException)
 }
 ```
 
+## Lua.Unity
+
+Lua-CSharp can also be used in Unity (works with both Mono and IL2CPP).
+
+### Requirements
+
+* Unity 2021.3 or higher
+
+### Installation
+
+1. Install [NugetForUnity](https://github.com/GlitchEnzo/NuGetForUnity).
+
+2. Open the NuGet window by going to `NuGet > Manage NuGet Packages`, search for the `LuaCSharp` package, and install it.
+
+3. Open the Package Manager window by selecting `Window > Package Manager`, then click on `[+] > Add package from git URL` and enter the following URL:
+
+    ```
+    https://github.com/AnnulusGames/Lua-CSharp.git?path=src/Lua.Unity/Assets/Lua.Unity
+    ```
+
+### LuaImporter / LuaAsset
+
+By introducing Lua.Unity, files with the `.lua` extension can be treated as `LuaAsset`.
+
+![img](docs/img-lua-importer.png)
+
+These assets can be used similarly to a standard `TextAsset`.
+
+```cs
+var asset = Resources.Load<LuaAsset>("example");
+await state.DoStringAsync(asset.Text, ct);
+```
+
+### Resources(Addressables)ModuleLoader
+
+Implementations of `ILuaModuleLoader` that utilize either Resources or Addressables internally are also provided.
+
+```cs
+// Use Resources for module loading
+state.ModuleLoader = new ResourcesModuleLoader();
+
+// Use Addressables for module loading (requires the Addressables package)
+state.ModuleLoader = new AddressablesModuleLoader();
+```
+
 ## Compatibility
 
 Lua-CSharp is designed with integration into .NET in mind, so there are several differences from the C implementation.

+ 46 - 10
README_JA.md

@@ -48,16 +48,7 @@ Install-Package LuaCSharp
 
 ### Unity
 
-Lua-CSharpをUnityで利用することも可能です。(Mono/IL2CPPの両方で動作します)
-
-### 要件
-
-* Unity 2021.3 以上
-
-### インストール
-
-1. [NugetForUnity](https://github.com/GlitchEnzo/NuGetForUnity)をインストールします。
-2. `NuGet > Manage NuGet Packages`からNuGetウィンドウを開き、`LuaCSharp`パッケージを検索してインストールします。
+Lua-CSharpをUnityで利用することも可能です。詳細は[Lua.Unity](#luaunity)の項目を参照してください。
 
 ## クイックスタート
 
@@ -487,6 +478,51 @@ catch (LuaRuntimeException)
 }
 ```
 
+## Lua.Unity
+
+Lua-CSharpはUnityで利用することも可能です。(Mono/IL2CPPの両方で動作します)
+また、Lua-CSharpをUnityと統合するための`Lua.Unity`拡張パッケージも提供されています。
+
+### 要件
+
+* Unity 2021.3 以上
+
+### インストール
+
+1. [NugetForUnity](https://github.com/GlitchEnzo/NuGetForUnity)をインストールします。
+
+2. `NuGet > Manage NuGet Packages`からNuGetウィンドウを開き、`LuaCSharp`パッケージを検索してインストールします。
+
+3. `Window > Package Manager`からPackage Managerウィンドウを開き、`[+] > Add package from git URL`から以下のURLを入力します。
+    ```
+    https://github.com/AnnulusGames/Lua-CSharp.git?path=src/Lua.Unity/Assets/Lua.Unity
+    ```
+
+### LuaImporter / LuaAsset
+
+Lua.Unityを導入することで、`.lua`拡張子のファイルを`LuaAsset`として扱えるようになります。
+
+![img](docs/img-lua-importer.png)
+
+これは通常の`TextAsset`のように利用することが可能です。
+
+```cs
+var asset = Resources.Load<LuaAsset>("example");
+await state.DoStringAsync(asset.Text, ct);
+```
+
+### Resources(Addressables)ModuleLoader
+
+また、内部でResourcesまたはAddressablesを利用する`ILuaModuleLoader`の実装が用意されています。
+
+```cs
+// モジュールの読み込みにResourcesを利用する
+state.ModuleLoader = new ResourcesModuleLoader();
+
+// モジュールの読み込みにAddressablesを利用する (Addressablesパッケージが必要)
+state.ModuleLoader = new AddressablesModuleLoader();
+```
+
 ## 互換性
 
 Lua-CSharpは.NETとの統合を念頭に設計されているため、C実装とは互換性がない仕様がいくつか存在します。

BIN
docs/img-lua-importer.png