lua热更框架之XLua
using System.Collections; using System.Collections.Generic; using UnityEngine; using UnityEngine.UI; using XLua; [Hotfix] public class Treasour : MonoBehaviour { public GameObject gold; public GameObject diamands; public Transform cavas; [LuaCallCSharp] private void CreatePrize() { for (int i = 0; i < 5; i++) { GameObject go = Instantiate(gold, transform.position + new Vector3(-10f + i * 30, 0, 0), transform.rotation); go.transform.SetParent(cavas); GameObject go1 = Instantiate(diamands, transform.position + new Vector3(0, 30, 0) + new Vector3(-10f + i * 30, 0, 0), transform.rotation); go1.transform.SetParent(cavas); } } }
local UnityEngine=CS.UnityEngine xlua.hotfix(CS.Treasour,'CreatePrize',function(self) for i=0,4,1 do local go=UnityEngine.GameObject.Instantiate(self.gold,self.transform.position+UnityEngine.Vector3(-10+i*40,0,0),self.transform.rotation) go.transform.SetParent(go.transform,self.cavas) local go1=UnityEngine.GameObject.Instantiate(self.diamands,self.transform.position+UnityEngine.Vector3(0,40,0)+UnityEngine.Vector3(-10+i*40,0,0),self.transform.rotation) go1.transform.SetParent(go1.transform,self.cavas) end end)
void Start(){ if(_hotfix) _lua_CreatePrize; else _csharp_CreatePrize; }