Files
UltimateFishing/Assets/Scripts/Assembly-CSharp/ManualPhotonViewAllocator.cs
2026-02-21 16:45:37 +08:00

29 lines
825 B
C#

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<OnClickDestroy>();
component.DestroyByRpc = true;
}
}