public override void OnInspectorGUI() { VNetTransform me = (target as VNetTransform); GUIStyle style = new GUIStyle(GUI.skin.button); style.normal.textColor = Color.red; if (me.netIdentifier == 0 && GUILayout.Button("Generate Net UID", style)) { me.netIdentifier = VNetUtils.GenerateUIDInEditor(); } if (me.isLocalControlled == false && me.isRemoteControlled == false && GUILayout.Button("Take Local Control")) { me.TakeLocalControl(); } if (me.isLocalControlled && GUILayout.Button("Revoke Local Control")) { me.RevokeLocalControl(); } base.OnInspectorGUI(); }
public void Update() { if (netSpawnAtTime == 0) { return; } if (netSpawnAtTime > VNetSessionTime.Inst.GetServerTime()) { return; } netSpawnAtTime = 0; enabled = false; // Spawn the prefab PrefabInstance = GameObject.Instantiate(m_prefab); PrefabInstance.transform.position = spawnPos; PrefabInstance.transform.rotation = spawnRot; VNetTransform netTrans = PrefabInstance.GetComponent <VNetTransform>(); if (netTrans) { netTrans.netIdentifier = spawnObjectGUID; if (spawnOwnerID != VNetCommon.NET_CLIENT_INVALID_UID) { if (spawnOwnerID == VNet.Inst.GetUID()) { netTrans.TakeLocalControl(); } else { netTrans.RemoteTakeControl(netSpawnAtTime, spawnOwnerID); } } } }