unity 关于Xlua中代码给游戏物体添加C#

标题看起来可能有些矛盾,既然使用lua了,为什么还需要再加C#脚本呢。啊啊哈哈  这是一个梗,也是一个我们团队面对的一个相对更高的过度过程吧

	--游戏加载页面
    local parent =  CS.UnityEngine.GameObject.Find("Canvas").transform 
	
	local A_enter = parent:Find("A_enter").gameObject
	

    --后面的很重要        在AddComponent()里面添加个 这个typeof(CS.C#脚本的名字) 
	A_enter:AddComponent (typeof(CS.enter));
	print("测试进行显示")




    不加typeof会报错的!  所以一定要添加个typeof(CS.C#脚本名字)

 

完成!

你可能感兴趣的:(lua,unity)