public void SpawnPrefab(Vector3 pos, Quaternion rotation, bool takeLocalControl) { // Start this... enabled = true; PrefabInstance = null; netSpawnAtTime = VNetSessionTime.Inst.GetServerTime() + VNetManager.Inst.PrefabSpawnDelay; spawnPos = pos; spawnRot = rotation; spawnOwnerID = takeLocalControl ? VNet.Inst.GetUID() : VNetCommon.NET_CLIENT_INVALID_UID; spawnObjectGUID = VNetUtils.GenerateUID(); // create a message and send it out VNetMessageSpawnPrefab spawn = new VNetMessageSpawnPrefab(); spawn.transformUID = netIdentifier; spawn.localControlUID = spawnOwnerID; spawn.time = netSpawnAtTime; spawn.localPosition = pos; spawn.localRotation = rotation; spawn.objectGUID = spawnObjectGUID; VNet.Inst.SendToLobby(spawn, true); }
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 override void OnInspectorGUI() { VNetSpawnPrefab me = (target as VNetSpawnPrefab); 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(); } base.OnInspectorGUI(); }