using UnityEngine; [RequireComponent(typeof(PhotonView))] public class ManualPhotonViewAllocator : MonoBehaviour { public GameObject Prefab; public void AllocateManualPhotonView() { PhotonView photonView = base.gameObject.GetPhotonView(); if (photonView == null) { Debug.LogError("Can't do manual instantiation without PhotonView component."); return; } int num = PhotonNetwork.AllocateViewID(); photonView.RPC("InstantiateRpc", PhotonTargets.AllBuffered, num); } [PunRPC] public void InstantiateRpc(int viewID) { GameObject gameObject = Object.Instantiate(Prefab, InputToEvent.inputHitPos + new Vector3(0f, 5f, 0f), Quaternion.identity); gameObject.GetPhotonView().viewID = viewID; OnClickDestroy component = gameObject.GetComponent(); component.DestroyByRpc = true; } }