Skip to content

Add generic LuaState.CreateUserData<T> - #7

Open
paq wants to merge 1 commit into
nuskey8:mainfrom
paq:create-user-data-t
Open

Add generic LuaState.CreateUserData<T>#7
paq wants to merge 1 commit into
nuskey8:mainfrom
paq:create-user-data-t

Conversation

@paq

@paq paq commented Jun 30, 2026

Copy link
Copy Markdown

The README documents state.CreateUserData<T>() for creating userdata, but this method was missing from the codebase. This PR adds the generic overload.

NuLua/README.md

Lines 254 to 268 in e173f96

Use `state.CreateUserData<T>()` to create UserData. The returned `LuaUserData` is a handle that holds information such as the UserData pointer and size.
```cs
LuaUserData userdata = state.CreateUserData<Example>(new()
{
Foo = 5,
Bar = 1.5,
});
struct Example
{
public int Foo;
public double Bar;
}
```

However, given Unity AOT support, this approach may not be desirable. Please let me know if the README should be updated instead.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant