non-vr lobby, version fix

This commit is contained in:
joonasp
2022-06-29 14:45:17 +03:00
parent 5774be9822
commit 04baadfad1
1774 changed files with 573069 additions and 1533 deletions

View File

@@ -0,0 +1,27 @@
using Photon.Pun;
using UnityEngine;
[RequireComponent(typeof(Renderer))]
[RequireComponent(typeof(PhotonView))]
public class ChangeColor : MonoBehaviour
{
private PhotonView photonView;
private void Start()
{
this.photonView = this.GetComponent<PhotonView>();
if (this.photonView.IsMine)
{
Color random = Random.ColorHSV();
this.photonView.RPC("ChangeColour", RpcTarget.AllBuffered, new Vector3(random.r, random.g, random.b));
}
}
[PunRPC]
private void ChangeColour(Vector3 randomColor)
{
Renderer renderer = this.GetComponent<Renderer>();
renderer.material.SetColor("_Color", new Color(randomColor.x, randomColor.y, randomColor.z));
}
}

View File

@@ -0,0 +1,12 @@
fileFormatVersion: 2
guid: 22d6d143693d26042907d2430a3477dc
timeCreated: 1561028120
licenseType: Store
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,12 @@
using Photon.Pun;
using UnityEngine;
[RequireComponent(typeof(PhotonView))]
public class ChangeName : MonoBehaviour
{
private void Start()
{
PhotonView photonView = this.GetComponent<PhotonView>();
this.name = string.Format("ActorNumber {0}", photonView.OwnerActorNr);
}
}

View File

@@ -0,0 +1,12 @@
fileFormatVersion: 2
guid: af26de26c990e88409ad9c77bd247b0f
timeCreated: 1561028129
licenseType: Store
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,36 @@
using Photon.Voice.PUN;
using UnityEngine;
[RequireComponent(typeof(PhotonVoiceView))]
public class PointersController : MonoBehaviour
{
#pragma warning disable 649
[SerializeField]
private GameObject pointerDown;
[SerializeField]
private GameObject pointerUp;
#pragma warning restore 649
private PhotonVoiceView photonVoiceView;
private void Awake()
{
this.photonVoiceView = this.GetComponent<PhotonVoiceView>();
this.SetActiveSafe(this.pointerUp, false);
this.SetActiveSafe(this.pointerDown, false);
}
private void Update()
{
this.SetActiveSafe(this.pointerDown, this.photonVoiceView.IsSpeaking);
this.SetActiveSafe(this.pointerUp, this.photonVoiceView.IsRecording);
}
private void SetActiveSafe(GameObject go, bool active)
{
if (go != null && go.activeSelf != active)
{
go.SetActive(active);
}
}
}

View File

@@ -0,0 +1,12 @@
fileFormatVersion: 2
guid: 455698a23ea64d1438d545455ecaf6a2
timeCreated: 1561030091
licenseType: Store
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,212 @@
using System.Collections.Generic;
using Photon.Pun;
using Photon.Voice.PUN;
using Photon.Voice.Unity;
using UnityEngine;
[RequireComponent(typeof(Collider))]
[RequireComponent(typeof(Rigidbody))]
public class ProximityVoiceTrigger : VoiceComponent
{
private List<byte> groupsToAdd = new List<byte>();
private List<byte> groupsToRemove = new List<byte>();
[SerializeField] // TODO: make it readonly
private byte[] subscribedGroups;
private PhotonVoiceView photonVoiceView;
private PhotonView photonView;
public byte TargetInterestGroup
{
get
{
if (this.photonView != null)
{
return (byte)this.photonView.OwnerActorNr;
}
return 0;
}
}
protected override void Awake()
{
this.photonVoiceView = this.GetComponentInParent<PhotonVoiceView>();
this.photonView = this.GetComponentInParent<PhotonView>();
Collider tmpCollider = this.GetComponent<Collider>();
tmpCollider.isTrigger = true;
this.IsLocalCheck();
}
private void ToggleTransmission()
{
if (this.photonVoiceView.RecorderInUse != null)
{
byte group = this.TargetInterestGroup;
if (this.photonVoiceView.RecorderInUse.InterestGroup != group)
{
if (this.Logger.IsInfoEnabled)
{
this.Logger.LogInfo("Setting RecorderInUse's InterestGroup to {0}", group);
}
this.photonVoiceView.RecorderInUse.InterestGroup = group;
}
bool transmitEnabled = this.subscribedGroups != null && this.subscribedGroups.Length > 0;
if (this.photonVoiceView.RecorderInUse.TransmitEnabled != transmitEnabled)
{
if (this.Logger.IsInfoEnabled)
{
this.Logger.LogInfo("Setting RecorderInUse's TransmitEnabled to {0}", transmitEnabled);
}
this.photonVoiceView.RecorderInUse.TransmitEnabled = transmitEnabled;
}
this.photonVoiceView.RecorderInUse.IsRecording = true;
}
}
private void OnTriggerEnter(Collider other)
{
if (this.IsLocalCheck())
{
ProximityVoiceTrigger trigger = other.GetComponent<ProximityVoiceTrigger>();
if (trigger != null)
{
byte group = trigger.TargetInterestGroup;
if (this.Logger.IsDebugEnabled)
{
this.Logger.LogDebug("OnTriggerEnter {0}", group);
}
if (group == this.TargetInterestGroup)
{
return;
}
if (group == 0)
{
return;
}
if (!this.groupsToAdd.Contains(group))
{
this.groupsToAdd.Add(group);
}
}
}
}
private void OnTriggerExit(Collider other)
{
if (this.IsLocalCheck())
{
ProximityVoiceTrigger trigger = other.GetComponent<ProximityVoiceTrigger>();
if (trigger != null)
{
byte group = trigger.TargetInterestGroup;
if (this.Logger.IsDebugEnabled)
{
this.Logger.LogDebug("OnTriggerExit {0}", group);
}
if (group == this.TargetInterestGroup)
{
return;
}
if (group == 0)
{
return;
}
if (this.groupsToAdd.Contains(group))
{
this.groupsToAdd.Remove(group);
}
if (!this.groupsToRemove.Contains(group))
{
this.groupsToRemove.Add(group);
}
}
}
}
private void Update()
{
if (!PhotonVoiceNetwork.Instance.Client.InRoom)
{
this.subscribedGroups = null;
}
else if (this.IsLocalCheck())
{
if (this.groupsToAdd.Count > 0 || this.groupsToRemove.Count > 0)
{
byte[] toAdd = null;
byte[] toRemove = null;
if (this.groupsToAdd.Count > 0)
{
toAdd = this.groupsToAdd.ToArray();
}
if (this.groupsToRemove.Count > 0)
{
toRemove = this.groupsToRemove.ToArray();
}
if (this.Logger.IsInfoEnabled)
{
this.Logger.LogInfo("client of actor number {0} trying to change groups, to_be_removed#:{1} to_be_added#={2}", this.TargetInterestGroup, this.groupsToRemove.Count, this.groupsToAdd.Count);
}
if (PhotonVoiceNetwork.Instance.Client.OpChangeGroups(toRemove, toAdd))
{
if (this.subscribedGroups != null)
{
List<byte> list = new List<byte>();
for (int i = 0; i < this.subscribedGroups.Length; i++)
{
list.Add(this.subscribedGroups[i]);
}
for (int i = 0; i < this.groupsToRemove.Count; i++)
{
if (list.Contains(this.groupsToRemove[i]))
{
list.Remove(this.groupsToRemove[i]);
}
}
for (int i = 0; i < this.groupsToAdd.Count; i++)
{
if (!list.Contains(this.groupsToAdd[i]))
{
list.Add(this.groupsToAdd[i]);
}
}
this.subscribedGroups = list.ToArray();
}
else
{
this.subscribedGroups = toAdd;
}
this.groupsToAdd.Clear();
this.groupsToRemove.Clear();
}
else if (this.Logger.IsErrorEnabled)
{
this.Logger.LogError("Error changing groups");
}
}
this.ToggleTransmission();
}
}
private bool IsLocalCheck()
{
if (this.photonVoiceView.IsPhotonViewReady)
{
if (this.photonView.IsMine)
{
return true;
}
if (this.enabled)
{
if (this.Logger.IsInfoEnabled)
{
this.Logger.LogInfo("Disabling ProximityVoiceTrigger as does not belong to local player, actor number {0}", this.TargetInterestGroup);
}
this.enabled = false;
}
}
return false;
}
}

View File

@@ -0,0 +1,12 @@
fileFormatVersion: 2
guid: 93f52792dd821664a896b3c1c0418b9e
timeCreated: 1560872672
licenseType: Store
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant: