public void TestMake() { NetEntity enitiy = new NetEntity(); enitiy.ConnectionID = 123456789; PlayerData data = new PlayerData(); data.Name = "Player yall"; data.PrefabName = "Player"; MakeEntity.AddComponent(enitiy, data); GameObject obj = new GameObject(); obj.transform.position = new Vector3(Random.RandomRange(1, 25), Random.RandomRange(1, 25), Random.RandomRange(1, 25)); obj.name = "a name yall"; NetTransform trans = new NetTransform(); trans.position.x = obj.transform.position.x; trans.position.y = obj.transform.position.y; trans.position.z = obj.transform.position.z; MakeEntity.AddComponent(enitiy, trans); NetTransform trans2 = MakeEntity.GetComponent <NetTransform>(enitiy); PlayerData playerData = MakeEntity.GetComponent <PlayerData>(enitiy); Debug.Log("Did it work?"); }
public override void HandleSnapshot(Package pkg) { Debug.Log("处理快照"); var trans = pkg.GetValue <Transform3DData>(); NetTransform netTran = cube.GetComponent <NetTransform>(); netTran.SetData(trans); }
public override void HandleSnapshot(Package pkg) { Debug.Log("处理快照"); var trans = pkg.GetValue <Transform3DData>(); NetTransform netTran = cube.GetComponent <NetTransform>(); netTran.SetData(trans); cube.transform.localPosition = new Vector3(trans.LocalPosition.X, trans.LocalPosition.Y, trans.LocalPosition.Z); }
public override void OnAfterConnect(bool result) { base.OnAfterConnect(result); Object obj = Resources.Load("Cube"); cube = GameObject.Instantiate(obj) as GameObject; cube.ResetTransform(); NetTransform netTran = cube.GetComponent <NetTransform>(); netTran.instanceId = 100; }
public override void OnStart() { InitData(new List <(System.Func <object, Packet>, System.Action <Packet>)>() { (SendInput, HandleInput), (SendRot, HandleRot), }); DontDestroyOnLoad(gameObject); netTransform = GetComponent <NetTransform>(); cam = GetComponentInChildren <Camera>(); rBody = GetComponent <Rigidbody2D>(); if (!hasAuthority) { cam.gameObject.SetActive(false); } }
void Awake() { tran = GetComponent <NetTransform>(); }