Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Unity crash when trying to get UnityEngine.Color.Instance #254

Closed
ratkingsminion opened this issue Dec 3, 2018 · 4 comments
Closed

Unity crash when trying to get UnityEngine.Color.Instance #254

ratkingsminion opened this issue Dec 3, 2018 · 4 comments

Comments

@ratkingsminion
Copy link

ratkingsminion commented Dec 3, 2018

The following code crashes Unity (2018.2.15) on the second line:

var _g = luaState["_G"] as SLua.LuaTable;
var color = _g["UnityEngine.Color.Instance"];

luaState is a correctly initialized Slua.LuaState.

@ratkingsminion ratkingsminion changed the title Unity crash when trying to get Color Unity crash when trying to get UnityEngine.Color.Instance Dec 3, 2018
@pangweiwei
Copy link
Owner

LuaTable.getObject(same as []) will split passed key string by '.' to path list, luatable use the path-list to find value step by step, but UnityEngine.Color don't have a key named Instance, so report a error.

slua use ""UnityEngine.Color.Instance" as whole key to store instance method table.

@ratkingsminion
Copy link
Author

ratkingsminion commented Dec 4, 2018

The thing is that it's okay if I just iterate over _G's objects via ´foreach (var kvp in _g)´, but when I iterate over all the keys via a list later, Unity crashes, and that shouldn't happen IMHO.

@pangweiwei
Copy link
Owner

I add 2 function get/set key from/to table.

@pangweiwei
Copy link
Owner

I also add rawget/set flag for get/set functions.

# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants