public void CmdSendGamePrefab(NetworkHash128 vHash) { //Debug.Log(vHash.ToString()); //LobbyManager.Instance.spawnPrefabs.ForEach(x => Debug.Log(x.GetComponent<NetworkIdentity>().assetId.ToString())); GameObject hGamePrefab = LobbyManager.Instance.spawnPrefabs.Where(x => x.GetComponent<NetworkIdentity>().assetId.ToString() == vHash.ToString()).FirstOrDefault(); if (hGamePrefab == null) throw new Exception("Requested Prefab Not Found!"); PrefabToSpawn = hGamePrefab; }
private GameObject SpawnPoolable(Vector3 position, NetworkHash128 assetId) { for (int i = 0; i < localInstances.Count; i ++) { if (localInstances[i].position == position && localInstances[i].GetComponent<NetworkIdentity>().assetId.ToString() == assetId.ToString()) { if (i > 0) { Debug.LogWarning ("The local instance we found as not the first one. That's odd."); } Transform inst = localInstances[i]; localInstances.RemoveAt (i); /* if (callbacks[i] != null) { callbacks[i](inst); } callbacks.RemoveAt (i); */ return inst.gameObject; } } for (int i = 0; i < queuedInstances.Count; i ++) { if (queuedInstances[i].index == assetIdToIndex[assetId] && queuedInstances[i].position == position) { Transform newInst = InstantiateInternal (assetIdToIndex[assetId], queuedInstances[i].tag, queuedInstances[i].layer, position, queuedInstances[i].rotation); return newInst.gameObject; } } Debug.LogWarning ("No queued info available for Spawned prefab"); return null; }