天天看点

ulua介绍和使用2

ulua介绍和使用2
ulua介绍和使用2

C#创建cube

void Start()
    {
        CreatCube();
    }

    private void CreatCube()
    {
       GameObject item= Resources.Load<GameObject>("cube");
       GameObject cube=GameObject.Instantiate(item);
       cube.transform.localPosition=Vector3.zero;
    }      
ulua介绍和使用2

WrapFile添加

_GT(typeof(Resources)),      

lua生成一个cube

private string cmd = @"
luanet.load_assembly('UnityEngine')--加载命名空间
Resources=UnityEngine.Resources
GameObject=UnityEngine.GameObject
local cube=Resources.Load('cube')
local player=GameObject.Instantiate(cube)
player.name=[[cubeplayer]]
";
    void Start()
    {
        LuaScriptMgr lua=new LuaScriptMgr();
        lua.Start();
        lua.DoString(cmd);
    }      
ulua介绍和使用2

C#生成

void CreatCube()
    {
        GameObject item=Resources.Load<GameObject>("cube");
        for (int i = 0; i < 10; i++)
        {
            for (int j = 0; j < 10; j++)
            {
                Instantiate(item, new Vector3(i,j,0),Quaternion.identity);
            }
            
        }
    }      
ulua介绍和使用2

lua生成

添加重新生成wrap

_GT(typeof(Vector3)),
        _GT(typeof(Quaternion)),      
private string cmd1 = @"
luanet.load_assembly('UnityEngine')--加载命名空间
Resources=UnityEngine.Resources
GameObject=UnityEngine.GameObject
Vector3=UnityEngine.Vector3
Quaternion=UnityEngine.Quaternion
local cube=Resources.Load('cube')
for i=0, 9,1 do
for j=0, 9,1 do
local player=GameObject.Instantiate(cube,Vector3(i,j,0),Quaternion.identity)
end
end
";
    void Start()
    {
        LuaScriptMgr lua=new LuaScriptMgr();
        lua.Start();
        lua.DoString(cmd1);
    }      
ulua介绍和使用2
ulua介绍和使用2
ulua介绍和使用2
luanet.load_assembly('UnityEngine')
Resources=UnityEngine.Resources
GameObject=UnityEngine.GameObject
Vector3=UnityEngine.Vector3
Quaternion=UnityEngine.Quaternion
local cube=Resources.Load('cube')
for i=0, 9,1 do
for j=0, 9,1 do
local player=GameObject.Instantiate(cube,Vector3(i,j,0),Quaternion.identity)
player.name=i..j..'cube'
end
end      
void Start()
    {
        LuaScriptMgr lua=new LuaScriptMgr();
        lua.Start();
        TextAsset text=Resources.Load<TextAsset>("cubeCreat.lua");
        lua.DoString(text.text);
    }