Skip to content

Commit d79deba

Browse files
committed
Update: README
1 parent e81e445 commit d79deba

File tree

3 files changed

+92
-20
lines changed

3 files changed

+92
-20
lines changed

README.md

Lines changed: 46 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -48,16 +48,7 @@ Install-Package LuaCSharp
4848

4949
### Unity
5050

51-
Lua-CSharp can also be used in Unity (works with both Mono and IL2CPP).
52-
53-
### Requirements
54-
55-
* Unity 2021.3 or higher
56-
57-
### Installation
58-
59-
1. Install [NugetForUnity](https://github.com/GlitchEnzo/NuGetForUnity).
60-
2. Open the NuGet window by going to `NuGet > Manage NuGet Packages`, search for the `LuaCSharp` package, and install it.
51+
You can also use Lua-CSharp with Unity. For details, see the [Lua.Unity](#luaunity) section.
6152

6253
## Quick Start
6354

@@ -487,6 +478,51 @@ catch (LuaRuntimeException)
487478
}
488479
```
489480

481+
## Lua.Unity
482+
483+
Lua-CSharp can also be used in Unity (works with both Mono and IL2CPP).
484+
485+
### Requirements
486+
487+
* Unity 2021.3 or higher
488+
489+
### Installation
490+
491+
1. Install [NugetForUnity](https://github.com/GlitchEnzo/NuGetForUnity).
492+
493+
2. Open the NuGet window by going to `NuGet > Manage NuGet Packages`, search for the `LuaCSharp` package, and install it.
494+
495+
3. Open the Package Manager window by selecting `Window > Package Manager`, then click on `[+] > Add package from git URL` and enter the following URL:
496+
497+
```
498+
https://github.com/AnnulusGames/Lua-CSharp.git?path=src/Lua.Unity/Assets/Lua.Unity
499+
```
500+
501+
### LuaImporter / LuaAsset
502+
503+
By introducing Lua.Unity, files with the `.lua` extension can be treated as `LuaAsset`.
504+
505+
![img](docs/img-lua-importer.png)
506+
507+
These assets can be used similarly to a standard `TextAsset`.
508+
509+
```cs
510+
var asset = Resources.Load<LuaAsset>("example");
511+
await state.DoStringAsync(asset.Text, ct);
512+
```
513+
514+
### Resources(Addressables)ModuleLoader
515+
516+
Implementations of `ILuaModuleLoader` that utilize either Resources or Addressables internally are also provided.
517+
518+
```cs
519+
// Use Resources for module loading
520+
state.ModuleLoader = new ResourcesModuleLoader();
521+
522+
// Use Addressables for module loading (requires the Addressables package)
523+
state.ModuleLoader = new AddressablesModuleLoader();
524+
```
525+
490526
## Compatibility
491527

492528
Lua-CSharp is designed with integration into .NET in mind, so there are several differences from the C implementation.

README_JA.md

Lines changed: 46 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -48,16 +48,7 @@ Install-Package LuaCSharp
4848

4949
### Unity
5050

51-
Lua-CSharpをUnityで利用することも可能です。(Mono/IL2CPPの両方で動作します)
52-
53-
### 要件
54-
55-
* Unity 2021.3 以上
56-
57-
### インストール
58-
59-
1. [NugetForUnity](https://github.com/GlitchEnzo/NuGetForUnity)をインストールします。
60-
2. `NuGet > Manage NuGet Packages`からNuGetウィンドウを開き、`LuaCSharp`パッケージを検索してインストールします。
51+
Lua-CSharpをUnityで利用することも可能です。詳細は[Lua.Unity](#luaunity)の項目を参照してください。
6152

6253
## クイックスタート
6354

@@ -487,6 +478,51 @@ catch (LuaRuntimeException)
487478
}
488479
```
489480

481+
## Lua.Unity
482+
483+
Lua-CSharpはUnityで利用することも可能です。(Mono/IL2CPPの両方で動作します)
484+
また、Lua-CSharpをUnityと統合するための`Lua.Unity`拡張パッケージも提供されています。
485+
486+
### 要件
487+
488+
* Unity 2021.3 以上
489+
490+
### インストール
491+
492+
1. [NugetForUnity](https://github.com/GlitchEnzo/NuGetForUnity)をインストールします。
493+
494+
2. `NuGet > Manage NuGet Packages`からNuGetウィンドウを開き、`LuaCSharp`パッケージを検索してインストールします。
495+
496+
3. `Window > Package Manager`からPackage Managerウィンドウを開き、`[+] > Add package from git URL`から以下のURLを入力します。
497+
```
498+
https://github.com/AnnulusGames/Lua-CSharp.git?path=src/Lua.Unity/Assets/Lua.Unity
499+
```
500+
501+
### LuaImporter / LuaAsset
502+
503+
Lua.Unityを導入することで、`.lua`拡張子のファイルを`LuaAsset`として扱えるようになります。
504+
505+
![img](docs/img-lua-importer.png)
506+
507+
これは通常の`TextAsset`のように利用することが可能です。
508+
509+
```cs
510+
var asset = Resources.Load<LuaAsset>("example");
511+
await state.DoStringAsync(asset.Text, ct);
512+
```
513+
514+
### Resources(Addressables)ModuleLoader
515+
516+
また、内部でResourcesまたはAddressablesを利用する`ILuaModuleLoader`の実装が用意されています。
517+
518+
```cs
519+
// モジュールの読み込みにResourcesを利用する
520+
state.ModuleLoader = new ResourcesModuleLoader();
521+
522+
// モジュールの読み込みにAddressablesを利用する (Addressablesパッケージが必要)
523+
state.ModuleLoader = new AddressablesModuleLoader();
524+
```
525+
490526
## 互換性
491527

492528
Lua-CSharpは.NETとの統合を念頭に設計されているため、C実装とは互換性がない仕様がいくつか存在します。

docs/img-lua-importer.png

92 KB
Loading

0 commit comments

Comments
 (0)