Video chat with photon in unity

PunSystem

using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using Photon.Pun;
using UnityEngine.UI;
public class Punsystem : MonoBehaviour
{
    public PhotonView M_Photonview; //That object we want to use this script, must be have photon view component
    public GameViewDecoder GameViewDecoder; //The component of video decoder for convert the bytes to screen
    public string YourName; //The name of you !!!
    public GameObject Track;
    public Toggle WebCamToggle;
    private void Start()
    {
        YourName = PlayerPrefs.GetString("UserName");
    }
    public void WebCam()
    {
        if (WebCamToggle.isOn == true)
        {
            Track.SetActive(false);
        }
        if (WebCamToggle.isOn == false)
        {
            Track.SetActive(true);
        }
    }
    public void SendMessage(byte[] _byteData, string message, string username)
    {
        M_Photonview.RPC("RPC_SendMessage",RpcTarget.All, _byteData, message);
    }
    [PunRPC]
    private void RPC_SendMessage(byte[] _byteData, string message, string username)
    {
        if (YourName != username)
        {
            if (message.Contains("VideoShare"))
            {
                GameViewDecoder.Action_ProcessImageData(_byteData);
            }
        }
    }
}


Register

using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
using UnityEngine.SceneManagement;
public class Register : MonoBehaviour
{
    public InputField inputname;
    public void GoToScene(string LevelName)
    {
        PlayerPrefs.SetString("UserName", inputname.text);
        SceneManager.LoadScene(LevelName);
    }
}



Content ©2023 Abolfazl Tanha All Rights Reserved​​​​​​​