Oculus Avatar

Options
https://doc.photonengine.com/ko-kr/pun/current/demos-and-tutorials/oculusavatarsdk

I am trying to connect the Oculus Avatar with Photon. I made a prefab of LocalAvatar and RemoteAvatar according to the tutorial, but I am not able to follow 'Instantiating Avatars' part. Where is the more detailed description? In fact, I do not even know how to make and apply the script as beginner. Please help me.
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using Photon.Pun;
using Photon.Realtime;

public class Launcher : MonoBehaviour, IOnEventCallback
{

    public readonly byte InstantiateVrAvatarEventCode = 123;

    public void OnJoinedRoom()
    {
        int viewId = PhotonNetwork.AllocateViewID();

        RaiseEventOptions raiseEventOptions = new RaiseEventOptions
        {
            CachingOption = EventCaching.AddToRoomCache,
            Receivers = ReceiverGroup.All
        };


        SendMessageOptions sendOptions = new SendOptions
        {
            Reliability = true
        };

        PhotonNetwork.RaiseEvent(InstantiateVrAvatarEventCode, viewId, raiseEventOptions, sendOptions);

    }

    public void OnEvent(EventData photonEvent)
    {
        GameObject go = null;

        if(PhotonNetwork.LocalPlayer.ActorNumber == photonEvent.Sender)
        {
            go = Instantiate(Resources.Load("LocalAvatar")) as GameObject;
        }
        else
        {
            go = Instantiate(Resources.Load("RemoteAvatar")) as GameObject;
        }

        if(go != null)
        {
            PhotonView pView = go.GetComponent<PhotonView>();

            if (pView != null)
            {
                int viewId = (int)photonEvent.CustomData;

                pView.ViewID = viewId;
            }
        }
    }

    public void OnEnable()
    {
        PhotonNetwork.AddCallbackTarget(this);
    }

    public void OnDisable()
    {
        PhotonNetwork.RemoveCallbackTarget(this);
    }
}

Comments