Przejdź do treści
Biblioteka skilli
Programowanie · Budowanie i kod

zlua-extension

/zlua-extension

Rejestruje metody rozszerzające C# na typach, aby Lua mogła wołać je jak metody obiektu, np. obj:ExtFoo.

Repozytorium
unity-mcp ↗
Licencja
MIT
Ostatnia zmiana repozytorium
02.11.2026

Ocena i bezpieczeństwo

95/ 100Klasa: dobry
Format25 / 25
Frontmatter z nazwą i opisem, poprawna nazwa, opis do 1024 znaków, nazwa zgodna z folderem.
Odkrywalność25 / 25
Opis mówi, kiedy użyć skilla, ma sensowną długość i jest w 3. osobie.
Treść30 / 35
Co najmniej 150 słów i do 500 linii, nagłówki, listy kroków, przykłady albo kod.
Higiena15 / 15
Bez zaślepek typu TODO, bez ścieżek Windows, z licencją.
Ryzykobrak sygnałów w skanie
Pliki w paczce
1
Skrypty
0
Komentarze HTML
0
Adresy URL w SKILL.md
0
Przestarzałość

Brak sygnałów. Repozytorium zmienione 02.11.2026, bez odwołań do wycofanych modeli i API.

Licencja

MIT, otwarta: można używać i zmieniać, z zachowaniem informacji o autorze.

Co robi i kiedy

Rejestruje metody rozszerzające C# na typach, aby Lua mogła wołać je jak metody obiektu, np. obj:ExtFoo.

Oryginalny opis (EN)

Registers C# extension methods on the extended type so Lua can call obj:ExtFoo. Use when writing [LuaExtension], ZLuaExtensions, luaExtensionXmlPaths, or when an extension method is missing from a Lua instance.

Jak działa

  1. Attribute
  2. XML
  3. Which methods appear
  4. Same name as an instance method
Sekcje z nagłówków SKILL.md, w oryginale · 69 linii, 461 słów
Podgląd SKILL.md
---
name: zlua-extension
description: >-
  Registers C# extension methods on the extended type so Lua can call
  obj:ExtFoo. Use when writing [LuaExtension], ZLuaExtensions, luaExtensionXmlPaths,
  or when an extension method is missing from a Lua instance.
---

# Extension methods

ZLua does not scan the assembly for `ExtensionAttribute`. Bind looks up a list of extension classes configured on the extended type, then reflects only those classes. An unconfigured extension is `zlua: member not found`, not a static call on the helper class.

| | |
|--|--|
| Attribute | `[LuaExtension(typeof(ExtClass), ...)]` on the extended type |
| XML root | `ZLuaExtensions` |
| Settings | `luaExtensionXmlPaths` |

Do not put `[LuaExtension]` on the static extension class. Do not mix this XML with `ZLuaAlias` or `ZLuaMarshalAs`.

## Attribute

Editable types, including hot-update assemblies, use the attribute only. XML is ignored for hot-update assemblies (including HybridCLR).

```csharp
using ZLua;

public static class MyClassExt
{
    public static void ResetLocal(this MyClass self) { }
}

[LuaExtension(typeof(MyClassExt), typeof(MyClassTweenExt))]
public class MyClass { }
```

```lua
local obj = CSharp.AC.MyClass()
obj:ResetLocal()
```

`AllowMultiple` is allowed. Several attributes on the same type are unioned. Binding `T` also walks `BaseType` and collects `[LuaExtension]` from base types.

An interface extension list is used only when that interface type itself is configured and the method's `this` accepts the type being bound. Implementing an interface does not import extensions configured only on the interface.

## XML

Use XML when the extended type is precompiled, AOT, or third-party, and is not a hot-update assembly. `this` must match `Type/@fullName`.

```xml
<?xml version="1.0" encoding="utf-8"?>
<ZLuaExtensions version="1">
  <Assembly name="UnityEngine.CoreModule">
    <Type fullName="UnityEngine.Transform">
      <Extension assembly="Assembly-CSharp" fullName="MyGame.TransformExt"/>
    </Type>
  </Assembly>
</ZLuaExtensions>
```

`Assembly/@name` is the extended type's assembly short name. `Extension/@assembly` and `@fullName` name the extension class. This file allows only `Assembly` / `Type` / `Extension`.

Attribute and XML lists are unioned. An unresolvable extension class fails Generate, and fails Mono Initialize or Bind. Il2Cpp bakes the list at Generate. The Player does not read XML. A type that is already bound does not pick up an extension assembly loaded later.

## Which methods appear

From each extension class, keep `public static` methods that have `ExtensionAttribute`, have at least one parameter, and whose first parameter can accept the bound type (`this Base` works on a `Derived` instance). Open generic extension methods are not supported. A class that contributes no matching method is allowed.

The method is an instance method on the extended type. It is not added to that type's static table. Lua arity is the CLR parameter count minus `this`. The full signature key lists only the parameters after `this`. `[LuaAlias]` can still rename it (`zlua-alias`).

Structs get the same methods on both ByVal and ByObj instance tables.

## Same name as an instance method

The extension and a real instance method with the same final Lua name are one overload group. There is no instance-first rule. One candidate is a direct closure. Several candidates dispatch. Disambiguate with a full signature key or `[LuaAlias]` (`zlua-method-overload`, `zlua-alias`).

Wersje

W bazie nie ma innych skilli o nazwie zlua-extension.

Migawka bazy z 13.11.2026 · wersja paczki 7a3c153bee9a (skrót SHA-256 całej paczki)

Pobrania w ostatnich 30 dniach: 0 · ranking

Zgłoś problem z tym skillem: szkodliwa treść, błędny opis albo prośba autora o usunięcie.

Podobne skille

  • 95zlua-csharp-call-lua
    Wywołuje Lua z C# przez LuaAppDomain i GetFunction, wiążąc metody modułów Lua z delegatami i przeładowując skrypty.
  • 95zlua-generic-method
    Zamyka typy generyczne C# w Lua przez make_generic_type, zlua.inflate i prefiksy GTAP, na przykład dla List<T>.
  • 90lua-guide
    Pomaga pisać ogólne skrypty Lua 5.4+: moduły, zakresy zmiennych, metatabele, korutyny i obsługę błędów w plikach .lua.
  • 95extension-creator
    Tworzy rozszerzenia AiderDesk: pliki, metadane, metody interfejsu Extension, polecenia, narzędzia i obsługę zdarzeń.
  • 85Lua C Integration
    Omawia Lua C API do rozszerzania Lua kodem natywnym: operacje na stosie, wywołania C z Lua i odwrotnie, moduły C, userdata, metatabele i optymalizacje wydajności.
  • 100lua-embedding-scripting
    Osadza środowisko Lua w aplikacjach w C, Go i Rust, żeby obsługiwać skrypty pluginów i reguły konfiguracji.

Uwagi i zgłoszenia

Wiadomość trafi do Bartosza Sokolińskiego. Adres e-mail jest potrzebny tylko do odpowiedzi. Szczegóły w polityce prywatności.