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

56
.vscode/settings.json vendored Normal file
View File

@ -0,0 +1,56 @@
{
"files.exclude":
{
"**/.DS_Store":true,
"**/.git":true,
"**/.gitignore":true,
"**/.gitmodules":true,
"**/*.booproj":true,
"**/*.pidb":true,
"**/*.suo":true,
"**/*.user":true,
"**/*.userprefs":true,
"**/*.unityproj":true,
"**/*.dll":true,
"**/*.exe":true,
"**/*.pdf":true,
"**/*.mid":true,
"**/*.midi":true,
"**/*.wav":true,
"**/*.gif":true,
"**/*.ico":true,
"**/*.jpg":true,
"**/*.jpeg":true,
"**/*.png":true,
"**/*.psd":true,
"**/*.tga":true,
"**/*.tif":true,
"**/*.tiff":true,
"**/*.3ds":true,
"**/*.3DS":true,
"**/*.fbx":true,
"**/*.FBX":true,
"**/*.lxo":true,
"**/*.LXO":true,
"**/*.ma":true,
"**/*.MA":true,
"**/*.obj":true,
"**/*.OBJ":true,
"**/*.asset":true,
"**/*.cubemap":true,
"**/*.flare":true,
"**/*.mat":true,
"**/*.meta":true,
"**/*.prefab":true,
"**/*.unity":true,
"build/":true,
"Build/":true,
"Library/":true,
"library/":true,
"obj/":true,
"Obj/":true,
"ProjectSettings/":true,
"temp/":true,
"Temp/":true
}
}

6
.vsconfig Normal file
View File

@ -0,0 +1,6 @@
{
"version": "1.0",
"components": [
"Microsoft.VisualStudio.Workload.ManagedGame"
]
}

17
Assets/BowOwnership.cs Normal file
View File

@ -0,0 +1,17 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using Photon.Pun;
public class BowOwnership : MonoBehaviourPunCallbacks
{
public void SetOwner()
{
/*if (Physics.SphereCast())
{
photonView.TransferOwnership();
}*/
}
}

View File

@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: d05f42c92d7a7fb4cb691f16698dd1dd
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

44
Assets/CharacterInfo.cs Normal file
View File

@ -0,0 +1,44 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class CharacterInfo : MonoBehaviour
{
public static CharacterInfo Instance;
private Color charColor = Color.white;
private string charName = "";
public CharacterInfo()
{
Instance = this;
}
private void Awake()
{
DontDestroyOnLoad(gameObject);
}
public string GetName()
{
return charName;
}
public void SetName(string name)
{
charName = name;
}
public Color GetCharColor()
{
return charColor;
}
public void SetCharColor(Color color)
{
charColor = color;
}
}

View File

@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: bba9f9f5ffa15e54e80384d4443b41da
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@ -0,0 +1,74 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
using UnityEngine.SceneManagement;
using TMPro;
public class CharacterMenuController : MonoBehaviour
{
public RawImage colorImg;
public Slider redSlider;
public Slider greenSlider;
public Slider blueSlider;
public TMP_InputField nameField;
public Renderer lHand;
public Renderer rHand;
public Renderer Head;
public GameObject handLine;
public GameObject networkManager;
public GameObject menuXR;
public GameObject loadingBox;
private CharacterInfo info;
private void Start()
{
info = CharacterInfo.Instance;
}
public void ColorChange()
{
Debug.Log(redSlider.value + ", " + greenSlider.value + ", " + blueSlider.value);
Color newColor = new Color(redSlider.value, greenSlider.value, blueSlider.value);
lHand.material.color = newColor;
rHand.material.color = newColor;
Head.material.color = newColor;
colorImg.color = newColor;
info.SetCharColor(newColor);
}
public void NameChange()
{
info.SetName(nameField.text);
}
public void JoinRoom()
{
StartCoroutine(JoinDelay());
}
public void OpenKeyboard()
{
TouchScreenKeyboard.Open("");
}
IEnumerator JoinDelay()
{
loadingBox.SetActive(true);
handLine.SetActive(false);
yield return new WaitForSeconds(0.5f);
menuXR.SetActive(false);
Destroy(gameObject);
networkManager.SetActive(true);
}
}

View File

@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 5db8bc4418dd3454da0711edcc3b9aa4
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

44
Assets/CollectionTray.cs Normal file
View File

@ -0,0 +1,44 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class CollectionTray : MonoBehaviour
{
public List<GameObject> row1;
public List<GameObject> row2;
public List<GameObject> row3;
public List<GameObject> row4;
public void RowShow(int i)
{
switch (i)
{
case 1:
foreach(GameObject go in row1)
{
go.SetActive(true);
}
break;
case 2:
foreach (GameObject go in row2)
{
go.SetActive(true);
}
break;
case 3:
foreach (GameObject go in row3)
{
go.SetActive(true);
}
break;
case 4:
foreach (GameObject go in row4)
{
go.SetActive(true);
}
break;
}
}
}

View File

@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 922eba903ed40a84386d5cf96b79e539
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

25
Assets/ColorChanger.cs Normal file
View File

@ -0,0 +1,25 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
using Photon.Pun;
public class ColorChanger : MonoBehaviourPun
{
public List<GameObject> changeObjects;
private void Awake()
{
if (!photonView.IsMine)
{
gameObject.SetActive(false);
}
}
public void ChangeColorPun()
{
photonView.RPC("ChangeColor", RpcTarget.AllBuffered);
}
}

View File

@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 42f5c1d963a66c941bd15d45a504f63b
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

11
Assets/DontDestroy.cs Normal file
View File

@ -0,0 +1,11 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class DontDestroy : MonoBehaviour
{
private void Awake()
{
DontDestroyOnLoad(gameObject);
}
}

View File

@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: fca267f982cfc594caf8574797a89279
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@ -0,0 +1,49 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using Photon.Pun;
public class HideDuplicatePun : MonoBehaviourPun
{
public List<MonoBehaviour> disableScripts;
public List<Renderer> disableMesh;
public Renderer playerHead;
public NetworkPlayerSpawnerVR vrManager;
// Start is called before the first frame update
private void Awake()
{
vrManager = GameObject.FindGameObjectWithTag("NetworkHide").GetComponent<NetworkPlayerSpawnerVR>();
}
// Update is called once per frame
void Update()
{
if (!photonView.IsMine)
{
foreach (MonoBehaviour obj in disableScripts)
{
obj.enabled = false;
}
foreach (Renderer r in disableMesh)
{
r.enabled = false;
}
}
else
{
playerHead.enabled = false;
}
}
private void OnDestroy()
{
Debug.LogWarning("DESTROY");
foreach(GameObject obj in vrManager.spawnedPlayers)
{
obj.SetActive(false);
obj.SetActive(true);
}
}
}

View File

@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 16cd893f6c789f8449e66244639a33ac
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@ -0,0 +1,124 @@
%YAML 1.1
%TAG !u! tag:unity3d.com,2011:
--- !u!114 &-347642447497319774
MonoBehaviour:
m_ObjectHideFlags: 11
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 0}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: d0353a89b1f911e48b9e16bdc9f2e058, type: 3}
m_Name:
m_EditorClassIdentifier:
version: 4
--- !u!21 &2100000
Material:
serializedVersion: 6
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_Name: Loading
m_Shader: {fileID: 4800000, guid: 933532a4fcc9baf4fa0491de14d08ed7, type: 3}
m_ShaderKeywords: _SMOOTHNESS_TEXTURE_ALBEDO_CHANNEL_A _SPECULAR_SETUP
m_LightmapFlags: 4
m_EnableInstancingVariants: 0
m_DoubleSidedGI: 0
m_CustomRenderQueue: 2000
stringTagMap:
RenderType: Opaque
disabledShaderPasses: []
m_SavedProperties:
serializedVersion: 3
m_TexEnvs:
- _BaseMap:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- _BumpMap:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- _DetailAlbedoMap:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- _DetailMask:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- _DetailNormalMap:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- _EmissionMap:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- _MainTex:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- _MetallicGlossMap:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- _OcclusionMap:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- _ParallaxMap:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- _SpecGlossMap:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- unity_Lightmaps:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- unity_LightmapsInd:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- unity_ShadowMasks:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
m_Floats:
- _AlphaClip: 0
- _Blend: 0
- _BumpScale: 1
- _ClearCoatMask: 0
- _ClearCoatSmoothness: 0
- _Cull: 2
- _Cutoff: 0.5
- _DetailAlbedoMapScale: 1
- _DetailNormalMapScale: 1
- _DstBlend: 0
- _EnvironmentReflections: 1
- _GlossMapScale: 0
- _Glossiness: 0
- _GlossyReflections: 0
- _Metallic: 0
- _OcclusionStrength: 1
- _Parallax: 0.005
- _QueueOffset: 0
- _ReceiveShadows: 1
- _Smoothness: 0
- _SmoothnessTextureChannel: 1
- _SpecularHighlights: 1
- _SrcBlend: 1
- _Surface: 0
- _WorkflowMode: 0
- _ZWrite: 1
m_Colors:
- _BaseColor: {r: 0, g: 0, b: 0, a: 1}
- _Color: {r: 1, g: 1, b: 1, a: 1}
- _EmissionColor: {r: 0, g: 0, b: 0, a: 1}
- _SpecColor: {r: 0, g: 0, b: 0, a: 1}
m_BuildTextureStacks: []

View File

@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: 37140baca5fffd649b5b66b9f1a57fd8
NativeFormatImporter:
externalObjects: {}
mainObjectFileID: 2100000
userData:
assetBundleName:
assetBundleVariant:

94
Assets/MenuController.cs Normal file
View File

@ -0,0 +1,94 @@
using Photon.Pun;
using UnityEngine;
public class MenuController : MonoBehaviourPun
{
public GameObject MainPanel;
public GameObject ColorPicker;
public GameObject TeleportPanel;
public GameObject Player;
public VRControls vrControls;
private float cooldownTime;
private bool cooldown;
// Start is called before the first frame update
void Awake()
{
cooldown = false;
vrControls = new VRControls();
if (!photonView.IsMine)
{
vrControls.Disable();
gameObject.SetActive(false);
}
else
{
vrControls.Other.Menu.performed += ctx => MainMenu();
Debug.Log("VRCONTROLS");
}
}
// Update is called once per frame
void Update()
{
if(cooldown && Time.time - cooldownTime < 1f)
{
cooldown = false;
}
}
public void ColorMenu()
{
if (!cooldown)
{
MainPanel.SetActive(false);
ColorPicker.SetActive(true);
cooldownTime = Time.time;
cooldown = true;
}
}
public void MainMenu()
{
if (!cooldown)
{
Debug.Log("METHOD");
MainPanel.SetActive(!MainPanel.activeInHierarchy);
ColorPicker.SetActive(false);
TeleportPanel.SetActive(false);
cooldownTime = Time.time;
cooldown = true;
/*if (MainPanel.activeInHierarchy)
{
Cursor.lockState = CursorLockMode.Confined;
}
else
{
Cursor.lockState = CursorLockMode.Locked;
}*/
}
}
public void TeleportMenu()
{
MainPanel.SetActive(false);
TeleportPanel.SetActive(true);
}
public void Teleport(string teleportTo)
{
GameObject[] objs = GameObject.FindGameObjectsWithTag("Teleport");
foreach(GameObject obj in objs)
{
if(obj.name == teleportTo) Player.transform.position = obj.transform.position;
}
}
}

View File

@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 2f6291c87795a5f488ca9c22d1f50bda
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

8
Assets/Multiplayer.meta Normal file
View File

@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: 377cc3f58b4cee2478d797f115180e49
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,7 @@
fileFormatVersion: 2
guid: 2cac614b54ea2ca4c8e4e74666565dc9
PrefabImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

View File

@ -0,0 +1,91 @@
using System;
using System.Collections.Generic;
using UnityEngine.InputSystem;
using Photon.Pun;
namespace UnityEngine.XR.Interaction.Toolkit.Inputs
{
/// <summary>
/// Use this class to automatically enable or disable all the inputs of type <see cref="InputAction"/>
/// in a list of assets of type <see cref="InputActionAsset"/>.
/// </summary>
/// <remarks>
/// Actions are initially disabled, meaning they do not listen/react to input yet. This class
/// is used to mass enable actions so that they actively listen for input and run callbacks.
/// </remarks>
/// <seealso cref="InputAction"/>
public class InputActionManager : MonoBehaviourPunCallbacks
{
[SerializeField]
[Tooltip("Input action assets to affect when inputs are enabled or disabled.")]
List<InputActionAsset> m_ActionAssets;
/// <summary>
/// Input action assets to affect when inputs are enabled or disabled.
/// </summary>
public List<InputActionAsset> actionAssets
{
get => m_ActionAssets;
set => m_ActionAssets = value ?? throw new ArgumentNullException(nameof(value));
}
protected void OnEnable()
{
if(photonView.IsMine) EnableInput();
}
protected void OnDisable()
{
if (photonView.IsMine) DisableInput();
}
/// <summary>
/// Enable all actions referenced by this component.
/// </summary>
/// <remarks>
/// This function will automatically be called when this <see cref="InputActionManager"/> component is enabled.
/// However, this method can be called to enable input manually, such as after disabling it with <see cref="DisableInput"/>.
/// <br />
/// Note that enabling inputs will only enable the action maps contained within the referenced
/// action map assets (see <see cref="actionAssets"/>).
/// </remarks>
/// <seealso cref="DisableInput"/>
public void EnableInput()
{
if (m_ActionAssets == null)
return;
foreach (var actionAsset in m_ActionAssets)
{
if (actionAsset != null)
{
actionAsset.Enable();
}
}
}
/// <summary>
/// Disable all actions referenced by this component.
/// </summary>
/// <remarks>
/// This function will automatically be called when this <see cref="InputActionManager"/> component is disabled.
/// However, this method can be called to disable input manually, such as after enabling it with <see cref="EnableInput"/>.
/// <br />
/// Note that disabling inputs will only disable the action maps contained within the referenced
/// action map assets (see <see cref="actionAssets"/>).
/// </remarks>
/// <seealso cref="EnableInput"/>
public void DisableInput()
{
if (m_ActionAssets == null)
return;
foreach (var actionAsset in m_ActionAssets)
{
if (actionAsset != null)
{
actionAsset.Disable();
}
}
}
}
}

View File

@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: fdb3ce2756dc5ee45b91b43fbad16192
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@ -0,0 +1,372 @@
%YAML 1.1
%TAG !u! tag:unity3d.com,2011:
--- !u!1 &3792194066035821785
GameObject:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
serializedVersion: 6
m_Component:
- component: {fileID: 2728055905554767678}
- component: {fileID: 6470632201704000592}
m_Layer: 0
m_Name: Point Light
m_TagString: Untagged
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
m_IsActive: 1
--- !u!4 &2728055905554767678
Transform:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 3792194066035821785}
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
m_LocalPosition: {x: 0.084, y: 1.065, z: 0.77}
m_LocalScale: {x: 1, y: 1, z: 1}
m_Children: []
m_Father: {fileID: 3917920774390578430}
m_RootOrder: 3
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
--- !u!108 &6470632201704000592
Light:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 3792194066035821785}
m_Enabled: 1
serializedVersion: 10
m_Type: 2
m_Shape: 0
m_Color: {r: 1, g: 1, b: 1, a: 1}
m_Intensity: 0.1
m_Range: 10
m_SpotAngle: 30
m_InnerSpotAngle: 21.80208
m_CookieSize: 10
m_Shadows:
m_Type: 0
m_Resolution: -1
m_CustomResolution: -1
m_Strength: 1
m_Bias: 0.05
m_NormalBias: 0.4
m_NearPlane: 0.2
m_CullingMatrixOverride:
e00: 1
e01: 0
e02: 0
e03: 0
e10: 0
e11: 1
e12: 0
e13: 0
e20: 0
e21: 0
e22: 1
e23: 0
e30: 0
e31: 0
e32: 0
e33: 1
m_UseCullingMatrixOverride: 0
m_Cookie: {fileID: 0}
m_DrawHalo: 0
m_Flare: {fileID: 0}
m_RenderMode: 0
m_CullingMask:
serializedVersion: 2
m_Bits: 4294967295
m_RenderingLayerMask: 1
m_Lightmapping: 4
m_LightShadowCasterMode: 0
m_AreaSize: {x: 1, y: 1}
m_BounceIntensity: 1
m_ColorTemperature: 6570
m_UseColorTemperature: 0
m_BoundingSphereOverride: {x: 0, y: 0, z: 0, w: 0}
m_UseBoundingSphereOverride: 0
m_UseViewFrustumForShadowCasterCull: 1
m_ShadowRadius: 0
m_ShadowAngle: 0
--- !u!1 &3917920774390578431
GameObject:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
serializedVersion: 6
m_Component:
- component: {fileID: 3917920774390578430}
m_Layer: 0
m_Name: Mannequin
m_TagString: Untagged
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
m_IsActive: 1
--- !u!4 &3917920774390578430
Transform:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 3917920774390578431}
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
m_LocalPosition: {x: -0.954, y: 0, z: -0.174}
m_LocalScale: {x: 1, y: 1, z: 1}
m_Children:
- {fileID: 3917920775105521855}
- {fileID: 3917920775328741170}
- {fileID: 3917920774592251871}
- {fileID: 2728055905554767678}
m_Father: {fileID: 0}
m_RootOrder: 0
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
--- !u!1 &3917920774592251808
GameObject:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
serializedVersion: 6
m_Component:
- component: {fileID: 3917920774592251871}
- component: {fileID: 3917920774592251869}
- component: {fileID: 3917920774592251870}
m_Layer: 0
m_Name: Lhand
m_TagString: Untagged
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
m_IsActive: 1
--- !u!4 &3917920774592251871
Transform:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 3917920774592251808}
m_LocalRotation: {x: -0, y: 0.42993057, z: -0, w: 0.90286195}
m_LocalPosition: {x: -0.0510298, y: 0.722, z: 0.28198734}
m_LocalScale: {x: 1, y: 1, z: 1}
m_Children: []
m_Father: {fileID: 3917920774390578430}
m_RootOrder: 2
m_LocalEulerAnglesHint: {x: 0, y: 50.926, z: 0}
--- !u!23 &3917920774592251869
MeshRenderer:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 3917920774592251808}
m_Enabled: 1
m_CastShadows: 1
m_ReceiveShadows: 1
m_DynamicOccludee: 1
m_MotionVectors: 1
m_LightProbeUsage: 1
m_ReflectionProbeUsage: 1
m_RayTracingMode: 2
m_RayTraceProcedural: 0
m_RenderingLayerMask: 1
m_RendererPriority: 0
m_Materials:
- {fileID: -7974662883447924875, guid: cf1947c0fc791164285826ce282c815b, type: 3}
m_StaticBatchInfo:
firstSubMesh: 0
subMeshCount: 0
m_StaticBatchRoot: {fileID: 0}
m_ProbeAnchor: {fileID: 0}
m_LightProbeVolumeOverride: {fileID: 0}
m_ScaleInLightmap: 1
m_ReceiveGI: 1
m_PreserveUVs: 0
m_IgnoreNormalsForChartDetection: 0
m_ImportantGI: 0
m_StitchLightmapSeams: 1
m_SelectedEditorRenderState: 3
m_MinimumChartSize: 4
m_AutoUVMaxDistance: 0.5
m_AutoUVMaxAngle: 89
m_LightmapParameters: {fileID: 0}
m_SortingLayerID: 0
m_SortingLayer: 0
m_SortingOrder: 0
m_AdditionalVertexStreams: {fileID: 0}
--- !u!33 &3917920774592251870
MeshFilter:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 3917920774592251808}
m_Mesh: {fileID: 4300000, guid: ca20b3907ff1c794cb89c1ad2cce8282, type: 3}
--- !u!1 &3917920775105521792
GameObject:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
serializedVersion: 6
m_Component:
- component: {fileID: 3917920775105521855}
- component: {fileID: 3917920775105521853}
- component: {fileID: 3917920775105521854}
m_Layer: 0
m_Name: Head
m_TagString: Untagged
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
m_IsActive: 1
--- !u!4 &3917920775105521855
Transform:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 3917920775105521792}
m_LocalRotation: {x: -0.6532815, y: 0.27059805, z: 0.27059805, w: 0.6532815}
m_LocalPosition: {x: -0.315, y: 1.026, z: 0.315}
m_LocalScale: {x: 0.05, y: 0.05, z: 0.05}
m_Children: []
m_Father: {fileID: 3917920774390578430}
m_RootOrder: 0
m_LocalEulerAnglesHint: {x: -90, y: 45, z: 0}
--- !u!33 &3917920775105521853
MeshFilter:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 3917920775105521792}
m_Mesh: {fileID: -462981019419857548, guid: e4b72324637d359459d572e99ea05981, type: 3}
--- !u!23 &3917920775105521854
MeshRenderer:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 3917920775105521792}
m_Enabled: 1
m_CastShadows: 1
m_ReceiveShadows: 1
m_DynamicOccludee: 1
m_MotionVectors: 1
m_LightProbeUsage: 1
m_ReflectionProbeUsage: 1
m_RayTracingMode: 2
m_RayTraceProcedural: 0
m_RenderingLayerMask: 1
m_RendererPriority: 0
m_Materials:
- {fileID: 8598954236217306308, guid: e4b72324637d359459d572e99ea05981, type: 3}
m_StaticBatchInfo:
firstSubMesh: 0
subMeshCount: 0
m_StaticBatchRoot: {fileID: 0}
m_ProbeAnchor: {fileID: 0}
m_LightProbeVolumeOverride: {fileID: 0}
m_ScaleInLightmap: 1
m_ReceiveGI: 1
m_PreserveUVs: 0
m_IgnoreNormalsForChartDetection: 0
m_ImportantGI: 0
m_StitchLightmapSeams: 1
m_SelectedEditorRenderState: 3
m_MinimumChartSize: 4
m_AutoUVMaxDistance: 0.5
m_AutoUVMaxAngle: 89
m_LightmapParameters: {fileID: 0}
m_SortingLayerID: 0
m_SortingLayer: 0
m_SortingOrder: 0
m_AdditionalVertexStreams: {fileID: 0}
--- !u!1 &3917920775328741171
GameObject:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
serializedVersion: 6
m_Component:
- component: {fileID: 3917920775328741170}
- component: {fileID: 3917920775328741168}
- component: {fileID: 3917920775328741169}
m_Layer: 0
m_Name: Rhand
m_TagString: Untagged
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
m_IsActive: 1
--- !u!4 &3917920775328741170
Transform:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 3917920775328741171}
m_LocalRotation: {x: 0.110257715, y: 0.30503958, z: -0.038682856, w: 0.94514436}
m_LocalPosition: {x: -0.442, y: 0.722, z: 0.605}
m_LocalScale: {x: 1, y: 1, z: 1}
m_Children: []
m_Father: {fileID: 3917920774390578430}
m_RootOrder: 1
m_LocalEulerAnglesHint: {x: 13.416, y: 35.734, z: -0.345}
--- !u!23 &3917920775328741168
MeshRenderer:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 3917920775328741171}
m_Enabled: 1
m_CastShadows: 1
m_ReceiveShadows: 1
m_DynamicOccludee: 1
m_MotionVectors: 1
m_LightProbeUsage: 1
m_ReflectionProbeUsage: 1
m_RayTracingMode: 2
m_RayTraceProcedural: 0
m_RenderingLayerMask: 1
m_RendererPriority: 0
m_Materials:
- {fileID: -7974662883447924875, guid: cf1947c0fc791164285826ce282c815b, type: 3}
m_StaticBatchInfo:
firstSubMesh: 0
subMeshCount: 0
m_StaticBatchRoot: {fileID: 0}
m_ProbeAnchor: {fileID: 0}
m_LightProbeVolumeOverride: {fileID: 0}
m_ScaleInLightmap: 1
m_ReceiveGI: 1
m_PreserveUVs: 0
m_IgnoreNormalsForChartDetection: 0
m_ImportantGI: 0
m_StitchLightmapSeams: 1
m_SelectedEditorRenderState: 3
m_MinimumChartSize: 4
m_AutoUVMaxDistance: 0.5
m_AutoUVMaxAngle: 89
m_LightmapParameters: {fileID: 0}
m_SortingLayerID: 0
m_SortingLayer: 0
m_SortingOrder: 0
m_AdditionalVertexStreams: {fileID: 0}
--- !u!33 &3917920775328741169
MeshFilter:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 3917920775328741171}
m_Mesh: {fileID: 4300000, guid: d0c255d07fd68f14b94e55d388e7e6bb, type: 3}

View File

@ -0,0 +1,7 @@
fileFormatVersion: 2
guid: 46f5a71041d598b4d8183883b67ba09c
PrefabImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,7 @@
fileFormatVersion: 2
guid: c05533743467d3d4ca4564c956e7a59a
PrefabImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

View File

@ -0,0 +1,53 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using Photon.Pun;
using Photon.Realtime;
//The following script is made following this tutorial: https://www.youtube.com/watch?v=KHWuTBmT1oI
public class NetworkManager : MonoBehaviourPunCallbacks
{
// Start is called before the first frame update
void Start()
{
ConnectToServer();
}
// Update is called once per frame
void Update()
{
}
void ConnectToServer()
{
PhotonNetwork.ConnectUsingSettings();
Debug.Log("Connecting...");
}
public override void OnConnectedToMaster()
{
Debug.Log("Connected");
base.OnConnectedToMaster();
RoomOptions roomOptions = new RoomOptions();
roomOptions.MaxPlayers = 16;
roomOptions.IsVisible = true;
roomOptions.IsOpen = true;
PhotonNetwork.JoinOrCreateRoom("Room 1", roomOptions, TypedLobby.Default);
}
public override void OnJoinedRoom()
{
Debug.Log("Room joined");
base.OnJoinedRoom();
}
public override void OnPlayerEnteredRoom(Player newPlayer)
{
Debug.Log("Player joined");
base.OnPlayerEnteredRoom(newPlayer);
}
}

View File

@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: c9fef1b6669975745b2d3fcaf95d28a8
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@ -0,0 +1,28 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using Photon.Pun;
using Photon.Realtime;
using TMPro;
//The following script is made following this tutorial: https://www.youtube.com/watch?v=KHWuTBmT1oI
public class NetworkPlayerSpawner : MonoBehaviourPunCallbacks
{
public GameObject spawnedPlayer;
public override void OnJoinedRoom()
{
base.OnJoinedRoom();
GameObject player = PhotonNetwork.Instantiate("Player_VRFree_Network", transform.position, transform.rotation);
}
public override void OnLeftRoom()
{
base.OnLeftRoom();
PhotonNetwork.Destroy(spawnedPlayer);
}
}

View File

@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: f6282c5def507c04ebed0b2a3a3a6c32
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@ -0,0 +1,37 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.XR.Interaction.Toolkit;
using Photon.Pun;
using Photon.Realtime;
//The following script is made following this tutorial: https://www.youtube.com/watch?v=KHWuTBmT1oI
public class NetworkPlayerSpawnerVR : MonoBehaviourPunCallbacks
{
public GameObject spawnedPlayer;
public List<GameObject> spawnedPlayers = new List<GameObject>();
public TeleportationProvider teleportationProvider;
public override void OnJoinedRoom()
{
base.OnJoinedRoom();
GameObject player = PhotonNetwork.Instantiate("XR Rig_Network", transform.position, transform.rotation);
if (CharacterInfo.Instance.GetName() == "") player.name = player.GetPhotonView().ViewID.ToString();
else player.name = CharacterInfo.Instance.GetName();
spawnedPlayers.Add(player);
if (player.GetPhotonView().IsMine)
{
teleportationProvider.system = player.GetComponent<LocomotionSystem>();
}
}
public override void OnLeftRoom()
{
base.OnLeftRoom();
PhotonNetwork.Destroy(spawnedPlayer);
}
}

View File

@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: b3a6fa0e963fe604e89eb6240e730208
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@ -0,0 +1,23 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using Photon.Pun;
using Photon.Realtime;
public class VRNetworkController : MonoBehaviourPunCallbacks
{
private void Awake()
{
print("TEST");
if (!photonView.IsMine)
{
gameObject.SetActive(false);
}
else
{
gameObject.SetActive(true);
}
}
}

View File

@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 97a830a1f9a7d544ab0c5433bf3a493e
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,7 @@
fileFormatVersion: 2
guid: a557f9ff5cea35a4dbbb7ac8b20533a3
PrefabImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

View File

@ -10,7 +10,7 @@ PrefabInstance:
- target: {fileID: 2376408783022628303, guid: c7190c7182dc47944b0a50b8b43c2a0a, - target: {fileID: 2376408783022628303, guid: c7190c7182dc47944b0a50b8b43c2a0a,
type: 3} type: 3}
propertyPath: m_Name propertyPath: m_Name
value: CGVR Lab Door value: Indoor Door Left
objectReference: {fileID: 0} objectReference: {fileID: 0}
- target: {fileID: 2389456291377549788, guid: c7190c7182dc47944b0a50b8b43c2a0a, - target: {fileID: 2389456291377549788, guid: c7190c7182dc47944b0a50b8b43c2a0a,
type: 3} type: 3}
@ -85,12 +85,12 @@ PrefabInstance:
- target: {fileID: 7524997068079331246, guid: c7190c7182dc47944b0a50b8b43c2a0a, - target: {fileID: 7524997068079331246, guid: c7190c7182dc47944b0a50b8b43c2a0a,
type: 3} type: 3}
propertyPath: m_Layer propertyPath: m_Layer
value: 31 value: 5
objectReference: {fileID: 0} objectReference: {fileID: 0}
- target: {fileID: 7641886289678632063, guid: c7190c7182dc47944b0a50b8b43c2a0a, - target: {fileID: 7641886289678632063, guid: c7190c7182dc47944b0a50b8b43c2a0a,
type: 3} type: 3}
propertyPath: m_Layer propertyPath: m_Layer
value: 0 value: 5
objectReference: {fileID: 0} objectReference: {fileID: 0}
- target: {fileID: 8606222079484180125, guid: c7190c7182dc47944b0a50b8b43c2a0a, - target: {fileID: 8606222079484180125, guid: c7190c7182dc47944b0a50b8b43c2a0a,
type: 3} type: 3}
@ -100,7 +100,7 @@ PrefabInstance:
- target: {fileID: 8606222079484180125, guid: c7190c7182dc47944b0a50b8b43c2a0a, - target: {fileID: 8606222079484180125, guid: c7190c7182dc47944b0a50b8b43c2a0a,
type: 3} type: 3}
propertyPath: m_ConnectedAnchor.z propertyPath: m_ConnectedAnchor.z
value: -0.35998628 value: -0.359999
objectReference: {fileID: 0} objectReference: {fileID: 0}
- target: {fileID: 8606222079484180125, guid: c7190c7182dc47944b0a50b8b43c2a0a, - target: {fileID: 8606222079484180125, guid: c7190c7182dc47944b0a50b8b43c2a0a,
type: 3} type: 3}

View File

@ -300,7 +300,7 @@ GameObject:
- component: {fileID: 6830999020486091146} - component: {fileID: 6830999020486091146}
- component: {fileID: 8579609115951157415} - component: {fileID: 8579609115951157415}
- component: {fileID: 8606222079484180125} - component: {fileID: 8606222079484180125}
m_Layer: 31 m_Layer: 5
m_Name: VR-door m_Name: VR-door
m_TagString: Untagged m_TagString: Untagged
m_Icon: {fileID: 0} m_Icon: {fileID: 0}
@ -491,7 +491,7 @@ HingeJoint:
m_Anchor: {x: -0.5, y: 0, z: 0} m_Anchor: {x: -0.5, y: 0, z: 0}
m_Axis: {x: 0, y: -0.4, z: 0} m_Axis: {x: 0, y: -0.4, z: 0}
m_AutoConfigureConnectedAnchor: 1 m_AutoConfigureConnectedAnchor: 1
m_ConnectedAnchor: {x: -3.2937446, y: -0.01233997, z: -0.3599955} m_ConnectedAnchor: {x: -3.2937627, y: -0.012340516, z: -0.359999}
m_UseSpring: 0 m_UseSpring: 0
m_Spring: m_Spring:
spring: 0 spring: 0
@ -527,7 +527,7 @@ GameObject:
- component: {fileID: 1563113102796242720} - component: {fileID: 1563113102796242720}
- component: {fileID: 8357273141740731653} - component: {fileID: 8357273141740731653}
- component: {fileID: 5489323224948033285} - component: {fileID: 5489323224948033285}
m_Layer: 0 m_Layer: 5
m_Name: Knob m_Name: Knob
m_TagString: Untagged m_TagString: Untagged
m_Icon: {fileID: 0} m_Icon: {fileID: 0}

View File

@ -459,6 +459,8 @@ GameObject:
- component: {fileID: 705318187586076703} - component: {fileID: 705318187586076703}
- component: {fileID: 420424634} - component: {fileID: 420424634}
- component: {fileID: 420424635} - component: {fileID: 420424635}
- component: {fileID: 6192141795265968197}
- component: {fileID: 2971467179744955774}
m_Layer: 0 m_Layer: 0
m_Name: Bow m_Name: Bow
m_TagString: Untagged m_TagString: Untagged
@ -614,6 +616,45 @@ Rigidbody:
m_Interpolate: 0 m_Interpolate: 0
m_Constraints: 0 m_Constraints: 0
m_CollisionDetection: 0 m_CollisionDetection: 0
--- !u!114 &6192141795265968197
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 2589571369817754473}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: aa584fbee541324448dd18d8409c7a41, type: 3}
m_Name:
m_EditorClassIdentifier:
ObservedComponentsFoldoutOpen: 1
Group: 0
prefixField: -1
Synchronization: 3
OwnershipTransfer: 0
observableSearch: 2
ObservedComponents:
- {fileID: 2971467179744955774}
sceneViewId: 0
InstantiationId: 0
isRuntimeInstantiated: 0
--- !u!114 &2971467179744955774
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 2589571369817754473}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: 627855c7f81362d41938ffe0b1475957, type: 3}
m_Name:
m_EditorClassIdentifier:
m_SynchronizePosition: 1
m_SynchronizeRotation: 1
m_SynchronizeScale: 0
m_UseLocal: 1
--- !u!1 &2938454372705689396 --- !u!1 &2938454372705689396
GameObject: GameObject:
m_ObjectHideFlags: 0 m_ObjectHideFlags: 0

View File

@ -12,7 +12,7 @@ GameObject:
- component: {fileID: 4822481401631496130} - component: {fileID: 4822481401631496130}
m_Layer: 0 m_Layer: 0
m_Name: LeftHandPresence m_Name: LeftHandPresence
m_TagString: Untagged m_TagString: NetworkHide
m_Icon: {fileID: 0} m_Icon: {fileID: 0}
m_NavMeshLayer: 0 m_NavMeshLayer: 0
m_StaticEditorFlags: 0 m_StaticEditorFlags: 0

View File

@ -12,7 +12,7 @@ GameObject:
- component: {fileID: 4822481401631496130} - component: {fileID: 4822481401631496130}
m_Layer: 0 m_Layer: 0
m_Name: RightHandPresence m_Name: RightHandPresence
m_TagString: Untagged m_TagString: NetworkHide
m_Icon: {fileID: 0} m_Icon: {fileID: 0}
m_NavMeshLayer: 0 m_NavMeshLayer: 0
m_StaticEditorFlags: 0 m_StaticEditorFlags: 0

View File

@ -1,63 +0,0 @@
using UnityEngine;
using System.Collections;
/// MouseLook rotates the transform based on the mouse delta.
/// Minimum and Maximum values can be used to constrain the possible rotation
/// To make an FPS style character:
/// - Create a capsule.
/// - Add the MouseLook script to the capsule.
/// -> Set the mouse look to use LookX. (You want to only turn character but not tilt it)
/// - Add FPSInputController script to the capsule
/// -> A CharacterMotor and a CharacterController component will be automatically added.
/// - Create a camera. Make the camera a child of the capsule. Reset it's transform.
/// - Add a MouseLook script to the camera.
/// -> Set the mouse look to use LookY. (You want the camera to tilt up and down like a head. The character already turns.)
[AddComponentMenu("Camera-Control/Mouse Look")]
public class MouseLook : MonoBehaviour {
public enum RotationAxes { MouseXAndY = 0, MouseX = 1, MouseY = 2 }
public RotationAxes axes = RotationAxes.MouseXAndY;
public float sensitivityX = 15F;
public float sensitivityY = 15F;
public float minimumX = -360F;
public float maximumX = 360F;
public float minimumY = -60F;
public float maximumY = 60F;
float rotationY = 0F;
void Update ()
{
if (axes == RotationAxes.MouseXAndY)
{
float rotationX = transform.localEulerAngles.y + Input.GetAxis("Mouse X") * sensitivityX;
rotationY += Input.GetAxis("Mouse Y") * sensitivityY;
rotationY = Mathf.Clamp (rotationY, minimumY, maximumY);
transform.localEulerAngles = new Vector3(-rotationY, rotationX, 0);
}
else if (axes == RotationAxes.MouseX)
{
transform.Rotate(0, Input.GetAxis("Mouse X") * sensitivityX, 0);
}
else
{
rotationY += Input.GetAxis("Mouse Y") * sensitivityY;
rotationY = Mathf.Clamp (rotationY, minimumY, maximumY);
transform.localEulerAngles = new Vector3(-rotationY, transform.localEulerAngles.y, 0);
}
}
void Start ()
{
// Make the rigid body not change rotation
if (GetComponent<Rigidbody>())
GetComponent<Rigidbody>().freezeRotation = true;
}
}

27
Assets/OtherControls.cs Normal file
View File

@ -0,0 +1,27 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using Photon.Pun;
public class OtherControls : MonoBehaviourPunCallbacks
{
public List<MonoBehaviour> toDisable = new List<MonoBehaviour>();
// Start is called before the first frame update
void Start()
{
if (!photonView.IsMine)
{
foreach (var t in toDisable)
{
t.enabled = false;
}
}
}
// Update is called once per frame
void Update()
{
}
}

View File

@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 5fa6d0734431d6b47952a7f749fc7f46
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

9
Assets/Photon.meta Normal file
View File

@ -0,0 +1,9 @@
fileFormatVersion: 2
guid: 98951132346795f438babe7a3183da43
folderAsset: yes
timeCreated: 1523536679
licenseType: Store
DefaultImporter:
userData:
assetBundleName:
assetBundleVariant:

View File

@ -0,0 +1,7 @@
fileFormatVersion: 2
guid: ea05e6479d592944d955c2a5e1a6d6f1
folderAsset: yes
DefaultImporter:
userData:
assetBundleName:
assetBundleVariant:

View File

@ -0,0 +1,9 @@
fileFormatVersion: 2
guid: af83a98aaa4f7b64eb7fcec95ee7b1ed
folderAsset: yes
timeCreated: 1523525757
licenseType: Store
DefaultImporter:
userData:
assetBundleName:
assetBundleVariant:

View File

@ -0,0 +1,22 @@
// ----------------------------------------------------------------------------------------------------------------------
// <summary>The Photon Chat Api enables clients to connect to a chat server and communicate with other clients.</summary>
// <remarks>ChannelCreationOptions is a parameter used when subscribing to a public channel for the first time.</remarks>
// <copyright company="Exit Games GmbH">Photon Chat Api - Copyright (C) 2018 Exit Games GmbH</copyright>
// ----------------------------------------------------------------------------------------------------------------------
namespace Photon.Chat
{
public class ChannelCreationOptions
{
/// <summary>Default values of channel creation options.</summary>
public static ChannelCreationOptions Default = new ChannelCreationOptions();
/// <summary>Whether or not the channel to be created will allow client to keep a list of users.</summary>
public bool PublishSubscribers { get; set; }
/// <summary>Limit of the number of users subscribed to the channel to be created.</summary>
public int MaxSubscribers { get; set; }
#if CHAT_EXTENDED
public System.Collections.Generic.Dictionary<string, object> CustomProperties { get; set; }
#endif
}
}

View File

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

View File

@ -0,0 +1,14 @@
// ----------------------------------------------------------------------------------------------------------------------
// <summary>The Photon Chat Api enables clients to connect to a chat server and communicate with other clients.</summary>
// <remarks>ChannelWellKnownProperties contains the list of well-known channel properties.</remarks>
// <copyright company="Exit Games GmbH">Photon Chat Api - Copyright (C) 2018 Exit Games GmbH</copyright>
// ----------------------------------------------------------------------------------------------------------------------
namespace Photon.Chat
{
public class ChannelWellKnownProperties
{
public const byte MaxSubscribers = 255;
public const byte PublishSubscribers = 254;
}
}

View File

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

View File

@ -0,0 +1,73 @@
// -----------------------------------------------------------------------
// <copyright file="ChatAppSettings.cs" company="Exit Games GmbH">
// Chat API for Photon - Copyright (C) 2018 Exit Games GmbH
// </copyright>
// <summary>Settings for Photon Chat application and the server to connect to.</summary>
// <author>developer@photonengine.com</author>
// ----------------------------------------------------------------------------
#if UNITY_4_7 || UNITY_5 || UNITY_5_3_OR_NEWER
#define SUPPORTED_UNITY
#endif
namespace Photon.Chat
{
using System;
using ExitGames.Client.Photon;
#if SUPPORTED_UNITY
using UnityEngine.Serialization;
#endif
/// <summary>
/// Settings for Photon application(s) and the server to connect to.
/// </summary>
/// <remarks>
/// This is Serializable for Unity, so it can be included in ScriptableObject instances.
/// </remarks>
#if !NETFX_CORE || SUPPORTED_UNITY
[Serializable]
#endif
public class ChatAppSettings
{
/// <summary>AppId for the Chat Api.</summary>
#if SUPPORTED_UNITY
[FormerlySerializedAs("AppId")]
#endif
public string AppIdChat;
/// <summary>The AppVersion can be used to identify builds and will split the AppId distinct "Virtual AppIds" (important for the users to find each other).</summary>
public string AppVersion;
/// <summary>Can be set to any of the Photon Cloud's region names to directly connect to that region.</summary>
public string FixedRegion;
/// <summary>The address (hostname or IP) of the server to connect to.</summary>
public string Server;
/// <summary>If not null, this sets the port of the first Photon server to connect to (that will "forward" the client as needed).</summary>
public ushort Port;
/// <summary>The network level protocol to use.</summary>
public ConnectionProtocol Protocol = ConnectionProtocol.Udp;
/// <summary>Enables a fallback to another protocol in case a connect to the Name Server fails.</summary>
/// <remarks>See: LoadBalancingClient.EnableProtocolFallback.</remarks>
public bool EnableProtocolFallback = true;
/// <summary>Log level for the network lib.</summary>
public DebugLevel NetworkLogging = DebugLevel.ERROR;
/// <summary>If true, the default nameserver address for the Photon Cloud should be used.</summary>
public bool IsDefaultNameServer { get { return string.IsNullOrEmpty(this.Server); } }
/// <summary>Available to not immediately break compatibility.</summary>
[Obsolete("Use AppIdChat instead.")]
public string AppId
{
get { return this.AppIdChat; }
set { this.AppIdChat = value; }
}
}
}

View File

@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 87776a9b1f405644abcc38ecd70c37fb
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@ -0,0 +1,193 @@
// ----------------------------------------------------------------------------------------------------------------------
// <summary>The Photon Chat Api enables clients to connect to a chat server and communicate with other clients.</summary>
// <remarks>ChatClient is the main class of this api.</remarks>
// <copyright company="Exit Games GmbH">Photon Chat Api - Copyright (C) 2014 Exit Games GmbH</copyright>
// ----------------------------------------------------------------------------------------------------------------------
#if UNITY_4_7 || UNITY_5 || UNITY_5_3_OR_NEWER
#define SUPPORTED_UNITY
#endif
namespace Photon.Chat
{
using System.Collections.Generic;
using System.Text;
#if SUPPORTED_UNITY || NETFX_CORE
using Hashtable = ExitGames.Client.Photon.Hashtable;
using SupportClass = ExitGames.Client.Photon.SupportClass;
#endif
/// <summary>
/// A channel of communication in Photon Chat, updated by ChatClient and provided as READ ONLY.
/// </summary>
/// <remarks>
/// Contains messages and senders to use (read!) and display by your GUI.
/// Access these by:
/// ChatClient.PublicChannels
/// ChatClient.PrivateChannels
/// </remarks>
public class ChatChannel
{
/// <summary>Name of the channel (used to subscribe and unsubscribe).</summary>
public readonly string Name;
/// <summary>Senders of messages in chronological order. Senders and Messages refer to each other by index. Senders[x] is the sender of Messages[x].</summary>
public readonly List<string> Senders = new List<string>();
/// <summary>Messages in chronological order. Senders and Messages refer to each other by index. Senders[x] is the sender of Messages[x].</summary>
public readonly List<object> Messages = new List<object>();
/// <summary>If greater than 0, this channel will limit the number of messages, that it caches locally.</summary>
public int MessageLimit;
/// <summary>Unique channel ID.</summary>
public int ChannelID;
/// <summary>Is this a private 1:1 channel?</summary>
public bool IsPrivate { get; protected internal set; }
/// <summary>Count of messages this client still buffers/knows for this channel.</summary>
public int MessageCount { get { return this.Messages.Count; } }
/// <summary>
/// ID of the last message received.
/// </summary>
public int LastMsgId { get; protected set; }
private Dictionary<object, object> properties;
/// <summary>Whether or not this channel keeps track of the list of its subscribers.</summary>
public bool PublishSubscribers { get; protected set; }
/// <summary>Maximum number of channel subscribers. 0 means infinite.</summary>
public int MaxSubscribers { get; protected set; }
/// <summary>Subscribed users.</summary>
public readonly HashSet<string> Subscribers = new HashSet<string>();
/// <summary>Used internally to create new channels. This does NOT create a channel on the server! Use ChatClient.Subscribe.</summary>
public ChatChannel(string name)
{
this.Name = name;
}
/// <summary>Used internally to add messages to this channel.</summary>
public void Add(string sender, object message, int msgId)
{
this.Senders.Add(sender);
this.Messages.Add(message);
this.LastMsgId = msgId;
this.TruncateMessages();
}
/// <summary>Used internally to add messages to this channel.</summary>
public void Add(string[] senders, object[] messages, int lastMsgId)
{
this.Senders.AddRange(senders);
this.Messages.AddRange(messages);
this.LastMsgId = lastMsgId;
this.TruncateMessages();
}
/// <summary>Reduces the number of locally cached messages in this channel to the MessageLimit (if set).</summary>
public void TruncateMessages()
{
if (this.MessageLimit <= 0 || this.Messages.Count <= this.MessageLimit)
{
return;
}
int excessCount = this.Messages.Count - this.MessageLimit;
this.Senders.RemoveRange(0, excessCount);
this.Messages.RemoveRange(0, excessCount);
}
/// <summary>Clear the local cache of messages currently stored. This frees memory but doesn't affect the server.</summary>
public void ClearMessages()
{
this.Senders.Clear();
this.Messages.Clear();
}
/// <summary>Provides a string-representation of all messages in this channel.</summary>
/// <returns>All known messages in format "Sender: Message", line by line.</returns>
public string ToStringMessages()
{
StringBuilder txt = new StringBuilder();
for (int i = 0; i < this.Messages.Count; i++)
{
txt.AppendLine(string.Format("{0}: {1}", this.Senders[i], this.Messages[i]));
}
return txt.ToString();
}
internal void ReadChannelProperties(Dictionary<object, object> newProperties)
{
if (newProperties != null && newProperties.Count > 0)
{
if (this.properties == null)
{
this.properties = new Dictionary<object, object>(newProperties.Count);
}
foreach (var pair in newProperties)
{
if (pair.Value == null)
{
this.properties.Remove(pair.Key);
}
else
{
this.properties[pair.Key] = pair.Value;
}
}
object temp;
if (this.properties.TryGetValue(ChannelWellKnownProperties.PublishSubscribers, out temp))
{
this.PublishSubscribers = (bool)temp;
}
if (this.properties.TryGetValue(ChannelWellKnownProperties.MaxSubscribers, out temp))
{
this.MaxSubscribers = (int)temp;
}
}
}
internal void AddSubscribers(string[] users)
{
if (users == null)
{
return;
}
for (int i = 0; i < users.Length; i++)
{
this.Subscribers.Add(users[i]);
}
}
#if CHAT_EXTENDED
internal void ReadUserProperties(string userId, Dictionary<object, object> changedProperties)
{
throw new System.NotImplementedException();
}
internal bool TryGetChannelProperty<T>(object propertyKey, out T propertyValue)
{
propertyValue = default(T);
object temp;
if (properties != null && properties.TryGetValue(propertyKey, out temp) && temp is T)
{
propertyValue = (T)temp;
return true;
}
return false;
}
public bool TryGetCustomChannelProperty<T>(string propertyKey, out T propertyValue)
{
return this.TryGetChannelProperty(propertyKey, out propertyValue);
}
#endif
}
}

View File

@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: 35b2a4878e5e99e438c97fbe8dbbd863
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: 692e391fa2a297c45b3d530aa85be610
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:

View File

@ -0,0 +1,43 @@
// ----------------------------------------------------------------------------------------------------------------------
// <summary>The Photon Chat Api enables clients to connect to a chat server and communicate with other clients.</summary>
// <remarks>ChatClient is the main class of this api.</remarks>
// <copyright company="Exit Games GmbH">Photon Chat Api - Copyright (C) 2014 Exit Games GmbH</copyright>
// ----------------------------------------------------------------------------------------------------------------------
namespace Photon.Chat
{
/// <summary>Enumeration of causes for Disconnects (used in <see cref="ChatClient.DisconnectedCause"/>).</summary>
/// <remarks>Read the individual descriptions to find out what to do about this type of disconnect.</remarks>
public enum ChatDisconnectCause
{
/// <summary>No error was tracked.</summary>
None,
/// <summary>OnStatusChanged: The server is not available or the address is wrong. Make sure the port is provided and the server is up.</summary>
ExceptionOnConnect,
/// <summary>OnStatusChanged: The server disconnected this client from within the room's logic (the C# code).</summary>
DisconnectByServerLogic,
/// <summary>OnStatusChanged: The server disconnected this client for unknown reasons.</summary>
DisconnectByServerReasonUnknown,
/// <summary>OnStatusChanged: The server disconnected this client due to timing out (missing acknowledgement from the client).</summary>
ServerTimeout,
/// <summary>OnStatusChanged: This client detected that the server's responses are not received in due time.</summary>
ClientTimeout,
/// <summary>OnStatusChanged: Some internal exception caused the socket code to fail. Contact Exit Games.</summary>
Exception,
/// <summary>OnOperationResponse: Authenticate in the Photon Cloud with invalid AppId. Update your subscription or contact Exit Games.</summary>
InvalidAuthentication,
/// <summary>OnOperationResponse: Authenticate (temporarily) failed when using a Photon Cloud subscription without CCU Burst. Update your subscription.</summary>
MaxCcuReached,
/// <summary>OnOperationResponse: Authenticate when the app's Photon Cloud subscription is locked to some (other) region(s). Update your subscription or change region.</summary>
InvalidRegion,
/// <summary>OnOperationResponse: Operation that's (currently) not available for this client (not authorized usually). Only tracked for op Authenticate.</summary>
OperationNotAllowedInCurrentState,
/// <summary>OnOperationResponse: Authenticate in the Photon Cloud with invalid client values or custom authentication setup in Cloud Dashboard.</summary>
CustomAuthenticationFailed,
/// <summary>The authentication ticket should provide access to any Photon Cloud server without doing another authentication-service call. However, the ticket expired.</summary>
AuthenticationTicketExpired,
/// <summary>OnStatusChanged: The client disconnected from within the logic (the C# code).</summary>
DisconnectByClientLogic
}
}

View File

@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: b90b85043f1857f43b94fd00edfc1ef1
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:

View File

@ -0,0 +1,39 @@
// ----------------------------------------------------------------------------------------------------------------------
// <summary>The Photon Chat Api enables clients to connect to a chat server and communicate with other clients.</summary>
// <remarks>ChatClient is the main class of this api.</remarks>
// <copyright company="Exit Games GmbH">Photon Chat Api - Copyright (C) 2014 Exit Games GmbH</copyright>
// ----------------------------------------------------------------------------------------------------------------------
namespace Photon.Chat
{
/// <summary>
/// Wraps up internally used constants in Photon Chat events. You don't have to use them directly usually.
/// </summary>
public class ChatEventCode
{
/// <summary>(0) Event code for messages published in public channels.</summary>
public const byte ChatMessages = 0;
/// <summary>(1) Not Used. </summary>
public const byte Users = 1;// List of users or List of changes for List of users
/// <summary>(2) Event code for messages published in private channels</summary>
public const byte PrivateMessage = 2;
/// <summary>(3) Not Used. </summary>
public const byte FriendsList = 3;
/// <summary>(4) Event code for status updates. </summary>
public const byte StatusUpdate = 4;
/// <summary>(5) Event code for subscription acks. </summary>
public const byte Subscribe = 5;
/// <summary>(6) Event code for unsubscribe acks. </summary>
public const byte Unsubscribe = 6;
/// <summary>(7) Event code for properties update. </summary>
public const byte PropertiesChanged = 7;
/// <summary>(8) Event code for new user subscription to a channel where <see cref="ChatChannel.PublishSubscribers"/> is enabled. </summary>
public const byte UserSubscribed = 8;
/// <summary>(9) Event code for when user unsubscribes from a channel where <see cref="ChatChannel.PublishSubscribers"/> is enabled. </summary>
public const byte UserUnsubscribed = 9;
/// <summary>(10) Event code for when the server sends an error to the client. </summary>
/// <remarks> This is currently only used by Chat WebHooks. </remarks>
public const byte ErrorInfo = 10;
}
}

View File

@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: 188e4a680bce12d4cbad8d57a24f7d44
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:

View File

@ -0,0 +1,38 @@
// ----------------------------------------------------------------------------------------------------------------------
// <summary>The Photon Chat Api enables clients to connect to a chat server and communicate with other clients.</summary>
// <remarks>ChatClient is the main class of this api.</remarks>
// <copyright company="Exit Games GmbH">Photon Chat Api - Copyright (C) 2014 Exit Games GmbH</copyright>
// ----------------------------------------------------------------------------------------------------------------------
namespace Photon.Chat
{
/// <summary>
/// Wraps up codes for operations used internally in Photon Chat. You don't have to use them directly usually.
/// </summary>
public class ChatOperationCode
{
/// <summary>(230) Operation Authenticate.</summary>
public const byte Authenticate = 230;
/// <summary>(0) Operation to subscribe to chat channels.</summary>
public const byte Subscribe = 0;
/// <summary>(1) Operation to unsubscribe from chat channels.</summary>
public const byte Unsubscribe = 1;
/// <summary>(2) Operation to publish a message in a chat channel.</summary>
public const byte Publish = 2;
/// <summary>(3) Operation to send a private message to some other user.</summary>
public const byte SendPrivate = 3;
/// <summary>(4) Not used yet.</summary>
public const byte ChannelHistory = 4;
/// <summary>(5) Set your (client's) status.</summary>
public const byte UpdateStatus = 5;
/// <summary>(6) Add friends the list of friends that should update you of their status.</summary>
public const byte AddFriends = 6;
/// <summary>(7) Remove friends from list of friends that should update you of their status.</summary>
public const byte RemoveFriends = 7;
/// <summary>(8) Operation to set properties of public chat channel or users in public chat channels.</summary>
public const byte SetProperties = 8;
}
}

View File

@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: c90a2a73f3ce648409739c724d3e6cef
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:

View File

@ -0,0 +1,85 @@
// ----------------------------------------------------------------------------------------------------------------------
// <summary>The Photon Chat Api enables clients to connect to a chat server and communicate with other clients.</summary>
// <remarks>ChatClient is the main class of this api.</remarks>
// <copyright company="Exit Games GmbH">Photon Chat Api - Copyright (C) 2014 Exit Games GmbH</copyright>
// ----------------------------------------------------------------------------------------------------------------------
namespace Photon.Chat
{
/// <summary>
/// Wraps up codes for parameters (in operations and events) used internally in Photon Chat. You don't have to use them directly usually.
/// </summary>
public class ChatParameterCode
{
/// <summary>(0) Array of chat channels.</summary>
public const byte Channels = 0;
/// <summary>(1) Name of a single chat channel.</summary>
public const byte Channel = 1;
/// <summary>(2) Array of chat messages.</summary>
public const byte Messages = 2;
/// <summary>(3) A single chat message.</summary>
public const byte Message = 3;
/// <summary>(4) Array of names of the users who sent the array of chat messages.</summary>
public const byte Senders = 4;
/// <summary>(5) Name of a the user who sent a chat message.</summary>
public const byte Sender = 5;
/// <summary>(6) Not used.</summary>
public const byte ChannelUserCount = 6;
/// <summary>(225) Name of user to send a (private) message to.</summary><remarks>The code is used in LoadBalancing and copied over here.</remarks>
public const byte UserId = 225;
/// <summary>(8) Id of a message.</summary>
public const byte MsgId = 8;
/// <summary>(9) Not used.</summary>
public const byte MsgIds = 9;
/// <summary>(221) Secret token to identify an authorized user.</summary><remarks>The code is used in LoadBalancing and copied over here.</remarks>
public const byte Secret = 221;
/// <summary>(15) Subscribe operation result parameter. A bool[] with result per channel.</summary>
public const byte SubscribeResults = 15;
/// <summary>(10) Status</summary>
public const byte Status = 10;
/// <summary>(11) Friends</summary>
public const byte Friends = 11;
/// <summary>(12) SkipMessage is used in SetOnlineStatus and if true, the message is not being broadcast.</summary>
public const byte SkipMessage = 12;
/// <summary>(14) Number of message to fetch from history. 0: no history. 1 and higher: number of messages in history. -1: all history.</summary>
public const byte HistoryLength = 14;
public const byte DebugMessage = 17;
/// <summary>(21) WebFlags object for changing behaviour of webhooks from client.</summary>
public const byte WebFlags = 21;
/// <summary>(22) WellKnown or custom properties of channel or user.</summary>
/// <remarks>
/// In event <see cref="ChatEventCode.Subscribe"/> it's always channel properties,
/// in event <see cref="ChatEventCode.UserSubscribed"/> it's always user properties,
/// in event <see cref="ChatEventCode.PropertiesChanged"/> it's channel properties unless <see cref="UserId"/> parameter value is not null
/// </remarks>
public const byte Properties = 22;
/// <summary>(23) Array of UserIds of users already subscribed to a channel.</summary>
/// <remarks>Used in Subscribe event when PublishSubscribers is enabled.
/// Does not include local user who just subscribed.
/// Maximum length is (<see cref="ChatChannel.MaxSubscribers"/> - 1).</remarks>
public const byte ChannelSubscribers = 23;
/// <summary>(24) Optional data sent in ErrorInfo event from Chat WebHooks. </summary>
public const byte DebugData = 24;
/// <summary>(25) Code for values to be used for "Check And Swap" (CAS) when changing properties.</summary>
public const byte ExpectedValues = 25;
/// <summary>(26) Code for broadcast parameter of <see cref="ChatOperationCode.SetProperties"/> method.</summary>
public const byte Broadcast = 26;
/// <summary>
/// WellKnown and custom user properties.
/// </summary>
/// <remarks>
/// Used only in event <see cref="ChatEventCode.Subscribe"/>
/// </remarks>
public const byte UserProperties = 28;
/// <summary>
/// Generated unique reusable room id
/// </summary>
public const byte UniqueRoomId = 29;
}
}

View File

@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: d7a17b60c85fb30448492e397c58c7ce
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:

View File

@ -0,0 +1,465 @@
// ----------------------------------------------------------------------------------------------------------------------
// <summary>The Photon Chat Api enables clients to connect to a chat server and communicate with other clients.</summary>
// <remarks>ChatClient is the main class of this api.</remarks>
// <copyright company="Exit Games GmbH">Photon Chat Api - Copyright (C) 2014 Exit Games GmbH</copyright>
// ----------------------------------------------------------------------------------------------------------------------
#if UNITY_4_7 || UNITY_5 || UNITY_5_3_OR_NEWER
#define SUPPORTED_UNITY
#endif
namespace Photon.Chat
{
using System;
using System.Diagnostics;
using System.Collections.Generic;
using ExitGames.Client.Photon;
#if SUPPORTED_UNITY || NETFX_CORE
using Hashtable = ExitGames.Client.Photon.Hashtable;
using SupportClass = ExitGames.Client.Photon.SupportClass;
#endif
/// <summary>
/// Provides basic operations of the Photon Chat server. This internal class is used by public ChatClient.
/// </summary>
public class ChatPeer : PhotonPeer
{
/// <summary>Name Server Host Name for Photon Cloud. Without port and without any prefix.</summary>
public string NameServerHost = "ns.photonengine.io";
/// <summary>Name Server port per protocol (the UDP port is different than TCP, etc).</summary>
private static readonly Dictionary<ConnectionProtocol, int> ProtocolToNameServerPort = new Dictionary<ConnectionProtocol, int>() { { ConnectionProtocol.Udp, 5058 }, { ConnectionProtocol.Tcp, 4533 }, { ConnectionProtocol.WebSocket, 9093 }, { ConnectionProtocol.WebSocketSecure, 19093 } }; //, { ConnectionProtocol.RHttp, 6063 } };
/// <summary>Name Server Address for Photon Cloud (based on current protocol). You can use the default values and usually won't have to set this value.</summary>
public string NameServerAddress { get { return this.GetNameServerAddress(); } }
virtual internal bool IsProtocolSecure { get { return this.UsedProtocol == ConnectionProtocol.WebSocketSecure; } }
/// <summary> Chat Peer constructor. </summary>
/// <param name="listener">Chat listener implementation.</param>
/// <param name="protocol">Protocol to be used by the peer.</param>
public ChatPeer(IPhotonPeerListener listener, ConnectionProtocol protocol) : base(listener, protocol)
{
this.ConfigUnitySockets();
}
// Sets up the socket implementations to use, depending on platform
[System.Diagnostics.Conditional("SUPPORTED_UNITY")]
private void ConfigUnitySockets()
{
Type websocketType = null;
#if (UNITY_XBOXONE || UNITY_GAMECORE) && !UNITY_EDITOR
websocketType = Type.GetType("ExitGames.Client.Photon.SocketNativeSource, Assembly-CSharp", false);
if (websocketType == null)
{
websocketType = Type.GetType("ExitGames.Client.Photon.SocketNativeSource, Assembly-CSharp-firstpass", false);
}
if (websocketType == null)
{
websocketType = Type.GetType("ExitGames.Client.Photon.SocketNativeSource, PhotonRealtime", false);
}
if (websocketType != null)
{
this.SocketImplementationConfig[ConnectionProtocol.Udp] = websocketType; // on Xbox, the native socket plugin supports UDP as well
}
#else
// to support WebGL export in Unity, we find and assign the SocketWebTcp class (if it's in the project).
// alternatively class SocketWebTcp might be in the Photon3Unity3D.dll
websocketType = Type.GetType("ExitGames.Client.Photon.SocketWebTcp, PhotonWebSocket", false);
if (websocketType == null)
{
websocketType = Type.GetType("ExitGames.Client.Photon.SocketWebTcp, Assembly-CSharp-firstpass", false);
}
if (websocketType == null)
{
websocketType = Type.GetType("ExitGames.Client.Photon.SocketWebTcp, Assembly-CSharp", false);
}
#endif
if (websocketType != null)
{
this.SocketImplementationConfig[ConnectionProtocol.WebSocket] = websocketType;
this.SocketImplementationConfig[ConnectionProtocol.WebSocketSecure] = websocketType;
}
#if NET_4_6 && (UNITY_EDITOR || !ENABLE_IL2CPP) && !NETFX_CORE
this.SocketImplementationConfig[ConnectionProtocol.Udp] = typeof(SocketUdpAsync);
this.SocketImplementationConfig[ConnectionProtocol.Tcp] = typeof(SocketTcpAsync);
#endif
}
/// <summary>If not zero, this is used for the name server port on connect. Independent of protocol (so this better matches). Set by ChatClient.ConnectUsingSettings.</summary>
/// <remarks>This is reset when the protocol fallback is used.</remarks>
public ushort NameServerPortOverride;
/// <summary>
/// Gets the NameServer Address (with prefix and port), based on the set protocol (this.UsedProtocol).
/// </summary>
/// <returns>NameServer Address (with prefix and port).</returns>
private string GetNameServerAddress()
{
var protocolPort = 0;
ProtocolToNameServerPort.TryGetValue(this.TransportProtocol, out protocolPort);
if (this.NameServerPortOverride != 0)
{
this.Listener.DebugReturn(DebugLevel.INFO, string.Format("Using NameServerPortInAppSettings as port for Name Server: {0}", this.NameServerPortOverride));
protocolPort = this.NameServerPortOverride;
}
switch (this.TransportProtocol)
{
case ConnectionProtocol.Udp:
case ConnectionProtocol.Tcp:
return string.Format("{0}:{1}", NameServerHost, protocolPort);
case ConnectionProtocol.WebSocket:
return string.Format("ws://{0}:{1}", NameServerHost, protocolPort);
case ConnectionProtocol.WebSocketSecure:
return string.Format("wss://{0}:{1}", NameServerHost, protocolPort);
default:
throw new ArgumentOutOfRangeException();
}
}
/// <summary> Connects to NameServer. </summary>
/// <returns>If the connection attempt could be sent.</returns>
public bool Connect()
{
if (this.DebugOut >= DebugLevel.INFO)
{
this.Listener.DebugReturn(DebugLevel.INFO, "Connecting to nameserver " + this.NameServerAddress);
}
return this.Connect(this.NameServerAddress, "NameServer");
}
/// <summary> Authenticates on NameServer. </summary>
/// <returns>If the authentication operation request could be sent.</returns>
public bool AuthenticateOnNameServer(string appId, string appVersion, string region, AuthenticationValues authValues)
{
if (this.DebugOut >= DebugLevel.INFO)
{
this.Listener.DebugReturn(DebugLevel.INFO, "OpAuthenticate()");
}
var opParameters = new Dictionary<byte, object>();
opParameters[ParameterCode.AppVersion] = appVersion;
opParameters[ParameterCode.ApplicationId] = appId;
opParameters[ParameterCode.Region] = region;
if (authValues != null)
{
if (!string.IsNullOrEmpty(authValues.UserId))
{
opParameters[ParameterCode.UserId] = authValues.UserId;
}
if (authValues.AuthType != CustomAuthenticationType.None)
{
opParameters[ParameterCode.ClientAuthenticationType] = (byte) authValues.AuthType;
if (authValues.Token != null)
{
opParameters[ParameterCode.Secret] = authValues.Token;
}
else
{
if (!string.IsNullOrEmpty(authValues.AuthGetParameters))
{
opParameters[ParameterCode.ClientAuthenticationParams] = authValues.AuthGetParameters;
}
if (authValues.AuthPostData != null)
{
opParameters[ParameterCode.ClientAuthenticationData] = authValues.AuthPostData;
}
}
}
}
return this.SendOperation(ChatOperationCode.Authenticate, opParameters, new SendOptions() { Reliability = true, Encrypt = this.IsEncryptionAvailable });
}
}
/// <summary>
/// Options for optional "Custom Authentication" services used with Photon. Used by OpAuthenticate after connecting to Photon.
/// </summary>
public enum CustomAuthenticationType : byte
{
/// <summary>Use a custom authentication service. Currently the only implemented option.</summary>
Custom = 0,
/// <summary>Authenticates users by their Steam Account. Set Steam's ticket as "ticket" via AddAuthParameter().</summary>
Steam = 1,
/// <summary>Authenticates users by their Facebook Account. Set Facebooks's tocken as "token" via AddAuthParameter().</summary>
Facebook = 2,
/// <summary>Authenticates users by their Oculus Account and token. Set Oculus' userid as "userid" and nonce as "nonce" via AddAuthParameter().</summary>
Oculus = 3,
/// <summary>Authenticates users by their PSN Account and token on PS4. Set token as "token", env as "env" and userName as "userName" via AddAuthParameter().</summary>
PlayStation4 = 4,
[Obsolete("Use PlayStation4 or PlayStation5 as needed")]
PlayStation = 4,
/// <summary>Authenticates users by their Xbox Account. Pass the XSTS token via SetAuthPostData().</summary>
Xbox = 5,
/// <summary>Authenticates users by their HTC Viveport Account. Set userToken as "userToken" via AddAuthParameter().</summary>
Viveport = 10,
/// <summary>Authenticates users by their NSA ID. Set token as "token" and appversion as "appversion" via AddAuthParameter(). The appversion is optional.</summary>
NintendoSwitch = 11,
/// <summary>Authenticates users by their PSN Account and token on PS5. Set token as "token", env as "env" and userName as "userName" via AddAuthParameter().</summary>
PlayStation5 = 12,
[Obsolete("Use PlayStation4 or PlayStation5 as needed")]
Playstation5 = 12,
/// <summary>Authenticates users with Epic Online Services (EOS). Set token as "token" and ownershipToken as "ownershipToken" via AddAuthParameter(). The ownershipToken is optional.</summary>
Epic = 13,
/// <summary>Authenticates users with Facebook Gaming api. Set token as "token" via AddAuthParameter().</summary>
FacebookGaming = 15,
/// <summary>Disables custom authentication. Same as not providing any AuthenticationValues for connect (more precisely for: OpAuthenticate).</summary>
None = byte.MaxValue
}
/// <summary>
/// Container for user authentication in Photon. Set AuthValues before you connect - all else is handled.
/// </summary>
/// <remarks>
/// On Photon, user authentication is optional but can be useful in many cases.
/// If you want to FindFriends, a unique ID per user is very practical.
///
/// There are basically three options for user authentication: None at all, the client sets some UserId
/// or you can use some account web-service to authenticate a user (and set the UserId server-side).
///
/// Custom Authentication lets you verify end-users by some kind of login or token. It sends those
/// values to Photon which will verify them before granting access or disconnecting the client.
///
/// The AuthValues are sent in OpAuthenticate when you connect, so they must be set before you connect.
/// If the AuthValues.UserId is null or empty when it's sent to the server, then the Photon Server assigns a UserId!
///
/// The Photon Cloud Dashboard will let you enable this feature and set important server values for it.
/// https://dashboard.photonengine.com
/// </remarks>
public class AuthenticationValues
{
/// <summary>See AuthType.</summary>
private CustomAuthenticationType authType = CustomAuthenticationType.None;
/// <summary>The type of authentication provider that should be used. Defaults to None (no auth whatsoever).</summary>
/// <remarks>Several auth providers are available and CustomAuthenticationType.Custom can be used if you build your own service.</remarks>
public CustomAuthenticationType AuthType
{
get { return authType; }
set { authType = value; }
}
/// <summary>This string must contain any (http get) parameters expected by the used authentication service. By default, username and token.</summary>
/// <remarks>
/// Maps to operation parameter 216.
/// Standard http get parameters are used here and passed on to the service that's defined in the server (Photon Cloud Dashboard).
/// </remarks>
public string AuthGetParameters { get; set; }
/// <summary>Data to be passed-on to the auth service via POST. Default: null (not sent). Either string or byte[] (see setters).</summary>
/// <remarks>Maps to operation parameter 214.</remarks>
public object AuthPostData { get; private set; }
/// <summary>Internal <b>Photon token</b>. After initial authentication, Photon provides a token for this client, subsequently used as (cached) validation.</summary>
/// <remarks>Any token for custom authentication should be set via SetAuthPostData or AddAuthParameter.</remarks>
public object Token { get; protected internal set; }
/// <summary>The UserId should be a unique identifier per user. This is for finding friends, etc..</summary>
/// <remarks>See remarks of AuthValues for info about how this is set and used.</remarks>
public string UserId { get; set; }
/// <summary>Creates empty auth values without any info.</summary>
public AuthenticationValues()
{
}
/// <summary>Creates minimal info about the user. If this is authenticated or not, depends on the set AuthType.</summary>
/// <param name="userId">Some UserId to set in Photon.</param>
public AuthenticationValues(string userId)
{
this.UserId = userId;
}
/// <summary>Sets the data to be passed-on to the auth service via POST.</summary>
/// <remarks>AuthPostData is just one value. Each SetAuthPostData replaces any previous value. It can be either a string, a byte[] or a dictionary.</remarks>
/// <param name="stringData">String data to be used in the body of the POST request. Null or empty string will set AuthPostData to null.</param>
public virtual void SetAuthPostData(string stringData)
{
this.AuthPostData = (string.IsNullOrEmpty(stringData)) ? null : stringData;
}
/// <summary>Sets the data to be passed-on to the auth service via POST.</summary>
/// <remarks>AuthPostData is just one value. Each SetAuthPostData replaces any previous value. It can be either a string, a byte[] or a dictionary.</remarks>
/// <param name="byteData">Binary token / auth-data to pass on.</param>
public virtual void SetAuthPostData(byte[] byteData)
{
this.AuthPostData = byteData;
}
/// <summary>Sets data to be passed-on to the auth service as Json (Content-Type: "application/json") via Post.</summary>
/// <remarks>AuthPostData is just one value. Each SetAuthPostData replaces any previous value. It can be either a string, a byte[] or a dictionary.</remarks>
/// <param name="dictData">A authentication-data dictionary will be converted to Json and passed to the Auth webservice via HTTP Post.</param>
public virtual void SetAuthPostData(Dictionary<string, object> dictData)
{
this.AuthPostData = dictData;
}
/// <summary>Adds a key-value pair to the get-parameters used for Custom Auth (AuthGetParameters).</summary>
/// <remarks>This method does uri-encoding for you.</remarks>
/// <param name="key">Key for the value to set.</param>
/// <param name="value">Some value relevant for Custom Authentication.</param>
public virtual void AddAuthParameter(string key, string value)
{
string ampersand = string.IsNullOrEmpty(this.AuthGetParameters) ? "" : "&";
this.AuthGetParameters = string.Format("{0}{1}{2}={3}", this.AuthGetParameters, ampersand, System.Uri.EscapeDataString(key), System.Uri.EscapeDataString(value));
}
/// <summary>
/// Transform this object into string.
/// </summary>
/// <returns>string representation of this object.</returns>
public override string ToString()
{
return string.Format("AuthenticationValues Type: {3} UserId: {0}, GetParameters: {1} Token available: {2}", this.UserId, this.AuthGetParameters, this.Token != null, this.AuthType);
}
/// <summary>
/// Make a copy of the current object.
/// </summary>
/// <param name="copy">The object to be copied into.</param>
/// <returns>The copied object.</returns>
public AuthenticationValues CopyTo(AuthenticationValues copy)
{
copy.AuthType = this.AuthType;
copy.AuthGetParameters = this.AuthGetParameters;
copy.AuthPostData = this.AuthPostData;
copy.UserId = this.UserId;
return copy;
}
}
/// <summary>Class for constants. Codes for parameters of Operations and Events.</summary>
public class ParameterCode
{
/// <summary>(224) Your application's ID: a name on your own Photon or a GUID on the Photon Cloud</summary>
public const byte ApplicationId = 224;
/// <summary>(221) Internally used to establish encryption</summary>
public const byte Secret = 221;
/// <summary>(220) Version of your application</summary>
public const byte AppVersion = 220;
/// <summary>(217) This key's (byte) value defines the target custom authentication type/service the client connects with. Used in OpAuthenticate</summary>
public const byte ClientAuthenticationType = 217;
/// <summary>(216) This key's (string) value provides parameters sent to the custom authentication type/service the client connects with. Used in OpAuthenticate</summary>
public const byte ClientAuthenticationParams = 216;
/// <summary>(214) This key's (string or byte[]) value provides parameters sent to the custom authentication service setup in Photon Dashboard. Used in OpAuthenticate</summary>
public const byte ClientAuthenticationData = 214;
/// <summary>(210) Used for region values in OpAuth and OpGetRegions.</summary>
public const byte Region = 210;
/// <summary>(230) Address of a (game) server to use.</summary>
public const byte Address = 230;
/// <summary>(225) User's ID</summary>
public const byte UserId = 225;
}
/// <summary>
/// ErrorCode defines the default codes associated with Photon client/server communication.
/// </summary>
public class ErrorCode
{
/// <summary>(0) is always "OK", anything else an error or specific situation.</summary>
public const int Ok = 0;
// server - Photon low(er) level: <= 0
/// <summary>
/// (-3) Operation can't be executed yet (e.g. OpJoin can't be called before being authenticated, RaiseEvent cant be used before getting into a room).
/// </summary>
/// <remarks>
/// Before you call any operations on the Cloud servers, the automated client workflow must complete its authorization.
/// In PUN, wait until State is: JoinedLobby or ConnectedToMaster
/// </remarks>
public const int OperationNotAllowedInCurrentState = -3;
/// <summary>(-2) The operation you called is not implemented on the server (application) you connect to. Make sure you run the fitting applications.</summary>
public const int InvalidOperationCode = -2;
/// <summary>(-1) Something went wrong in the server. Try to reproduce and contact Exit Games.</summary>
public const int InternalServerError = -1;
// server - PhotonNetwork: 0x7FFF and down
// logic-level error codes start with short.max
/// <summary>(32767) Authentication failed. Possible cause: AppId is unknown to Photon (in cloud service).</summary>
public const int InvalidAuthentication = 0x7FFF;
/// <summary>(32766) GameId (name) already in use (can't create another). Change name.</summary>
public const int GameIdAlreadyExists = 0x7FFF - 1;
/// <summary>(32765) Game is full. This rarely happens when some player joined the room before your join completed.</summary>
public const int GameFull = 0x7FFF - 2;
/// <summary>(32764) Game is closed and can't be joined. Join another game.</summary>
public const int GameClosed = 0x7FFF - 3;
/// <summary>(32762) Not in use currently.</summary>
public const int ServerFull = 0x7FFF - 5;
/// <summary>(32761) Not in use currently.</summary>
public const int UserBlocked = 0x7FFF - 6;
/// <summary>(32760) Random matchmaking only succeeds if a room exists that is neither closed nor full. Repeat in a few seconds or create a new room.</summary>
public const int NoRandomMatchFound = 0x7FFF - 7;
/// <summary>(32758) Join can fail if the room (name) is not existing (anymore). This can happen when players leave while you join.</summary>
public const int GameDoesNotExist = 0x7FFF - 9;
/// <summary>(32757) Authorization on the Photon Cloud failed because the concurrent users (CCU) limit of the app's subscription is reached.</summary>
/// <remarks>
/// Unless you have a plan with "CCU Burst", clients might fail the authentication step during connect.
/// Affected client are unable to call operations. Please note that players who end a game and return
/// to the master server will disconnect and re-connect, which means that they just played and are rejected
/// in the next minute / re-connect.
/// This is a temporary measure. Once the CCU is below the limit, players will be able to connect an play again.
///
/// OpAuthorize is part of connection workflow but only on the Photon Cloud, this error can happen.
/// Self-hosted Photon servers with a CCU limited license won't let a client connect at all.
/// </remarks>
public const int MaxCcuReached = 0x7FFF - 10;
/// <summary>(32756) Authorization on the Photon Cloud failed because the app's subscription does not allow to use a particular region's server.</summary>
/// <remarks>
/// Some subscription plans for the Photon Cloud are region-bound. Servers of other regions can't be used then.
/// Check your master server address and compare it with your Photon Cloud Dashboard's info.
/// https://cloud.photonengine.com/dashboard
///
/// OpAuthorize is part of connection workflow but only on the Photon Cloud, this error can happen.
/// Self-hosted Photon servers with a CCU limited license won't let a client connect at all.
/// </remarks>
public const int InvalidRegion = 0x7FFF - 11;
/// <summary>
/// (32755) Custom Authentication of the user failed due to setup reasons (see Cloud Dashboard) or the provided user data (like username or token). Check error message for details.
/// </summary>
public const int CustomAuthenticationFailed = 0x7FFF - 12;
/// <summary>(32753) The Authentication ticket expired. Usually, this is refreshed behind the scenes. Connect (and authorize) again.</summary>
public const int AuthenticationTicketExpired = 0x7FF1;
}
}

View File

@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: 3f712805dec728943a668b3bf19dc422
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:

View File

@ -0,0 +1,39 @@
// ----------------------------------------------------------------------------------------------------------------------
// <summary>The Photon Chat Api enables clients to connect to a chat server and communicate with other clients.</summary>
// <remarks>ChatClient is the main class of this api.</remarks>
// <copyright company="Exit Games GmbH">Photon Chat Api - Copyright (C) 2014 Exit Games GmbH</copyright>
// ----------------------------------------------------------------------------------------------------------------------
namespace Photon.Chat
{
/// <summary>Possible states for a Chat Client.</summary>
public enum ChatState
{
/// <summary>Peer is created but not used yet.</summary>
Uninitialized,
/// <summary>Connecting to name server.</summary>
ConnectingToNameServer,
/// <summary>Connected to name server.</summary>
ConnectedToNameServer,
/// <summary>Authenticating on current server.</summary>
Authenticating,
/// <summary>Finished authentication on current server.</summary>
Authenticated,
/// <summary>Disconnecting from name server. This is usually a transition from name server to frontend server.</summary>
DisconnectingFromNameServer,
/// <summary>Connecting to frontend server.</summary>
ConnectingToFrontEnd,
/// <summary>Connected to frontend server.</summary>
ConnectedToFrontEnd,
/// <summary>Disconnecting from frontend server.</summary>
DisconnectingFromFrontEnd,
/// <summary>Currently not used.</summary>
QueuedComingFromFrontEnd,
/// <summary>The client disconnects (from any server).</summary>
Disconnecting,
/// <summary>The client is no longer connected (to any server).</summary>
Disconnected,
/// <summary>Client was unable to connect to Name Server and will attempt to connect with an alternative network protocol (TCP).</summary>
ConnectWithFallbackProtocol
}
}

View File

@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: 8f482d8c4fe7ade4cbb08eb4a2d83b39
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:

View File

@ -0,0 +1,35 @@
// ----------------------------------------------------------------------------------------------------------------------
// <summary>The Photon Chat Api enables clients to connect to a chat server and communicate with other clients.</summary>
// <remarks>ChatClient is the main class of this api.</remarks>
// <copyright company="Exit Games GmbH">Photon Chat Api - Copyright (C) 2014 Exit Games GmbH</copyright>
// ----------------------------------------------------------------------------------------------------------------------
namespace Photon.Chat
{
/// <summary>Contains commonly used status values for SetOnlineStatus. You can define your own.</summary>
/// <remarks>
/// While "online" (value 2 and up), the status message will be sent to anyone who has you on his friend list.
///
/// Define custom online status values as you like with these rules:
/// 0: Means "offline". It will be used when you are not connected. In this status, there is no status message.
/// 1: Means "invisible" and is sent to friends as "offline". They see status 0, no message but you can chat.
/// 2: And any higher value will be treated as "online". Status can be set.
/// </remarks>
public static class ChatUserStatus
{
/// <summary>(0) Offline.</summary>
public const int Offline = 0;
/// <summary>(1) Be invisible to everyone. Sends no message.</summary>
public const int Invisible = 1;
/// <summary>(2) Online and available.</summary>
public const int Online = 2;
/// <summary>(3) Online but not available.</summary>
public const int Away = 3;
/// <summary>(4) Do not disturb.</summary>
public const int DND = 4;
/// <summary>(5) Looking For Game/Group. Could be used when you want to be invited or do matchmaking.</summary>
public const int LFG = 5;
/// <summary>(6) Could be used when in a room, playing.</summary>
public const int Playing = 6;
}
}

View File

@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: 7db67e7f5face2e42b6daafcaf4e6c82
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:

View File

@ -0,0 +1,148 @@
// ----------------------------------------------------------------------------------------------------------------------
// <summary>The Photon Chat Api enables clients to connect to a chat server and communicate with other clients.</summary>
// <remarks>ChatClient is the main class of this api.</remarks>
// <copyright company="Exit Games GmbH">Photon Chat Api - Copyright (C) 2014 Exit Games GmbH</copyright>
// ----------------------------------------------------------------------------------------------------------------------
namespace Photon.Chat
{
using System.Collections.Generic;
using ExitGames.Client.Photon;
/// <summary>
/// Callback interface for Chat client side. Contains callback methods to notify your app about updates.
/// Must be provided to new ChatClient in constructor
/// </summary>
public interface IChatClientListener
{
/// <summary>
/// All debug output of the library will be reported through this method. Print it or put it in a
/// buffer to use it on-screen.
/// </summary>
/// <param name="level">DebugLevel (severity) of the message.</param>
/// <param name="message">Debug text. Print to System.Console or screen.</param>
void DebugReturn(DebugLevel level, string message);
/// <summary>
/// Disconnection happened.
/// </summary>
void OnDisconnected();
/// <summary>
/// Client is connected now.
/// </summary>
/// <remarks>
/// Clients have to be connected before they can send their state, subscribe to channels and send any messages.
/// </remarks>
void OnConnected();
/// <summary>The ChatClient's state changed. Usually, OnConnected and OnDisconnected are the callbacks to react to.</summary>
/// <param name="state">The new state.</param>
void OnChatStateChange(ChatState state);
/// <summary>
/// Notifies app that client got new messages from server
/// Number of senders is equal to number of messages in 'messages'. Sender with number '0' corresponds to message with
/// number '0', sender with number '1' corresponds to message with number '1' and so on
/// </summary>
/// <param name="channelName">channel from where messages came</param>
/// <param name="senders">list of users who sent messages</param>
/// <param name="messages">list of messages it self</param>
void OnGetMessages(string channelName, string[] senders, object[] messages);
/// <summary>
/// Notifies client about private message
/// </summary>
/// <param name="sender">user who sent this message</param>
/// <param name="message">message it self</param>
/// <param name="channelName">channelName for private messages (messages you sent yourself get added to a channel per target username)</param>
void OnPrivateMessage(string sender, object message, string channelName);
/// <summary>
/// Result of Subscribe operation. Returns subscription result for every requested channel name.
/// </summary>
/// <remarks>
/// If multiple channels sent in Subscribe operation, OnSubscribed may be called several times, each call with part of sent array or with single channel in "channels" parameter.
/// Calls order and order of channels in "channels" parameter may differ from order of channels in "channels" parameter of Subscribe operation.
/// </remarks>
/// <param name="channels">Array of channel names.</param>
/// <param name="results">Per channel result if subscribed.</param>
void OnSubscribed(string[] channels, bool[] results);
/// <summary>
/// Result of Unsubscribe operation. Returns for channel name if the channel is now unsubscribed.
/// </summary>
/// If multiple channels sent in Unsubscribe operation, OnUnsubscribed may be called several times, each call with part of sent array or with single channel in "channels" parameter.
/// Calls order and order of channels in "channels" parameter may differ from order of channels in "channels" parameter of Unsubscribe operation.
/// <param name="channels">Array of channel names that are no longer subscribed.</param>
void OnUnsubscribed(string[] channels);
/// <summary>
/// New status of another user (you get updates for users set in your friends list).
/// </summary>
/// <param name="user">Name of the user.</param>
/// <param name="status">New status of that user.</param>
/// <param name="gotMessage">True if the status contains a message you should cache locally. False: This status update does not include a message (keep any you have).</param>
/// <param name="message">Message that user set.</param>
void OnStatusUpdate(string user, int status, bool gotMessage, object message);
/// <summary>
/// A user has subscribed to a public chat channel
/// </summary>
/// <param name="channel">Name of the chat channel</param>
/// <param name="user">UserId of the user who subscribed</param>
void OnUserSubscribed(string channel, string user);
/// <summary>
/// A user has unsubscribed from a public chat channel
/// </summary>
/// <param name="channel">Name of the chat channel</param>
/// <param name="user">UserId of the user who unsubscribed</param>
void OnUserUnsubscribed(string channel, string user);
#if CHAT_EXTENDED
/// <summary>
/// Properties of a public channel has been changed
/// </summary>
/// <param name="channel">Channel name in which the properties have changed</param>
/// <param name="senderUserId">The UserID of the user who changed the properties</param>
/// <param name="properties">The properties that have changed</param>
void OnChannelPropertiesChanged(string channel, string senderUserId, Dictionary<object, object> properties);
/// <summary>
/// Properties of a user in a public channel has been changed
/// </summary>
/// <param name="channel">Channel name in which the properties have changed</param>
/// <param name="targetUserId">The UserID whom properties have changed</param>
/// <param name="senderUserId">The UserID of the user who changed the properties</param>
/// <param name="properties">The properties that have changed</param>
void OnUserPropertiesChanged(string channel, string targetUserId, string senderUserId, Dictionary<object, object> properties);
/// <summary>
/// The server uses error events to make the client aware of some issues.
/// </summary>
/// <remarks>
/// This is currently used only in Chat WebHooks.
/// </remarks>
/// <param name="channel">The name of the channel in which this error info has been received</param>
/// <param name="error">The text message of the error info</param>
/// <param name="data">Optional error data</param>
void OnErrorInfo(string channel, string error, object data);
#endif
#if SDK_V4
/// <summary>
/// Received a broadcast message
/// </summary>
/// <param name="channel">Name of the chat channel</param>
/// <param name="message">Message data</param>
void OnReceiveBroadcastMessage(string channel, byte[] message);
#endif
}
}

View File

@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: bab7c8053b486e34aa0d4ca99dcbec80
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:

View File

@ -0,0 +1,12 @@
{
"name": "PhotonChat",
"references": [],
"optionalUnityReferences": [],
"includePlatforms": [],
"excludePlatforms": [],
"allowUnsafeCode": false,
"overrideReferences": false,
"precompiledReferences": [],
"autoReferenced": true,
"defineConstraints": []
}

View File

@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: 08a110bd598f7604f9519c2d7e1fb3cc
timeCreated: 1537459565
licenseType: Store
DefaultImporter:
userData:
assetBundleName:
assetBundleVariant:

View File

@ -0,0 +1,137 @@
Photon Chat C# Client - Changelog
Exit Games GmbH - www.photonengine.com - forum.photonengine.com
Version 4.1.6.11 (22. November 2021)
Added: CustomAuthenticationType.Epic to authenticate via Epic Online Services (EOS).
Added: CustomAuthenticationType.FacebookGaming to authenticate via Facebook Gaming services.
Version 4.1.6.10 (21. October 2021 - rev6243)
Fixed: The ChatPeer.ConfigUnitySockets(), which used a surplus typeof() for Xbox configuration.
Version 4.1.6.6 (21. September 2021 - rev6204)
Changed: For Xbox, order of checked assemblies when getting Type SocketNativeSource. It's more likely to be in Assembly-CSharp.
Version 4.1.6.5 (24. August 2021 - rev6181)
Updated: The default name server host to "ns.photonengine.io". When using WSS on this, it expects TLS1.2 (Win 7 and old Unity versions may not support this).
Version 4.1.6.2 (17. June 2021)
Changed: The enumeration CustomAuthenticationType was changed to fix naming inconsistencies. Use PlayStation4 and PlayStation5 respectively. Old variants are available as obsolete.
Version 4.1.5.2 (12. March 2021)
ADDED: CustomAuthenticationType.Playstation5 (value 12).
Version 4.1.5.0 (03. March 2021)
Updated: ChatPeer ConfigUnitySockets() to the analog of the Realtime API.
Version 4.1.5.0 (3. February 2021)
Internal: AuthenticationValues.Token is now an object instead of a string (so some internal code changed). This enables the server to send a byte[], which is more effective than a string.
Version 4.1.4.6 (16. November 2020)
Added: ChatClient.PrivateChatHistoryLength field. If set before you connect, this can be used to limit the number of private messages when the server (re)subscribes the client to (still alive) a private chat channel.
Added: Protocol Fallback option for Chat. Analog to the Realtime API, Chat can now try another protocol, if the initial connect to the Name Server fails. After the timeout or when an error happened, UDP will fallback to TCP. TCP will fallback to UDP.
Added: EnableProtocolFallback in ChatClient and ChatAppSettings. When using ConnectUsingSettings, the ChatClient's value gets set and used.
Changed: Connect(appid, appversion, authValues) will only apply the authvalues parameter, if that's non-null.
Changed: ChatAppSettings field AppId is now AppIdChat (matching the value in Realtime API AppSettings). The old name is currently just obsolete.
Added: ChatAppSettings.Port to override the Name Server Port if needed. Note: Chat does not support "Alternative Ports" yet (ports pre-defined per server).
Added: ChatPeer.NameServerPortOverride value to replace/override the default per-protocol port value (by the one in the AppSettings, e.g.).
Version 4.1.4.5 (02. September 2020)
Added: Option for extended features: Channels may send a user list, channels and users can have custom properties and there are web-forwarding flags. Needs compile define CHAT_EXTENDED. This also adds new methods to the IChatClientListener.
Changed: AuthenticationValues has been refined, analog to the changes in the Realtime API.
Version 4.1.4.2 (8. May 2020 - rev5519)
Added: Broadcast receive and read channel using UniqueRoomID UniqueRoomID read from SubscribeChannel response
Version 4.1.2.20
Changed: ChatDisconnectCause enum and OnDisconnected callback usage updated to be in sync. with Realtime.
Added: ChatClient.ConnectUsingSettings(ChatAppSettings appSettings).
Added: more error logs when something fails internally.
Version 4.1.2.19 (12. November 2019 - rev5266)
Changed: ChatPeer now look for SocketNativeSource instead of SocketWebTcpNativeDynamic when the target platform is XB One. A new Xbox addon is coming up on our SDK page.
Version 4.1.2.16 (25. June 2019 - rev5168)
Added: ChatClient.TryGetPrivateChannelByUser.
Version 4.1.2.14 (6. May 2019 - rev5097)
Changed: Chat API changes are now listed in a separate changes file.
Version 4.1.2.13 (3. May 2019 - rev5086)
Fixed: Properly add local client's UserId to public channels' Subscribers list when applicable.
Version 4.1.2.11 (15. April 2019 - rev5043)
Added: Feature: PublishSubscribers. Per channel, you can now define if the server broadcasts users joining and leaving.
Fixed: proper way to handle Subscribe event when channel properties are returned.
Added: Viveport Auth Provider enum value.
Added: Switch-related workaround. Setting a Thread.Name was causing a crash in some exports on console. This affects Unity to Nintendo Switch exports.
Added: ChannelCreationOptions class to be used in the new Subscribe overload method.
Changed: Chat to use the same 1.8 serialization as Realtime/PUN. This also now matches the SocketWebTcp.SerializationProtocol default.
Version 4.1.2.9 (13. February 2019 - rev4985)
Added: Client API for Max Subscribers and Publish Subscribers features inside public channels.
Version 4.1.2.1 (31. July 2018 - rev4787)
Changed: Namespace from "ExitGames.Client.Photon.Chat" to "Photon.Chat".
Added: ConnectAndSetStatus method.
Version 4.1.1.17 (11. October 2017 - rev4465)
Fixed: Unity "6" compile define is now UNITY_2017.
Version 4.1.1.15 (17. July 2017 - rev4232)
Added: ChatClient.TransportProtocol as shortcut to the use PhotonPeer's TransportProtocol value. This enables setting the protocol easily while not connected.
Added: ChatClient.SocketImplementationConfig as shortcut to modify PhotonPeer's SocketImplementationConfig. This enables you to setup which IPhotonSocket implementation to use for which network protocol.
Changed: ChatPeer.ConfigUnitySockets() to try to find our websocket implementations in the assembly, making the SocketWebTcpCoroutine and SocketWebTcpThread classes optional.
Removed: Class "SocketWebTcp" is no longer found by ConfigUnitySockets().
Version 4.1.1.14 (5. July 2017 - rev4191)
Added: ChatClient can optionally run a thread to call SendOutgoingCommands in intervals. This makes sure the connection doesn't fail easily (e.g. when Unity is loading scenes, etc.). You still have to call Service to dispatch received messages.
Added: ChatClient.UseBackgroundWorkerForSending. Set this to true, to use the new background thread. Note: Do not use this in WebGL exports from Unity cause Threads are unavailable in them.
Version 4.1.1.2 (13. September 2016 - rev3652)
Changed: GetNameServerAddress() is the same in Chat and LoadBalancing APIs now.
Changed: ChatPeer now has ConfigUnitySockets(), which defines the SocketImplementationConfig. It's only used in Unity (using UNITY define).
Changed: ChatClient is not setting socket implementations anymore.
Added: Hashtable definition to use Photon's own implementation for Windows Store builds (NETFX_CORE). This must be used but it means you to use the same Hashtable definition in all builds (no matter if 8.1 or 10).
Added: Support for WebGL export in Unity.
Version 4.0.5.0 (3. December 2015 - rev3144)
Added: A MessageLimit field for ChatClient and ChatChannel to limit the number of messages the client keeps locally. It might be useful to limit memory usage in long running chats. Set ChatClient.MessageLimit to apply the limit to any channel subscribed afterwards or apply a limit individually.
Version 4.0.0.11 (28. October 2015 - rev3093)
Added: More sanity checks on operations (empty userId or secret, max friends).
Added: Special debug logging when the server returns an error for "Operation Unknown". In this case, it's highly likely that you don't use a Chat AppId.
Added: More helpful error logging.
Version 4.0.0.10 (14. July 2015 - rev2988)
Added: A Unity 4.6 demo with uGUI. It's missing a few features but should give you a good start to making your own.
Added: Unity/WebGL support (merged from PUN).
Added: Breaking! IChatClientListener.DebugReturn(). Photon lib and chat client log via this method (no logging to console by default).
Changed: ChatClient.CustomAuthenticationValues is now .AuthValues. You can use those values to identify a user, even if you don't setup an external, custom authentication service.
Changed: ChatClient.UserId no longer directly stores the id but puts it into AuthValues. This means, the UserId could also be set via setting AuthValues.
Changed: The API of AuthenticationValues. There is now the UserId and AddAuthParameter() replaces the less general SetAuthParameters() (which only set specific key/values).
Note: All users should have a UserId. You can set chatClient.UserId before you connect, or you can set the AuthenticationValues in Connect(..., authValues) to set a UserId.
Added: ChatChannel.ToStringMessages(), which gets all messages in a single string, line by line. The format is "Sender:Message".
Added: ChatClient.TryGetChannel() to find a channel only by name, no matter if public or private.
Version 4.0.0.7 (12. January 2015 - rev2763)
Internal: Changed code for UserID from 7 to 225. The latter is used in LoadBalancing, too, so we want to re-use the code here.
Version 4.0.0.1 (17. June 2014 - rev2663)
Changed: How the server responds to Subscribe and Unsubscribe. Events will now contain success/failure of those. This allows us to send the answer after calling a WebHook if needed and we can even send it to multiple clients (which authenticated with the same userID).
Changed: Handling of subscription responsed. This is done to allow web services to subscribe a client remotely and to be able to prevent joining some channel that a user should not join (the channel of some guild or another team, e.g.).
Changed: Debug loggging. In Unity we can't use Debug.Assert, etc. So we have to log more cleanly. This works in Editor and several platforms (but not all).
Changed: Folder for Chat API. It now begins with "Photon" which provides some context no matter where you copy the files. Easier to find in Unity projects.
Changed: Operation FriendList and method SendFriendList renamed to AddFriends
Added: Operation RemoveFriends and corresponding method in ChatClient.cs
Added: Console Demo has new command 'fr' to remove friends
Version 4.0.0.0 (23. May 2014 - rev2614)
Added: SendPrivateMessage() overload that has option to encrypt private messages. Public messages don't need encryption.
Removed: lastId and LastMessageIndex from channels. Those were impractical and should be removed from the API.
Changed: UserStatus class to ChatUserStatus.
Changed: Most classes are defined in their own file now.
Removed: Folders "Shared" and their subfolders. This gives a much better overview.
Added: Handling for event SubscribeResponse. This is not actually a response but gives you info about channels that got subscribed (e.g. when you re-login quickly or when a user is logged in in multiple clients).
Added: HandleSubscriptionResults() method to handle the event and proper responses.

View File

@ -0,0 +1,7 @@
fileFormatVersion: 2
guid: e5c3dda6f11fe7845989297c8a603dc2
TextScriptImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

View File

@ -0,0 +1,9 @@
fileFormatVersion: 2
guid: 801c62f7d03cb463ba20067deb330234
folderAsset: yes
timeCreated: 1537874612
licenseType: Store
DefaultImporter:
userData:
assetBundleName:
assetBundleVariant:

View File

@ -0,0 +1,9 @@
fileFormatVersion: 2
guid: 1aab6e4c105054f7e91af2cf027064d1
folderAsset: yes
timeCreated: 1538395282
licenseType: Store
DefaultImporter:
userData:
assetBundleName:
assetBundleVariant:

View File

@ -0,0 +1,40 @@
// --------------------------------------------------------------------------------------------------------------------
// <copyright file="EventSystemSpawner.cs" company="Exit Games GmbH">
// </copyright>
// <summary>
// For additive Scene Loading context, eventSystem can't be added to each scene and instead should be instantiated only if necessary.
// https://answers.unity.com/questions/1403002/multiple-eventsystem-in-scene-this-is-not-supporte.html
// </summary>
// <author>developer@exitgames.com</author>
// --------------------------------------------------------------------------------------------------------------------
using UnityEngine;
using UnityEngine.EventSystems;
namespace Photon.Chat.UtilityScripts
{
/// <summary>
/// Event system spawner. Will add an EventSystem GameObject with an EventSystem component and a StandaloneInputModule component.
/// Use this in additive scene loading context where you would otherwise get a "Multiple EventSystem in scene... this is not supported" error from Unity.
/// </summary>
public class EventSystemSpawner : MonoBehaviour
{
void OnEnable()
{
#if ENABLE_INPUT_SYSTEM && !ENABLE_LEGACY_INPUT_MANAGER
Debug.LogError("PUN Demos are not compatible with the New Input System, unless you enable \"Both\" in: Edit > Project Settings > Player > Active Input Handling. Pausing App.");
Debug.Break();
return;
#endif
EventSystem sceneEventSystem = FindObjectOfType<EventSystem>();
if (sceneEventSystem == null)
{
GameObject eventSystem = new GameObject("EventSystem");
eventSystem.AddComponent<EventSystem>();
eventSystem.AddComponent<StandaloneInputModule>();
}
}
}
}

View File

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

View File

@ -0,0 +1,24 @@
// --------------------------------------------------------------------------------------------------------------------
// <copyright file="OnStartDelete.cs" company="Exit Games GmbH">
// Part of: Photon Unity Utilities,
// </copyright>
// <summary>
// This component will destroy the GameObject it is attached to (in Start()).
// </summary>
// <author>developer@exitgames.com</author>
// --------------------------------------------------------------------------------------------------------------------
using UnityEngine;
namespace Photon.Chat.UtilityScripts
{
/// <summary>This component will destroy the GameObject it is attached to (in Start()).</summary>
public class OnStartDelete : MonoBehaviour
{
// Use this for initialization
private void Start()
{
Destroy(this.gameObject);
}
}
}

View File

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

View File

@ -0,0 +1,70 @@
// --------------------------------------------------------------------------------------------------------------------
// <copyright file="TextButtonTransition.cs" company="Exit Games GmbH">
// </copyright>
// <summary>
// Use this on Button texts to have some color transition on the text as well without corrupting button's behaviour.
// </summary>
// <author>developer@exitgames.com</author>
// --------------------------------------------------------------------------------------------------------------------
using UnityEngine;
using UnityEngine.EventSystems;
using UnityEngine.UI;
namespace Photon.Chat.UtilityScripts
{
/// <summary>
/// Use this on Button texts to have some color transition on the text as well without corrupting button's behaviour.
/// </summary>
[RequireComponent(typeof(Text))]
public class TextButtonTransition : MonoBehaviour, IPointerEnterHandler, IPointerExitHandler
{
Text _text;
/// <summary>
/// The selectable Component.
/// </summary>
public Selectable Selectable;
/// <summary>
/// The color of the normal of the transition state.
/// </summary>
public Color NormalColor= Color.white;
/// <summary>
/// The color of the hover of the transition state.
/// </summary>
public Color HoverColor = Color.black;
public void Awake()
{
_text = GetComponent<Text>();
}
public void OnEnable()
{
_text.color = NormalColor;
}
public void OnDisable()
{
_text.color = NormalColor;
}
public void OnPointerEnter(PointerEventData eventData)
{
if (Selectable == null || Selectable.IsInteractable()) {
_text.color = HoverColor;
}
}
public void OnPointerExit(PointerEventData eventData)
{
if (Selectable == null || Selectable.IsInteractable()) {
_text.color = NormalColor;
}
}
}
}

View File

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

View File

@ -0,0 +1,86 @@
// --------------------------------------------------------------------------------------------------------------------
// <copyright file="TextToggleIsOnTransition.cs" company="Exit Games GmbH">
// </copyright>
// <summary>
// Use this on Button texts to have some color transition on the text as well without corrupting button's behaviour.
// </summary>
// <author>developer@exitgames.com</author>
// --------------------------------------------------------------------------------------------------------------------
using UnityEngine;
using UnityEngine.EventSystems;
using UnityEngine.UI;
namespace Photon.Chat.UtilityScripts
{
/// <summary>
/// Use this on toggles texts to have some color transition on the text depending on the isOn State.
/// </summary>
[RequireComponent(typeof(Text))]
public class TextToggleIsOnTransition : MonoBehaviour, IPointerEnterHandler, IPointerExitHandler
{
/// <summary>
/// The toggle Component.
/// </summary>
public Toggle toggle;
Text _text;
/// <summary>
/// The color of the normal on transition state.
/// </summary>
public Color NormalOnColor= Color.white;
/// <summary>
/// The color of the normal off transition state.
/// </summary>
public Color NormalOffColor = Color.black;
/// <summary>
/// The color of the hover on transition state.
/// </summary>
public Color HoverOnColor= Color.black;
/// <summary>
/// The color of the hover off transition state.
/// </summary>
public Color HoverOffColor = Color.black;
bool isHover;
public void OnEnable()
{
_text = GetComponent<Text>();
OnValueChanged (toggle.isOn);
toggle.onValueChanged.AddListener(OnValueChanged);
}
public void OnDisable()
{
toggle.onValueChanged.RemoveListener(OnValueChanged);
}
public void OnValueChanged(bool isOn)
{
_text.color = isOn? (isHover?HoverOnColor:HoverOnColor) : (isHover?NormalOffColor:NormalOffColor) ;
}
public void OnPointerEnter(PointerEventData eventData)
{
isHover = true;
_text.color = toggle.isOn?HoverOnColor:HoverOffColor;
}
public void OnPointerExit(PointerEventData eventData)
{
isHover = false;
_text.color = toggle.isOn?NormalOnColor:NormalOffColor;
}
}
}

View File

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

View File

@ -0,0 +1,9 @@
fileFormatVersion: 2
guid: 4e3a46219ebf94310a9f347733f88f31
folderAsset: yes
timeCreated: 1537874626
licenseType: Store
DefaultImporter:
userData:
assetBundleName:
assetBundleVariant:

View File

@ -0,0 +1,30 @@
// --------------------------------------------------------------------------------------------------------------------
// <copyright company="Exit Games GmbH"/>
// <summary>Demo code for Photon Chat in Unity.</summary>
// <author>developer@exitgames.com</author>
// --------------------------------------------------------------------------------------------------------------------
using Photon.Realtime;
namespace Photon.Chat.Demo
{
public static class AppSettingsExtensions
{
public static ChatAppSettings GetChatSettings(this AppSettings appSettings)
{
return new ChatAppSettings
{
AppIdChat = appSettings.AppIdChat,
AppVersion = appSettings.AppVersion,
FixedRegion = appSettings.IsBestRegion ? null : appSettings.FixedRegion,
NetworkLogging = appSettings.NetworkLogging,
Protocol = appSettings.Protocol,
EnableProtocolFallback = appSettings.EnableProtocolFallback,
Server = appSettings.IsDefaultNameServer ? null : appSettings.Server,
Port = (ushort)appSettings.Port
};
}
}
}

View File

@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 4fcf4818ecc9abf4e9b7e0c37af9b851
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@ -0,0 +1,32 @@
// --------------------------------------------------------------------------------------------------------------------
// <copyright company="Exit Games GmbH"/>
// <summary>Demo code for Photon Chat in Unity.</summary>
// <author>developer@exitgames.com</author>
// --------------------------------------------------------------------------------------------------------------------
using UnityEngine;
using UnityEngine.EventSystems;
using UnityEngine.UI;
namespace Photon.Chat.Demo
{
public class ChannelSelector : MonoBehaviour, IPointerClickHandler
{
public string Channel;
public void SetChannel(string channel)
{
this.Channel = channel;
Text t = this.GetComponentInChildren<Text>();
t.text = this.Channel;
}
public void OnPointerClick(PointerEventData eventData)
{
ChatGui handler = FindObjectOfType<ChatGui>();
handler.ShowChannel(this.Channel);
}
}
}

View File

@ -0,0 +1,10 @@
fileFormatVersion: 2
guid: 48caa72710147fc4f9389b0b5ec6137d
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@ -0,0 +1,54 @@
// --------------------------------------------------------------------------------------------------------------------
// <copyright company="Exit Games GmbH"/>
// <summary>Demo code for Photon Chat in Unity.</summary>
// <author>developer@exitgames.com</author>
// --------------------------------------------------------------------------------------------------------------------
using UnityEngine;
#if PHOTON_UNITY_NETWORKING
using UnityEngine.UI;
using Photon.Pun;
namespace Photon.Chat.Demo
{
/// <summary>
/// This is used in the Editor Splash to properly inform the developer about the chat AppId requirement.
/// </summary>
[ExecuteInEditMode]
public class ChatAppIdCheckerUI : MonoBehaviour
{
public Text Description;
public void Update()
{
if (string.IsNullOrEmpty(PhotonNetwork.PhotonServerSettings.AppSettings.AppIdChat))
{
if (this.Description != null)
{
this.Description.text = "<Color=Red>WARNING:</Color>\nPlease setup a Chat AppId in the PhotonServerSettings file.";
}
}
else
{
if (this.Description != null)
{
this.Description.text = string.Empty;
}
}
}
}
}
#else
namespace Photon.Chat.Demo
{
public class ChatAppIdCheckerUI : MonoBehaviour
{
// empty class. if PUN is not present, we currently don't check Chat-AppId "presence".
}
}
#endif

View File

@ -0,0 +1,10 @@
fileFormatVersion: 2
guid: 4eb1284704a754507acb17b07b888086
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@ -0,0 +1,649 @@
// --------------------------------------------------------------------------------------------------------------------
// <copyright company="Exit Games GmbH"/>
// <summary>Demo code for Photon Chat in Unity.</summary>
// <author>developer@exitgames.com</author>
// --------------------------------------------------------------------------------------------------------------------
using System;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
using Photon.Chat;
using Photon.Realtime;
using AuthenticationValues = Photon.Chat.AuthenticationValues;
#if PHOTON_UNITY_NETWORKING
using Photon.Pun;
#endif
namespace Photon.Chat.Demo
{
/// <summary>
/// This simple Chat UI demonstrate basics usages of the Chat Api
/// </summary>
/// <remarks>
/// The ChatClient basically lets you create any number of channels.
///
/// some friends are already set in the Chat demo "DemoChat-Scene", 'Joe', 'Jane' and 'Bob', simply log with them so that you can see the status changes in the Interface
///
/// Workflow:
/// Create ChatClient, Connect to a server with your AppID, Authenticate the user (apply a unique name,)
/// and subscribe to some channels.
/// Subscribe a channel before you publish to that channel!
///
///
/// Note:
/// Don't forget to call ChatClient.Service() on Update to keep the Chatclient operational.
/// </remarks>
public class ChatGui : MonoBehaviour, IChatClientListener
{
public string[] ChannelsToJoinOnConnect; // set in inspector. Demo channels to join automatically.
public string[] FriendsList;
public int HistoryLengthToFetch; // set in inspector. Up to a certain degree, previously sent messages can be fetched for context
public string UserName { get; set; }
private string selectedChannelName; // mainly used for GUI/input
public ChatClient chatClient;
#if !PHOTON_UNITY_NETWORKING
[SerializeField]
#endif
protected internal ChatAppSettings chatAppSettings;
public GameObject missingAppIdErrorPanel;
public GameObject ConnectingLabel;
public RectTransform ChatPanel; // set in inspector (to enable/disable panel)
public GameObject UserIdFormPanel;
public InputField InputFieldChat; // set in inspector
public Text CurrentChannelText; // set in inspector
public Toggle ChannelToggleToInstantiate; // set in inspector
public GameObject FriendListUiItemtoInstantiate;
private readonly Dictionary<string, Toggle> channelToggles = new Dictionary<string, Toggle>();
private readonly Dictionary<string,FriendItem> friendListItemLUT = new Dictionary<string, FriendItem>();
public bool ShowState = true;
public GameObject Title;
public Text StateText; // set in inspector
public Text UserIdText; // set in inspector
// private static string WelcomeText = "Welcome to chat. Type \\help to list commands.";
private static string HelpText = "\n -- HELP --\n" +
"To subscribe to channel(s) (channelnames are case sensitive) : \n" +
"\t<color=#E07B00>\\subscribe</color> <color=green><list of channelnames></color>\n" +
"\tor\n" +
"\t<color=#E07B00>\\s</color> <color=green><list of channelnames></color>\n" +
"\n" +
"To leave channel(s):\n" +
"\t<color=#E07B00>\\unsubscribe</color> <color=green><list of channelnames></color>\n" +
"\tor\n" +
"\t<color=#E07B00>\\u</color> <color=green><list of channelnames></color>\n" +
"\n" +
"To switch the active channel\n" +
"\t<color=#E07B00>\\join</color> <color=green><channelname></color>\n" +
"\tor\n" +
"\t<color=#E07B00>\\j</color> <color=green><channelname></color>\n" +
"\n" +
"To send a private message: (username are case sensitive)\n" +
"\t\\<color=#E07B00>msg</color> <color=green><username></color> <color=green><message></color>\n" +
"\n" +
"To change status:\n" +
"\t\\<color=#E07B00>state</color> <color=green><stateIndex></color> <color=green><message></color>\n" +
"<color=green>0</color> = Offline " +
"<color=green>1</color> = Invisible " +
"<color=green>2</color> = Online " +
"<color=green>3</color> = Away \n" +
"<color=green>4</color> = Do not disturb " +
"<color=green>5</color> = Looking For Group " +
"<color=green>6</color> = Playing" +
"\n\n" +
"To clear the current chat tab (private chats get closed):\n" +
"\t<color=#E07B00>\\clear</color>";
public void Start()
{
DontDestroyOnLoad(this.gameObject);
this.UserIdText.text = "";
this.StateText.text = "";
this.StateText.gameObject.SetActive(true);
this.UserIdText.gameObject.SetActive(true);
this.Title.SetActive(true);
this.ChatPanel.gameObject.SetActive(false);
this.ConnectingLabel.SetActive(false);
if (string.IsNullOrEmpty(this.UserName))
{
this.UserName = "user" + Environment.TickCount%99; //made-up username
}
#if PHOTON_UNITY_NETWORKING
this.chatAppSettings = PhotonNetwork.PhotonServerSettings.AppSettings.GetChatSettings();
#endif
bool appIdPresent = !string.IsNullOrEmpty(this.chatAppSettings.AppIdChat);
this.missingAppIdErrorPanel.SetActive(!appIdPresent);
this.UserIdFormPanel.gameObject.SetActive(appIdPresent);
if (!appIdPresent)
{
Debug.LogError("You need to set the chat app ID in the PhotonServerSettings file in order to continue.");
}
}
public void Connect()
{
this.UserIdFormPanel.gameObject.SetActive(false);
this.chatClient = new ChatClient(this);
#if !UNITY_WEBGL
this.chatClient.UseBackgroundWorkerForSending = true;
#endif
this.chatClient.AuthValues = new AuthenticationValues(this.UserName);
this.chatClient.ConnectUsingSettings(this.chatAppSettings);
this.ChannelToggleToInstantiate.gameObject.SetActive(false);
Debug.Log("Connecting as: " + this.UserName);
this.ConnectingLabel.SetActive(true);
}
/// <summary>To avoid that the Editor becomes unresponsive, disconnect all Photon connections in OnDestroy.</summary>
public void OnDestroy()
{
if (this.chatClient != null)
{
this.chatClient.Disconnect();
}
}
/// <summary>To avoid that the Editor becomes unresponsive, disconnect all Photon connections in OnApplicationQuit.</summary>
public void OnApplicationQuit()
{
if (this.chatClient != null)
{
this.chatClient.Disconnect();
}
}
public void Update()
{
if (this.chatClient != null)
{
this.chatClient.Service(); // make sure to call this regularly! it limits effort internally, so calling often is ok!
}
// check if we are missing context, which means we got kicked out to get back to the Photon Demo hub.
if ( this.StateText == null)
{
Destroy(this.gameObject);
return;
}
this.StateText.gameObject.SetActive(this.ShowState); // this could be handled more elegantly, but for the demo it's ok.
}
public void OnEnterSend()
{
if (Input.GetKey(KeyCode.Return) || Input.GetKey(KeyCode.KeypadEnter))
{
this.SendChatMessage(this.InputFieldChat.text);
this.InputFieldChat.text = "";
}
}
public void OnClickSend()
{
if (this.InputFieldChat != null)
{
this.SendChatMessage(this.InputFieldChat.text);
this.InputFieldChat.text = "";
}
}
public int TestLength = 2048;
private byte[] testBytes = new byte[2048];
private void SendChatMessage(string inputLine)
{
if (string.IsNullOrEmpty(inputLine))
{
return;
}
if ("test".Equals(inputLine))
{
if (this.TestLength != this.testBytes.Length)
{
this.testBytes = new byte[this.TestLength];
}
this.chatClient.SendPrivateMessage(this.chatClient.AuthValues.UserId, this.testBytes, true);
}
bool doingPrivateChat = this.chatClient.PrivateChannels.ContainsKey(this.selectedChannelName);
string privateChatTarget = string.Empty;
if (doingPrivateChat)
{
// the channel name for a private conversation is (on the client!!) always composed of both user's IDs: "this:remote"
// so the remote ID is simple to figure out
string[] splitNames = this.selectedChannelName.Split(new char[] { ':' });
privateChatTarget = splitNames[1];
}
//UnityEngine.Debug.Log("selectedChannelName: " + selectedChannelName + " doingPrivateChat: " + doingPrivateChat + " privateChatTarget: " + privateChatTarget);
if (inputLine[0].Equals('\\'))
{
string[] tokens = inputLine.Split(new char[] {' '}, 2);
if (tokens[0].Equals("\\help"))
{
this.PostHelpToCurrentChannel();
}
if (tokens[0].Equals("\\state"))
{
int newState = 0;
List<string> messages = new List<string>();
messages.Add ("i am state " + newState);
string[] subtokens = tokens[1].Split(new char[] {' ', ','});
if (subtokens.Length > 0)
{
newState = int.Parse(subtokens[0]);
}
if (subtokens.Length > 1)
{
messages.Add(subtokens[1]);
}
this.chatClient.SetOnlineStatus(newState,messages.ToArray()); // this is how you set your own state and (any) message
}
else if ((tokens[0].Equals("\\subscribe") || tokens[0].Equals("\\s")) && !string.IsNullOrEmpty(tokens[1]))
{
this.chatClient.Subscribe(tokens[1].Split(new char[] {' ', ','}));
}
else if ((tokens[0].Equals("\\unsubscribe") || tokens[0].Equals("\\u")) && !string.IsNullOrEmpty(tokens[1]))
{
this.chatClient.Unsubscribe(tokens[1].Split(new char[] {' ', ','}));
}
else if (tokens[0].Equals("\\clear"))
{
if (doingPrivateChat)
{
this.chatClient.PrivateChannels.Remove(this.selectedChannelName);
}
else
{
ChatChannel channel;
if (this.chatClient.TryGetChannel(this.selectedChannelName, doingPrivateChat, out channel))
{
channel.ClearMessages();
}
}
}
else if (tokens[0].Equals("\\msg") && !string.IsNullOrEmpty(tokens[1]))
{
string[] subtokens = tokens[1].Split(new char[] {' ', ','}, 2);
if (subtokens.Length < 2) return;
string targetUser = subtokens[0];
string message = subtokens[1];
this.chatClient.SendPrivateMessage(targetUser, message);
}
else if ((tokens[0].Equals("\\join") || tokens[0].Equals("\\j")) && !string.IsNullOrEmpty(tokens[1]))
{
string[] subtokens = tokens[1].Split(new char[] { ' ', ',' }, 2);
// If we are already subscribed to the channel we directly switch to it, otherwise we subscribe to it first and then switch to it implicitly
if (this.channelToggles.ContainsKey(subtokens[0]))
{
this.ShowChannel(subtokens[0]);
}
else
{
this.chatClient.Subscribe(new string[] { subtokens[0] });
}
}
else
{
Debug.Log("The command '" + tokens[0] + "' is invalid.");
}
}
else
{
if (doingPrivateChat)
{
this.chatClient.SendPrivateMessage(privateChatTarget, inputLine);
}
else
{
this.chatClient.PublishMessage(this.selectedChannelName, inputLine);
}
}
}
public void PostHelpToCurrentChannel()
{
this.CurrentChannelText.text += HelpText;
}
public void DebugReturn(ExitGames.Client.Photon.DebugLevel level, string message)
{
if (level == ExitGames.Client.Photon.DebugLevel.ERROR)
{
Debug.LogError(message);
}
else if (level == ExitGames.Client.Photon.DebugLevel.WARNING)
{
Debug.LogWarning(message);
}
else
{
Debug.Log(message);
}
}
public void OnConnected()
{
if (this.ChannelsToJoinOnConnect != null && this.ChannelsToJoinOnConnect.Length > 0)
{
this.chatClient.Subscribe(this.ChannelsToJoinOnConnect, this.HistoryLengthToFetch);
}
this.ConnectingLabel.SetActive(false);
this.UserIdText.text = "Connected as "+ this.UserName;
this.ChatPanel.gameObject.SetActive(true);
if (this.FriendsList!=null && this.FriendsList.Length>0)
{
this.chatClient.AddFriends(this.FriendsList); // Add some users to the server-list to get their status updates
// add to the UI as well
foreach(string _friend in this.FriendsList)
{
if (this.FriendListUiItemtoInstantiate != null && _friend!= this.UserName)
{
this.InstantiateFriendButton(_friend);
}
}
}
if (this.FriendListUiItemtoInstantiate != null)
{
this.FriendListUiItemtoInstantiate.SetActive(false);
}
this.chatClient.SetOnlineStatus(ChatUserStatus.Online); // You can set your online state (without a mesage).
}
public void OnDisconnected()
{
this.ConnectingLabel.SetActive(false);
}
public void OnChatStateChange(ChatState state)
{
// use OnConnected() and OnDisconnected()
// this method might become more useful in the future, when more complex states are being used.
this.StateText.text = state.ToString();
}
public void OnSubscribed(string[] channels, bool[] results)
{
// in this demo, we simply send a message into each channel. This is NOT a must have!
foreach (string channel in channels)
{
this.chatClient.PublishMessage(channel, "says 'hi'."); // you don't HAVE to send a msg on join but you could.
if (this.ChannelToggleToInstantiate != null)
{
this.InstantiateChannelButton(channel);
}
}
Debug.Log("OnSubscribed: " + string.Join(", ", channels));
/*
// select first subscribed channel in alphabetical order
if (this.chatClient.PublicChannels.Count > 0)
{
var l = new List<string>(this.chatClient.PublicChannels.Keys);
l.Sort();
string selected = l[0];
if (this.channelToggles.ContainsKey(selected))
{
ShowChannel(selected);
foreach (var c in this.channelToggles)
{
c.Value.isOn = false;
}
this.channelToggles[selected].isOn = true;
AddMessageToSelectedChannel(WelcomeText);
}
}
*/
// Switch to the first newly created channel
this.ShowChannel(channels[0]);
}
/// <inheritdoc />
public void OnSubscribed(string channel, string[] users, Dictionary<object, object> properties)
{
Debug.LogFormat("OnSubscribed: {0}, users.Count: {1} Channel-props: {2}.", channel, users.Length, properties.ToStringFull());
}
private void InstantiateChannelButton(string channelName)
{
if (this.channelToggles.ContainsKey(channelName))
{
Debug.Log("Skipping creation for an existing channel toggle.");
return;
}
Toggle cbtn = (Toggle)Instantiate(this.ChannelToggleToInstantiate);
cbtn.gameObject.SetActive(true);
cbtn.GetComponentInChildren<ChannelSelector>().SetChannel(channelName);
cbtn.transform.SetParent(this.ChannelToggleToInstantiate.transform.parent, false);
this.channelToggles.Add(channelName, cbtn);
}
private void InstantiateFriendButton(string friendId)
{
GameObject fbtn = (GameObject)Instantiate(this.FriendListUiItemtoInstantiate);
fbtn.gameObject.SetActive(true);
FriendItem _friendItem = fbtn.GetComponent<FriendItem>();
_friendItem.FriendId = friendId;
fbtn.transform.SetParent(this.FriendListUiItemtoInstantiate.transform.parent, false);
this.friendListItemLUT[friendId] = _friendItem;
}
public void OnUnsubscribed(string[] channels)
{
foreach (string channelName in channels)
{
if (this.channelToggles.ContainsKey(channelName))
{
Toggle t = this.channelToggles[channelName];
Destroy(t.gameObject);
this.channelToggles.Remove(channelName);
Debug.Log("Unsubscribed from channel '" + channelName + "'.");
// Showing another channel if the active channel is the one we unsubscribed from before
if (channelName == this.selectedChannelName && this.channelToggles.Count > 0)
{
IEnumerator<KeyValuePair<string, Toggle>> firstEntry = this.channelToggles.GetEnumerator();
firstEntry.MoveNext();
this.ShowChannel(firstEntry.Current.Key);
firstEntry.Current.Value.isOn = true;
}
}
else
{
Debug.Log("Can't unsubscribe from channel '" + channelName + "' because you are currently not subscribed to it.");
}
}
}
public void OnGetMessages(string channelName, string[] senders, object[] messages)
{
if (channelName.Equals(this.selectedChannelName))
{
// update text
this.ShowChannel(this.selectedChannelName);
}
}
public void OnPrivateMessage(string sender, object message, string channelName)
{
// as the ChatClient is buffering the messages for you, this GUI doesn't need to do anything here
// you also get messages that you sent yourself. in that case, the channelName is determinded by the target of your msg
this.InstantiateChannelButton(channelName);
byte[] msgBytes = message as byte[];
if (msgBytes != null)
{
Debug.Log("Message with byte[].Length: "+ msgBytes.Length);
}
if (this.selectedChannelName.Equals(channelName))
{
this.ShowChannel(channelName);
}
}
/// <summary>
/// New status of another user (you get updates for users set in your friends list).
/// </summary>
/// <param name="user">Name of the user.</param>
/// <param name="status">New status of that user.</param>
/// <param name="gotMessage">True if the status contains a message you should cache locally. False: This status update does not include a
/// message (keep any you have).</param>
/// <param name="message">Message that user set.</param>
public void OnStatusUpdate(string user, int status, bool gotMessage, object message)
{
Debug.LogWarning("status: " + string.Format("{0} is {1}. Msg:{2}", user, status, message));
if (this.friendListItemLUT.ContainsKey(user))
{
FriendItem _friendItem = this.friendListItemLUT[user];
if ( _friendItem!=null) _friendItem.OnFriendStatusUpdate(status,gotMessage,message);
}
}
public void OnUserSubscribed(string channel, string user)
{
Debug.LogFormat("OnUserSubscribed: channel=\"{0}\" userId=\"{1}\"", channel, user);
}
public void OnUserUnsubscribed(string channel, string user)
{
Debug.LogFormat("OnUserUnsubscribed: channel=\"{0}\" userId=\"{1}\"", channel, user);
}
/// <inheritdoc />
public void OnChannelPropertiesChanged(string channel, string userId, Dictionary<object, object> properties)
{
Debug.LogFormat("OnChannelPropertiesChanged: {0} by {1}. Props: {2}.", channel, userId, Extensions.ToStringFull(properties));
}
public void OnUserPropertiesChanged(string channel, string targetUserId, string senderUserId, Dictionary<object, object> properties)
{
Debug.LogFormat("OnUserPropertiesChanged: (channel:{0} user:{1}) by {2}. Props: {3}.", channel, targetUserId, senderUserId, Extensions.ToStringFull(properties));
}
/// <inheritdoc />
public void OnErrorInfo(string channel, string error, object data)
{
Debug.LogFormat("OnErrorInfo for channel {0}. Error: {1} Data: {2}", channel, error, data);
}
public void AddMessageToSelectedChannel(string msg)
{
ChatChannel channel = null;
bool found = this.chatClient.TryGetChannel(this.selectedChannelName, out channel);
if (!found)
{
Debug.Log("AddMessageToSelectedChannel failed to find channel: " + this.selectedChannelName);
return;
}
if (channel != null)
{
channel.Add("Bot", msg,0); //TODO: how to use msgID?
}
}
public void ShowChannel(string channelName)
{
if (string.IsNullOrEmpty(channelName))
{
return;
}
ChatChannel channel = null;
bool found = this.chatClient.TryGetChannel(channelName, out channel);
if (!found)
{
Debug.Log("ShowChannel failed to find channel: " + channelName);
return;
}
this.selectedChannelName = channelName;
this.CurrentChannelText.text = channel.ToStringMessages();
Debug.Log("ShowChannel: " + this.selectedChannelName);
foreach (KeyValuePair<string, Toggle> pair in this.channelToggles)
{
pair.Value.isOn = pair.Key == channelName ? true : false;
}
}
public void OpenDashboard()
{
Application.OpenURL("https://dashboard.photonengine.com");
}
}
}

View File

@ -0,0 +1,10 @@
fileFormatVersion: 2
guid: 02d148d0890b2d44dbdf7f1c1b39a499
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

File diff suppressed because it is too large Load Diff

Some files were not shown because too many files have changed in this diff Show More