mirror of
https://github.com/FriendshipIsEpic/FiE-Game.git
synced 2024-11-29 08:37:58 +01:00
31 lines
917 B
C#
31 lines
917 B
C#
using UnityEngine;
|
|
using System.Collections;
|
|
|
|
[RequireComponent(typeof(PhotonView))]
|
|
public class ManualPhotonViewAllocator : MonoBehaviour
|
|
{
|
|
public GameObject Prefab;
|
|
|
|
public void AllocateManualPhotonView()
|
|
{
|
|
PhotonView pv = this.gameObject.GetPhotonView();
|
|
if (pv == null)
|
|
{
|
|
Debug.LogError("Can't do manual instantiation without PhotonView component.");
|
|
return;
|
|
}
|
|
|
|
int viewID = PhotonNetwork.AllocateViewID();
|
|
pv.RPC("InstantiateRpc", PhotonTargets.AllBuffered, viewID);
|
|
}
|
|
|
|
[PunRPC]
|
|
public void InstantiateRpc(int viewID)
|
|
{
|
|
GameObject go = GameObject.Instantiate(Prefab, InputToEvent.inputHitPos + new Vector3(0, 5f, 0), Quaternion.identity) as GameObject;
|
|
go.GetPhotonView().viewID = viewID;
|
|
|
|
OnClickDestroy ocd = go.GetComponent<OnClickDestroy>();
|
|
ocd.DestroyByRpc = true;
|
|
}
|
|
}
|