//private static Dictionary<string, AssetBundle> AssetBundles = new Dictionary<string, AssetBundle>(); public NAObject(GameObject _root, string _name, Vector3 _position, Vector3 _angles, Vector3 _scale, string _file, NetworkViewID _NetworkViewId) { Debug.Log("Creating NAObject " + _name); name = _name; position = _position; angles = _angles; scale = _scale; file = _file; NetworkViewId = _NetworkViewId; //create and sync the Main GameObject go = new GameObject(_name + _NetworkViewId); go.transform.parent = _root.transform; go.transform.position = _position; go.transform.eulerAngles = _angles; //go.transform.localScale = _scale; NetworkView nView = go.AddComponent <NetworkView>(); nView.viewID = this.NetworkViewId; NetworkSync nSync = go.AddComponent <NetworkSync>(); //if (name.Contains("Coffee") || name.Contains("Radio") || name.Contains("Object")) if (name.StartsWith("X")) { LogManager.Log("add " + name + " to the instanciables."); NA.instanciables.Add(this); } }
private GameObject CreateLocalObject(string aPrefabName, Vector3 aPosition, Quaternion aOrientation, int aNetId) { // Create the object locally GameObject newObj = Instantiate(Resources.Load(aPrefabName), aPosition, aOrientation) as GameObject; if (newObj == null) { Debug.LogError("ClientNetwork.CreateLocalObject can't instantiate unknown prefab " + aPrefabName); return(null); } // Set the id on the NetworkId script NetworkSync netSync = newObj.GetComponent(typeof(NetworkSync)) as NetworkSync; if (netSync != null) { netSync.clientNet = this; netSync.SetId(aNetId); } else { Debug.LogWarning("Instantiating object " + gameObject.name + " over the network without a NetworkSync"); } // Tell the object everything for the network has been initialized newObj.SendMessage("NetworkInitialized", SendMessageOptions.DontRequireReceiver); return(newObj); }
private void OnValidate() { if (netSync == null) { netSync = GetComponent <NetworkSync>(); } }
IEnumerator PulseColor() { for (int i = 0; i < 20; i++) { GetComponent <Renderer>().material.color = new Color(Random.Range(0.0f, 1.0f), Random.Range(0.0f, 1.0f), Random.Range(0.0f, 1.0f)); yield return(new WaitForSeconds(0.1f)); } NetworkSync sync = gameObject.GetComponent(typeof(NetworkSync)) as NetworkSync; if (sync) { if (sync.owned) { GetComponent <Renderer>().material.color = Color.green; } else { GetComponent <Renderer>().material.color = Color.grey; } } else { GetComponent <Renderer>().material.color = Color.red; } }
// when scene loads, init all starting network objects void LoadObjectsInNewScene() { List <GameObject> startingEntities = GameObject.FindGameObjectWithTag("NetworkStartingEntities")?.GetComponent <NetworkStartingEntities>()?.startingEntities; if (startingEntities == null) { return; } foreach (GameObject obj in startingEntities) { if (obj == null) { continue; } NetworkObjects.RemoveIncorrectComponents(obj); NetworkSync sync = obj.GetComponent <NetworkSync>(); if (obj == gameObject) { sync.Initialize(sync.ObjectID, sync.NetworkType); continue; } sync.Initialize(NextObjectID, sync.NetworkType); obj.SetActive(true); } }
// when scene loads, init all starting network objects void LoadObjectsInNewScene(int sceneStartingObjectID) { List <GameObject> startingEntities = GameObject.FindGameObjectWithTag("NetworkStartingEntities")?.GetComponent <NetworkStartingEntities>()?.startingEntities; if (startingEntities == null) { return; } currentObjectID = sceneStartingObjectID; foreach (GameObject obj in startingEntities) { // GameController doesn't follow the same rules NetworkObjects.RemoveIncorrectComponents(obj); NetworkSync sync = obj.GetComponent <NetworkSync>(); if (string.IsNullOrWhiteSpace(sync.NetworkType)) { throw new InvalidTypeException($"NetworkType field is empty in starting network object {obj.name}"); } if (obj == gameObject) { sync.Initialize(sync.ObjectID, sync.NetworkType); continue; } sync.Initialize(NextObjectID, sync.NetworkType); obj.SetActive(false); } StartCoroutine(LoadObjectsCoroutine(startingEntities)); }
// Start is called before the first frame update void Start() { sync = GetComponent <NetworkSync>(); if (GameController.Instance.IsHost) { exampleToggle = false; } }
public void StartNetworkHost() { host = gameObject.AddComponent <NetworkHost>(); NetworkSync sync = gameObject.AddComponent <NetworkSync>(); sync.Initialize(0, "GameController"); host.Initialize(); matchmakingHost = GetComponent <MatchmakingHost>() ?? gameObject.AddComponent <MatchmakingHost>(); }
public void OnChangeArea() { Debug.Log("OnChangeArea called"); // Tell the server we are ready myPlayer = clientNet.Instantiate("Player", Vector3.zero, Quaternion.identity); myPlayer.GetComponent <NetworkSync>().AddToArea(1); playerNetSync = myPlayer.GetComponent <NetworkSync>(); }
void Awake() { netSync = GetComponent(typeof(NetworkSync)) as NetworkSync; netSync.getDataFunction = GetSyncData; netSync.setDataFunction = SetSyncData; interpolationBackTime = netSync.broadcastFrequency * 2; extrapolationTime = netSync.broadcastFrequency; }
public void StartNetworkClient(string roomCode) { client = gameObject.AddComponent <NetworkClient>(); NetworkSync sync = gameObject.AddComponent <NetworkSync>(); sync.Initialize(0, "GameController"); client.Initialize(); matchmakingClient = GetComponent <MatchmakingClient>() ?? gameObject.AddComponent <MatchmakingClient>(); matchmakingClient.JoinRoom = roomCode; }
// Start is called before the first frame update void Awake() { NetworkSync sync = GetComponent <NetworkSync>(); if (sync) { sync.getDataFunction = GetSyncData; sync.setDataFunction = SetSyncData; } }
public static void RequestTrackNetworks(int tracknetwork, int station, int cart, Player player, FreightSystemMonitor monitor) { if (WorldScript.mbIsServer) { NetworkSync.GetTrackNetworks(tracknetwork, station, cart, player); } else { NetworkManager.instance.SendInterfaceCommand(InterfaceName, InterfaceTrackSystems, tracknetwork.ToString() + "," + station.ToString() + "," + cart.ToString(), null, monitor, 0f); } }
public static void RequestNetworkStatus(int netindex, Player player, FreightSystemMonitor monitor) { if (WorldScript.mbIsServer) { NetworkSync.GetNetworkStatus(netindex, player); } else { NetworkManager.instance.SendInterfaceCommand(InterfaceName, InterfaceNetStatus, netindex.ToString(), null, monitor, 0f); } }
void SendAudioDataToServer() { //AudioSource audio = GetComponent<AudioSource>(); //float[] data = new float[audio.clip.samples]; //audio.clip.GetData(data, 0); //Debug.Log ("send " + data.Length + " samples of audio data"); NetworkSync ns = GetComponent <NetworkSync>(); if (ns) { ns.ServerSyncAudio(); } }
public void SetCondition(string condition) { if (gameObject.name != "Player_Sheep(Clone)") { return; } NetworkSync ns = GetComponent <NetworkSync>(); if (ns) { References.client.clientNet.CallRPC("SetCondition", UCNetwork.MessageReceiver.ServerOnly, -1, new object[] { ns.GetId(), condition }); } }
// Start is called before the first frame update void Start() { sync = GetComponent <NetworkSync>(); anim = GetComponent <Animator>(); foreach (AnimatorControllerParameter parameter in anim.parameters) { if (parameter.type != AnimatorControllerParameterType.Trigger) { parameters.Add(new SyncAnimatorParameter() { name = parameter.name, type = parameter.type, value = GetAnimatorParameterValue(parameter.type, parameter.name) }); } } }
void RecorderStop() { if (Microphone.IsRecording("")) { int spos = Microphone.GetPosition(""); float pos = (float)spos / (float)SampleRate; LogManager.Log("trunk stopped at " + pos + " s"); Microphone.End(null); AudioClip clip = AudioClip.Create("TrunkClamped", spos, 1, SampleRate, false); float[] src = new float[record.samples]; record.GetData(src, 0); float[] dst = new float[spos]; for (int i = 0; i < spos; ++i) { dst[i] = src[i]; } clip.SetData(dst, 0); GetComponent <AudioSource>().clip = clip; //clamp SendAudioDataToServer(); } else { if (GetComponent <AudioSource>().clip != null) { GetComponent <AudioSource>().Stop(); } } NetworkSync ns = GetComponent <NetworkSync>(); if (ns) { ns.SyncAudioSource(); } }
public void RegisterNetworkObject(int objectID, string networkType, GameObject networkObj) { if (networkObjects.ContainsKey(objectID)) { throw new InvalidOperationException($"Object ID {objectID} already exists. GameObjects: {networkObjects[objectID].name}, {networkObj.name}"); } RemoveIncorrectComponents(networkObj); // initialize NetworkSync sync = networkObj.GetComponent <NetworkSync>(); if (sync == null) { throw new MissingComponentException($"NetworkSync component is required on Network Object {networkObj.name}"); } sync.Initialize(objectID, networkType); // track created network objects networkObjects[objectID] = networkObj; }
public bool AddNetObject(int aNetworkId, NetworkSync aNetworkSync, GameObject gameObject) { if (netIdObjMap.ContainsKey(aNetworkId)) { Debug.LogError("AddNetObject called with a key that already exists: " + aNetworkId); DestroyObject(gameObject); return(false); } NetIdMapData mapData = new NetIdMapData(); mapData.gameObject = gameObject; mapData.networkSync = aNetworkSync; //mapData.voiceChatPlayer = null; netIdObjMap[aNetworkId] = mapData; return(true); }
void RecorderPlay() { if (Microphone.IsRecording("")) { Microphone.End(null); SendAudioDataToServer(); } if (GetComponent <AudioSource>().clip != null) { GetComponent <AudioSource>().Play(); } NetworkSync ns = GetComponent <NetworkSync>(); if (ns) { ns.SyncAudioSource(); } }
private void AddedEntities() { EntityArray entities = addedSyncEntities.entities; ComponentDataArray <NetworkSync> networkSyncs = addedSyncEntities.networkSyncComponents; for (int i = 0; i < entities.Length; i++) { NetworkSync networkSync = networkSyncs[i]; int instanceId = networkSync.instanceId; NetworkSyncState component = new NetworkSyncState() { actorId = networkManager.LocalPlayerID, networkId = networkManager.GetNetworkId(), }; Entity entity = entities[i]; PostUpdateCommands.AddComponent(entity, component); if (NetworkUtility.CanAssignAuthority(networkManager, networkSync.authority)) { PostUpdateCommands.AddComponent(entity, new NetworktAuthority()); } NetworkEntityData networkEntityData = new NetworkEntityData { InstanceId = networkSync.instanceId, NetworkSyncEntity = new NetworkSyncEntity { ActorId = component.actorId, NetworkId = component.networkId, } }; for (int j = 0; j < AddComponentDataOnEntityAddedMethods.Count; j++) { if (AddComponentDataOnEntityAddedMethods[j].Invoke(this, ref entity, out ComponentDataContainer componentData)) { networkEntityData.ComponentData.Add(componentData); } } ownNetworkSendMessageUtility.AddEntity(networkEntityData); AllNetworkSendMessageUtility.AddEntity(networkEntityData); } }
// A network sync wants to be assigned a network id public void ConnectNetworkSync(NetworkSync aNetworkSync) { // Id's requested from a network sync that this client hasn't instantiated, and the server hasn't created, need to the requested from the server // This handles the case where a NetworkSync is assigned to an object inside of a scene Debug.Log("ClientNetwork::RequestNetworkId - Requesting a network id for network sync " + aNetworkSync.GetInstanceID()); // Let the server know about the new object NetOutgoingMessage sendMsg = client.CreateMessage(); sendMsg.Write((int)MessageType.ConnectNetworkSync); sendMsg.Write(aNetworkSync.position.x); sendMsg.Write(aNetworkSync.position.y); sendMsg.Write(aNetworkSync.position.z); sendMsg.Write(aNetworkSync.rotation.x); sendMsg.Write(aNetworkSync.rotation.y); sendMsg.Write(aNetworkSync.rotation.z); sendMsg.Write(aNetworkSync.rotation.w); sendMsg.Write(aNetworkSync.gameObject.name); client.SendMessage(sendMsg, NetDeliveryMethod.ReliableOrdered); }
public void Play() { AudioSource audio = GetComponent <AudioSource>(); if (audio != null) { audio.Play(); NetworkSync ns = GetComponent <NetworkSync>(); if (ns == null) { ns = gameObject.GetComponentInParent <NetworkSync>(); } if (ns == null) { LogManager.LogWarning("NAObjectBase Play no NetworkSync found !"); } if (ns) { ns.SyncAudioSource(); } } }
public void Stop() { AudioSource audio = GetComponent <AudioSource>(); if (audio != null) { audio.Stop(); NetworkSync ns = GetComponent <NetworkSync>(); if (ns == null) { ns = gameObject.GetComponentInParent <NetworkSync>(); } if (ns == null) { LogManager.LogError("NAObjectBase Stop no NetworkSync found !"); } if (ns) { ns.SyncAudioSource(); } } }
void LooperPlay() { AudioSource audio = GetComponent <AudioSource>(); if (audio != null) { audio.Play(); NetworkSync ns = GetComponent <NetworkSync>(); if (ns == null) { ns = gameObject.GetComponentInParent <NetworkSync>(); } if (ns == null) { LogManager.LogError("Looper sync NetworkSync not found"); } if (ns) { ns.SyncAudioSource(); } } }
// Callback that happens void NetworkInitialized() { // Get the NetworkSync component, set up our function calls NetworkSync sync = gameObject.GetComponent(typeof(NetworkSync)) as NetworkSync; if (sync) { sync.getDataFunction = GetSyncData; sync.setDataFunction = SetSyncData; if (sync.owned) { GetComponent <Renderer>().material.color = Color.green; } else { GetComponent <Renderer>().material.color = Color.grey; } } else { Debug.LogWarning("Unable to get Sync component"); } }
// Start is called before the first frame update void Start() { sync = GetComponent <NetworkSync>(); Update(); }
private void ReceiveNetworkUpdate(byte[] data) { NetworkSyncDataContainer networkSyncDataContainer = messageSerializer.Deserialize(data); if (LogReceivedMessages && (networkSyncDataContainer.AddedNetworkSyncEntities.Any() || networkSyncDataContainer.RemovedNetworkSyncEntities.Any() || networkSyncDataContainer.NetworkSyncDataEntities.Any())) { Debug.Log("ReceiveNetworkUpdate: " + NetworkMessageUtility.ToString(networkSyncDataContainer)); } // added Entities List <NetworkEntityData> addedNetworkSyncEntities = networkSyncDataContainer.AddedNetworkSyncEntities; for (int i = 0; i < addedNetworkSyncEntities.Count; i++) { if (addedNetworkSyncEntities[i].NetworkSyncEntity.ActorId == networkManager.LocalPlayerID) { continue; } Entity entity = reflectionUtility.GetEntityFactoryMethod(addedNetworkSyncEntities[i].InstanceId).Invoke(EntityManager); NetworkSync networkSync = EntityManager.GetComponentData <NetworkSync>(entity); if (NetworkUtility.CanAssignAuthority(networkManager, networkSync.authority)) { PostUpdateCommands.AddComponent(entity, new NetworktAuthority()); } PostUpdateCommands.AddComponent(entity, new NetworkSyncState { actorId = addedNetworkSyncEntities[i].NetworkSyncEntity.ActorId, networkId = addedNetworkSyncEntities[i].NetworkSyncEntity.NetworkId, }); var componentData = addedNetworkSyncEntities[i].ComponentData; for (int j = 0; j < componentData.Count; j++) { ComponentType componentType = reflectionUtility.GetComponentType(componentData[j].ComponentTypeId); AddComponentsMethods[componentType].Invoke(this, entity, componentData[j].MemberData); } if (addedNetworkSyncEntities[i].NetworkSyncEntity.ActorId != networkManager.LocalPlayerID) { NetworkSendSystem.AllNetworkSendMessageUtility.AddEntity(addedNetworkSyncEntities[i]); } } // removed Entities List <NetworkSyncEntity> removedNetworkSyncEntities = networkSyncDataContainer.RemovedNetworkSyncEntities; for (int i = 0; i < removedNetworkSyncEntities.Count; i++) { if (removedNetworkSyncEntities[i].ActorId == networkManager.LocalPlayerID) { continue; } NetworkSyncEntity networkSyncEntity = removedNetworkSyncEntities[i]; int hash = NetworkUtility.GetNetworkEntityHash(networkSyncEntity.ActorId, networkSyncEntity.NetworkId); if (networkEntityMap.TryGetValue(hash, out Entity entity)) { PostUpdateCommands.RemoveComponent <NetworkSyncState>(entity); PostUpdateCommands.DestroyEntity(entity); if (EntityManager.HasComponent <Transform>(entity)) { gameObjectsToDestroy.Add(EntityManager.GetComponentObject <Transform>(entity).gameObject); } for (int j = 0; j < RemoveComponentOnDestroyEntityMethods.Count; j++) { RemoveComponentOnDestroyEntityMethods[j].Invoke(this, entity); } } if (removedNetworkSyncEntities[i].ActorId != networkManager.LocalPlayerID) { NetworkSendSystem.AllNetworkSendMessageUtility.RemoveEntity(removedNetworkSyncEntities[i]); } } // update components List <NetworkSyncDataEntityContainer> networkSyncDataEntities = networkSyncDataContainer.NetworkSyncDataEntities; for (int i = 0; i < networkSyncDataEntities.Count; i++) { NetworkSyncEntity networkSyncEntity = networkSyncDataEntities[i].NetworkSyncEntity; if (networkSyncEntity.ActorId == networkManager.LocalPlayerID) { continue; } int hash = NetworkUtility.GetNetworkEntityHash(networkSyncEntity.ActorId, networkSyncEntity.NetworkId); if (!networkEntityMap.TryGetValue(hash, out Entity entity)) { continue; } List <ComponentDataContainer> addedComponents = networkSyncDataEntities[i].AddedComponents; List <int> removedComponents = networkSyncDataEntities[i].RemovedComponents; List <ComponentDataContainer> componentData = networkSyncDataEntities[i].ComponentData; for (int j = 0; j < addedComponents.Count; j++) { ComponentType componentType = reflectionUtility.GetComponentType(addedComponents[j].ComponentTypeId); AddComponentsMethods[componentType].Invoke(this, entity, addedComponents[j].MemberData); } for (int j = 0; j < componentData.Count; j++) { ComponentType componentType = reflectionUtility.GetComponentType(componentData[j].ComponentTypeId); SetComponentsMethods[componentType].Invoke(this, entity, componentData[j].MemberData); } for (int j = 0; j < removedComponents.Count; j++) { ComponentType componentType = reflectionUtility.GetComponentType(removedComponents[j]); RemoveComponentsMethods[componentType].Invoke(this, entity); } if (networkSyncEntity.ActorId == networkManager.LocalPlayerID) { continue; } NetworkSendSystem.AllNetworkSendMessageUtility.AddComponents(entity, networkSyncEntity.ActorId, networkSyncEntity.NetworkId, addedComponents); NetworkSendSystem.AllNetworkSendMessageUtility.RemoveComponents(entity, networkSyncEntity.ActorId, networkSyncEntity.NetworkId, removedComponents); NetworkSendSystem.AllNetworkSendMessageUtility.SetComponentData(entity, networkSyncEntity.ActorId, networkSyncEntity.NetworkId, componentData); } }
public void Process() { if (downloading) { AssetBundle bundle = NADownloader.GetAssetBundle(download_id); if (bundle != null) //downloaded { downloading = false; GameObject goChild = null; bool bInstantiateObjects = true; if (bInstantiateObjects) { Debug.Log("instantiate object " + name); Object[] objs = bundle.LoadAllAssets(); Debug.Log("Asset Bundle Objects count = " + objs.Length); string[] strAssets = bundle.GetAllAssetNames(); /* * foreach (string s in strAssets) * { * Debug.Log ("Asset = " + s); * } */ /* * foreach (Object o in objs) * { * Debug.Log ("Object " + o.name + " type:" + o.GetType()); * } */ if (bundle.mainAsset == null) //no main Asset in the bundle { Debug.Log("no mainAsset in bundle, manually instantiating objects"); foreach (Object o in objs) { if (o != null) { goChild = GameObject.Instantiate(o) as GameObject; if (goChild != null) { goChild.name = o.name; goChild.transform.parent = go.transform; goChild.transform.localPosition = Vector3.zero; goChild.transform.localEulerAngles = Vector3.zero; //goChild.transform.localScale = Vector3.one; } } } } else { Debug.Log("instantiating mainAsset in bundle"); goChild = GameObject.Instantiate(bundle.mainAsset) as GameObject; goChild.name = bundle.mainAsset.name + id; goChild.transform.parent = go.transform; goChild.transform.localPosition = Vector3.zero; goChild.transform.localEulerAngles = Vector3.zero; //goChild.transform.localScale = Vector3.one; } //NA.PatchMaterials(go); //crashes on 5.3.1 //if (!name.Contains("elevation")) //{ NA.PatchAllMaterials(goChild); //go //} NAObjectLabel lbl = go.GetComponentInChildren <NAObjectLabel>(); if (lbl) { /*Renderer lblr = lbl.gameObject.GetComponent<Renderer>(); * if (lblr != null) * { * lblr.enabled = false; * } */ //fix du collider Collider col = lbl.gameObject.GetComponent <Collider>(); if (col != null) { col.isTrigger = true; } } Light[] lights = go.GetComponentsInChildren <Light>(); Transform[] gameobjects = go.GetComponentsInChildren <Transform>(); AudioListener[] listeners = go.GetComponentsInChildren <AudioListener>(); //exceptions /*if (name.Contains("maki") || name.Contains("SYN")) * { * //unactivate lights * foreach (Light l in lights) * { * l.enabled = false; * * } * * * } */ //we have to scale after instantiation go.transform.localScale = scale; bundle.Unload(false); go.AddComponent <NAViewerOptim>(); sources = go.GetComponentsInChildren <AudioSource>(); //audio sources have to be augmented with specific NA behaviour foreach (AudioSource s in sources) { //NA.DecorateAudioSource(s); s.spatialBlend = 1f; //s.rolloffMode = AudioRolloffMode.Linear; if (s.name == "LightBeam") { s.rolloffMode = AudioRolloffMode.Custom; s.maxDistance = 100f; } } foreach (AudioListener al in listeners) { al.enabled = false; } LogManager.LogWarning(name + " - objects:" + gameobjects.Length + " sources:" + sources.Length + " lights:" + lights.Length); //ESPACES RESONANTS /* * NAReverbResonator[] resonators = NAReverbResonator.FindObjectsOfType(typeof(NAReverbResonator)) as NAReverbResonator[]; * * Debug.Log ("NAReverbResonator count = " + resonators.Length); * foreach (NAReverbResonator r in resonators) * { * NAReverbEffector eff = r.gameObject.GetComponent<NAReverbEffector>(); * if (eff == null) * r.gameObject.AddComponent<NAReverbEffector>(); * * AudioReverbFilter arf = r.gameObject.GetComponent<AudioReverbFilter>(); * if (arf == null) * r.gameObject.AddComponent<AudioReverbFilter>(); * * } */ //jonathan : removed on 1/9/2016 NetworkSync nSync = go.GetComponent <NetworkSync>(); List <GameObject> listSync = new List <GameObject>(); //Oct 2016 : special cases NoiseBall[] nballs = go.GetComponentsInChildren <NoiseBall>(); foreach (NoiseBall nb in nballs) { listSync.Add(nb.gameObject); } //Oct 2016 : get the objects to be custom synced and add to the list NASync[] nasyncs = go.GetComponentsInChildren <NASync>(); foreach (NASync nasync in nasyncs) { listSync.Add(nasync.gameObject); } if (NA.syncMode == SyncMode.RigibodiesAndAudioSources) { /*Rigidbody[] rbs = go.GetComponentsInChildren<Rigidbody>(); * foreach (Rigidbody rb in rbs) * { * listSync.Add(rb.gameObject); * } * AudioSource[] audios = go.GetComponentsInChildren<AudioSource>(); * foreach (AudioSource audio in audios) * { * listSync.Add(audio.gameObject); * } */ Collider[] colliders = go.GetComponentsInChildren <Collider>(); foreach (Collider collider in colliders) { listSync.Add(collider.gameObject); } } if (NA.isServer()) { foreach (GameObject o in listSync) { string path = NA.GetGameObjectPath(o.transform); NetworkViewID id = Network.AllocateViewID(); //LogManager.Log("PrepareAsServer " + path + " id=" + id); go.GetComponent <NetworkView>().RPC("AttachNetworkView", RPCMode.AllBuffered, path, id); } } else if (NA.isClient()) { nSync.AttachNetworkViews(); } /* * * nSync.Prepare(); //client and server (for now, just stops all AudioSources) * if (Network.isServer) * { * if (goChild != null) * { * PrepareAsServer(goChild, goChild.name); * } * } * else * { * nSync.AttachNetworkViews(); * } * */ } } } }
// Use this for initialization void Start() { velocity = Vector3.zero; if (playerPV.isMine) { respawnText = GameObject.Find("Canvas/Respawn").GetComponent<Text>(); cameraTransform = Camera.main.transform; knifeFillImage = GameObject.FindGameObjectWithTag ("Fill").GetComponent<Image> (); knifeFillImage.color = new Color (1, 0, 0, 1); knifeFillImage.fillAmount = 0; canThrow = false; knifeTimer = 0; GetComponent<MeshRenderer>().enabled = true; transform.GetChild(1).GetComponent<MeshRenderer>().enabled = true; } ns = GetComponent<NetworkSync> (); }