FiE-Game/Assets/Photon Unity Networking/UtilityScripts/OnAwakeUsePhotonView.cs

45 lines
1.2 KiB
C#
Raw Normal View History

2023-07-19 19:11:02 +02:00
using ExitGames.Client.Photon;
using UnityEngine;
using System.Collections;
[RequireComponent(typeof(PhotonView))]
public class OnAwakeUsePhotonView : Photon.MonoBehaviour {
// tries to send an RPC as soon as this script awakes (e.g. immediately when instantiated)
void Awake()
{
if (!this.photonView.isMine)
{
return;
}
// Debug.Log("OnAwakeSendRPC.Awake() of " + this + " photonView: " + this.photonView + " this.photonView.instantiationData: " + this.photonView.instantiationData);
this.photonView.RPC("OnAwakeRPC", PhotonTargets.All);
}
// tries to send an RPC as soon as this script starts (e.g. immediately when instantiated)
void Start()
{
if (!this.photonView.isMine)
{
return;
}
// Debug.Log("OnAwakeSendRPC.Start() of " + this + " photonView: " + this.photonView);
this.photonView.RPC("OnAwakeRPC", PhotonTargets.All, (byte)1);
}
[PunRPC]
public void OnAwakeRPC()
{
Debug.Log("RPC: 'OnAwakeRPC' PhotonView: " + this.photonView);
}
[PunRPC]
public void OnAwakeRPC(byte myParameter)
{
Debug.Log("RPC: 'OnAwakeRPC' Parameter: " + myParameter + " PhotonView: " + this.photonView);
}
}