- ToLua的Example示例学习笔记12_TestGameOb
- ToLua的Example示例学习笔记_总集篇
- ToLua的Example示例学习笔记03_CallLuaFun
- ToLua的Example示例学习笔记13_CustomLoad
- ToLua的Example示例学习笔记22_UseList
- ToLua的Example示例学习笔记11_Delegate
- ToLua的Example示例学习笔记02_ScriptsFro
- ToLua的Example示例学习笔记05_LuaCorouti
- ToLua的Example示例学习笔记04_AccessingL
- ToLua的Example示例学习笔记09_Dictionary
展示了Lua对GameObject的操作。
「1」代码
操作代码如下:
local Color = UnityEngine.Color
local GameObject = UnityEngine.GameObject
local ParticleSystem = UnityEngine.ParticleSystem
function OnComplete()
print('OnComplete CallBack')
end
local go = GameObject('go')
go:AddComponent(typeof(ParticleSystem))
local node = go.transform
node.position = Vector3.one
print('gameObject is: '..tostring(go))
--go.transform:DOPath({Vector3.zero, Vector3.one * 10}, 1, DG.Tweening.PathType.Linear, DG.Tweening.PathMode.Full3D, 10, nil)
--go.transform:DORotate(Vector3(0,0,360), 2, DG.Tweening.RotateMode.FastBeyond360):OnComplete(OnComplete)
GameObject.Destroy(go, 2)
go.name = '123'
--print('delay destroy gameobject is: '..go.name)
c#代码如下:
new LuaResLoader();
lua = new LuaState();
lua.LogGC = true;
lua.Start();
LuaBinder.Bind(lua);
lua.DoString(script, "TestGameObject.cs");
「2」需要了解的部分
- 主要的方法如下:
GameObject:AddComponent(typeof(Component))
在lua中给游戏物体添加组件
GameObject("游戏物体名")
在lua中创建新的游戏物体
GameObject.Destroy(游戏对象, 延迟时间)
延时销毁的指定的游戏物体
luabinder.bind(lua)
将当前luastate的虚拟机中绑定C#中的一些类、全局类、委托等
网友评论