From 5b78e6ea1736325348ad4074b8cc66d15eefed29 Mon Sep 17 00:00:00 2001 From: akeit0 <90429982+Akeit0@users.noreply.github.com> Date: Wed, 28 Oct 2026 12:18:50 +0900 Subject: [PATCH] Make the official Lua source generator optional --- CONTRIBUTING.md | 3 +++ README.md | 16 ++++++++++++++++ README_JA.md | 15 +++++++++++++++ src/Lua/Lua.csproj | 5 ----- 4 files changed, 34 insertions(+), 5 deletions(-) diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 3e686653..220a9ed0 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -43,6 +43,9 @@ The extension package for Unity is located in the `Assets/Lua.Unity` directory w The Unity package does not include the source code of the core package. During development, a local package containing the debug DLL is added as `com.nuskey8.lua.unity.internal`. +For `[LuaObject]` bindings, the local package also needs `Lua.Annotations.dll` and +`Lua.SourceGenerator.dll`, built separately from their projects. + ## Publishing Packages Publishing to NuGet is handled by a workflow via GitHub Actions. This will run whenever you push a `v.*.*.*` tag. diff --git a/README.md b/README.md index fd3035e2..12485475 100644 --- a/README.md +++ b/README.md @@ -46,6 +46,16 @@ dotnet add package LuaCSharp Install-Package LuaCSharp ``` +The runtime package does not depend on the official source generator or its annotations. +To use `[LuaObject]`, also install both packages at the same version as `LuaCSharp`: + +```ps1 +dotnet add package LuaCSharp.Annotations +dotnet add package LuaCSharp.SourceGenerator +``` + +Existing projects using `[LuaObject]` must add these explicit references when upgrading. + ### Unity You can also use Lua-CSharp with Unity. For details, see the [Lua.Unity](#luaunity) section. @@ -367,6 +377,9 @@ for (int i = 0; i < 10; i++) ## LuaObject +Requires the optional `LuaCSharp.Annotations` and `LuaCSharp.SourceGenerator` packages +described in [Installation](#installation). + By applying the `[LuaObject]` attribute, you can create custom classes that run within Lua. Adding this attribute to a class that you wish to use in Lua allows the Source Generator to automatically generate the code required for interaction from Lua. The following is an example implementation of a wrapper class for `System.Numerics.Vector3` that can be used in Lua: @@ -619,6 +632,9 @@ Lua-CSharp can also be used in Unity (works with both Mono and IL2CPP). 2. Open the NuGet window by going to `NuGet > Manage NuGet Packages`, search for the `LuaCSharp` package, and install it. + For `[LuaObject]` bindings, also install `LuaCSharp.Annotations` and + `LuaCSharp.SourceGenerator` at the same version. Custom bindings only require the runtime. + 3. Open the Package Manager window by selecting `Window > Package Manager`, then click on `[+] > Add package from git URL` and enter the following URL: ``` diff --git a/README_JA.md b/README_JA.md index 28515e03..6648049c 100644 --- a/README_JA.md +++ b/README_JA.md @@ -46,6 +46,15 @@ dotnet add package LuaCSharp Install-Package LuaCSharp ``` +ランタイムパッケージは公式Source Generatorと属性パッケージに依存しません。 +`[LuaObject]`を使用する場合は、`LuaCSharp`と同じバージョンの次のパッケージも明示的に追加してください。 +既存の`[LuaObject]`利用プロジェクトも、アップグレード時に追加が必要です。 + +```ps1 +dotnet add package LuaCSharp.Annotations +dotnet add package LuaCSharp.SourceGenerator +``` + ### Unity Lua-CSharpをUnityで利用することも可能です。詳細は[Lua.Unity](#luaunity)の項目を参照してください。 @@ -365,6 +374,9 @@ for (int i = 0; i < 10; i++) ## LuaObject +利用には[インストール](#インストール)で説明した`LuaCSharp.Annotations`と +`LuaCSharp.SourceGenerator`の追加が必要です。 + `[LuaObject]`属性を用いることで、Lua上で動作する独自のクラスを作成することが可能になります。Luaで使いたいクラスにこの属性を付加することで、Source GeneratorがLua側から利用されるコードを自動生成します。 以下のサンプルコードはLuaで動作する`System.Numerics.Vector3`のラッパークラスの実装例です。 @@ -586,6 +598,9 @@ Lua-CSharpはUnityで利用することも可能です。(Mono/IL2CPPの両方 2. `NuGet > Manage NuGet Packages`からNuGetウィンドウを開き、`LuaCSharp`パッケージを検索してインストールします。 + `[LuaObject]`を使用する場合は、同じバージョンの`LuaCSharp.Annotations`と + `LuaCSharp.SourceGenerator`もインストールしてください。 + 3. `Window > Package Manager`からPackage Managerウィンドウを開き、`[+] > Add package from git URL`から以下のURLを入力します。 ``` https://github.com/nuskey8/Lua-CSharp.git?path=src/Lua.Unity/Assets/Lua.Unity diff --git a/src/Lua/Lua.csproj b/src/Lua/Lua.csproj index c9b20ed5..69662571 100644 --- a/src/Lua/Lua.csproj +++ b/src/Lua/Lua.csproj @@ -30,9 +30,4 @@ - - - - -