first commit
This commit is contained in:
@@ -0,0 +1,61 @@
|
||||
// --------------------------------------------------------------------------------------------------------------------
|
||||
// <copyright file="AutoSyncSceneToggle.cs" company="Exit Games GmbH">
|
||||
// Part of: Pun Cockpit Demo
|
||||
// </copyright>
|
||||
// <author>developer@exitgames.com</author>
|
||||
// --------------------------------------------------------------------------------------------------------------------
|
||||
|
||||
using UnityEngine;
|
||||
using UnityEngine.UI;
|
||||
|
||||
namespace Photon.Pun.Demo.Cockpit
|
||||
{
|
||||
/// <summary>
|
||||
/// PhotonNetwork.AutomaticallySyncScene UI Toggle
|
||||
/// </summary>
|
||||
[RequireComponent(typeof(Toggle))]
|
||||
public class AutoSyncSceneToggle : MonoBehaviour
|
||||
{
|
||||
Toggle _toggle;
|
||||
|
||||
bool registered;
|
||||
|
||||
// Use this for initialization
|
||||
void OnEnable()
|
||||
{
|
||||
|
||||
_toggle = GetComponent<Toggle>();
|
||||
|
||||
if (!registered)
|
||||
{
|
||||
registered = true;
|
||||
_toggle.onValueChanged.AddListener(ToggleValue);
|
||||
}
|
||||
}
|
||||
|
||||
void OnDisable()
|
||||
{
|
||||
if (_toggle != null)
|
||||
{
|
||||
registered = false;
|
||||
_toggle.onValueChanged.RemoveListener(ToggleValue);
|
||||
}
|
||||
}
|
||||
|
||||
void Update()
|
||||
{
|
||||
|
||||
if (PhotonNetwork.AutomaticallySyncScene != _toggle.isOn)
|
||||
{
|
||||
_toggle.isOn = PhotonNetwork.AutomaticallySyncScene;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public void ToggleValue(bool value)
|
||||
{
|
||||
PhotonNetwork.AutomaticallySyncScene = value;
|
||||
//Debug.Log("PhotonNetwork.CrcCheckEnabled = " + PhotonNetwork.CrcCheckEnabled, this);
|
||||
}
|
||||
}
|
||||
}
|
@@ -0,0 +1,12 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 345270254ed7b49e89ce5662ca70a091
|
||||
timeCreated: 1538567993
|
||||
licenseType: Store
|
||||
MonoImporter:
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
@@ -0,0 +1,68 @@
|
||||
// --------------------------------------------------------------------------------------------------------------------
|
||||
// <copyright file="BackgroundTimeOutField.cs" company="Exit Games GmbH">
|
||||
// Part of: Pun Cockpit Demo
|
||||
// </copyright>
|
||||
// <author>developer@exitgames.com</author>
|
||||
// --------------------------------------------------------------------------------------------------------------------
|
||||
|
||||
using UnityEngine;
|
||||
using UnityEngine.UI;
|
||||
|
||||
namespace Photon.Pun.Demo.Cockpit
|
||||
{
|
||||
/// <summary>
|
||||
/// PhotonNetwork.BackgroundTimeout UI InputField.
|
||||
/// </summary>
|
||||
public class BackgroundTimeOutField : MonoBehaviour
|
||||
{
|
||||
public InputField PropertyValueInput;
|
||||
|
||||
float _cache;
|
||||
|
||||
bool registered;
|
||||
|
||||
void OnEnable()
|
||||
{
|
||||
if (!registered)
|
||||
{
|
||||
registered = true;
|
||||
PropertyValueInput.onEndEdit.AddListener(OnEndEdit);
|
||||
}
|
||||
}
|
||||
|
||||
void OnDisable()
|
||||
{
|
||||
registered = false;
|
||||
PropertyValueInput.onEndEdit.RemoveListener(OnEndEdit);
|
||||
}
|
||||
|
||||
void Update()
|
||||
{
|
||||
if (PhotonNetwork.KeepAliveInBackground != _cache)
|
||||
{
|
||||
_cache = PhotonNetwork.KeepAliveInBackground;
|
||||
PropertyValueInput.text = _cache.ToString("F1");
|
||||
}
|
||||
}
|
||||
|
||||
// new UI will fire "EndEdit" event also when loosing focus. So check "enter" key and only then StartChat.
|
||||
public void OnEndEdit(string value)
|
||||
{
|
||||
if (Input.GetKey(KeyCode.Return) || Input.GetKey(KeyCode.KeypadEnter) || Input.GetKey(KeyCode.Tab))
|
||||
{
|
||||
this.SubmitForm(value.Trim());
|
||||
}
|
||||
else
|
||||
{
|
||||
this.SubmitForm(value);
|
||||
}
|
||||
}
|
||||
|
||||
public void SubmitForm(string value)
|
||||
{
|
||||
_cache = float.Parse(value);
|
||||
PhotonNetwork.KeepAliveInBackground = _cache;
|
||||
//Debug.Log("PhotonNetwork.BackgroundTimeout = " + PhotonNetwork.BackgroundTimeout, this);
|
||||
}
|
||||
}
|
||||
}
|
@@ -0,0 +1,12 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 44aff3084c8664497aa6048e66e71a7c
|
||||
timeCreated: 1519126771
|
||||
licenseType: Store
|
||||
MonoImporter:
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
@@ -0,0 +1,61 @@
|
||||
// --------------------------------------------------------------------------------------------------------------------
|
||||
// <copyright file="CrcCheckToggle.cs" company="Exit Games GmbH">
|
||||
// Part of: Pun Cockpit Demo
|
||||
// </copyright>
|
||||
// <author>developer@exitgames.com</author>
|
||||
// --------------------------------------------------------------------------------------------------------------------
|
||||
|
||||
using UnityEngine;
|
||||
using UnityEngine.UI;
|
||||
|
||||
namespace Photon.Pun.Demo.Cockpit
|
||||
{
|
||||
/// <summary>
|
||||
/// PhotonNetwork.CrcCheckEnabled UI Toggle
|
||||
/// </summary>
|
||||
[RequireComponent(typeof(Toggle))]
|
||||
public class CrcCheckToggle : MonoBehaviour
|
||||
{
|
||||
Toggle _toggle;
|
||||
|
||||
bool registered;
|
||||
|
||||
// Use this for initialization
|
||||
void OnEnable()
|
||||
{
|
||||
|
||||
_toggle = GetComponent<Toggle>();
|
||||
|
||||
if (!registered)
|
||||
{
|
||||
registered = true;
|
||||
_toggle.onValueChanged.AddListener(ToggleValue);
|
||||
}
|
||||
}
|
||||
|
||||
void OnDisable()
|
||||
{
|
||||
if (_toggle != null)
|
||||
{
|
||||
registered = false;
|
||||
_toggle.onValueChanged.RemoveListener(ToggleValue);
|
||||
}
|
||||
}
|
||||
|
||||
void Update()
|
||||
{
|
||||
|
||||
if (PhotonNetwork.CrcCheckEnabled != _toggle.isOn)
|
||||
{
|
||||
_toggle.isOn = PhotonNetwork.CrcCheckEnabled;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public void ToggleValue(bool value)
|
||||
{
|
||||
PhotonNetwork.CrcCheckEnabled = value;
|
||||
//Debug.Log("PhotonNetwork.CrcCheckEnabled = " + PhotonNetwork.CrcCheckEnabled, this);
|
||||
}
|
||||
}
|
||||
}
|
@@ -0,0 +1,12 @@
|
||||
fileFormatVersion: 2
|
||||
guid: ac5f2e2d5fa8e4143ab9b97b523d3990
|
||||
timeCreated: 1519127346
|
||||
licenseType: Store
|
||||
MonoImporter:
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
@@ -0,0 +1,9 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 44872d445f2594fbeb2bd8fba90f1f08
|
||||
folderAsset: yes
|
||||
timeCreated: 1559569017
|
||||
licenseType: Store
|
||||
DefaultImporter:
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
@@ -0,0 +1,66 @@
|
||||
// --------------------------------------------------------------------------------------------------------------------
|
||||
// <copyright file="PhotonNetwork.CurrentRoom.IsOpen.cs" company="Exit Games GmbH">
|
||||
// Part of: Pun Cockpit Demo
|
||||
// </copyright>
|
||||
// <author>developer@exitgames.com</author>
|
||||
// --------------------------------------------------------------------------------------------------------------------
|
||||
|
||||
using UnityEngine;
|
||||
using UnityEngine.EventSystems;
|
||||
using UnityEngine.UI;
|
||||
|
||||
namespace Photon.Pun.Demo.Cockpit
|
||||
{
|
||||
/// <summary>
|
||||
/// PhotonNetwork.CurrentRoom.IsOpen UI Toggle
|
||||
/// </summary>
|
||||
[RequireComponent(typeof(Toggle))]
|
||||
public class CurrentRoomIsOpenToggle : MonoBehaviour, IPointerClickHandler
|
||||
{
|
||||
Toggle _toggle;
|
||||
|
||||
|
||||
// Use this for initialization
|
||||
void OnEnable()
|
||||
{
|
||||
_toggle = GetComponent<Toggle>();
|
||||
}
|
||||
|
||||
void Update()
|
||||
{
|
||||
|
||||
if (PhotonNetwork.CurrentRoom == null && _toggle.interactable)
|
||||
{
|
||||
_toggle.interactable = false;
|
||||
|
||||
}
|
||||
else if (PhotonNetwork.CurrentRoom != null && !_toggle.interactable)
|
||||
{
|
||||
_toggle.interactable = true;
|
||||
}
|
||||
|
||||
if (PhotonNetwork.CurrentRoom!=null && PhotonNetwork.CurrentRoom.IsOpen != _toggle.isOn)
|
||||
{
|
||||
Debug.Log("Update toggle : PhotonNetwork.CurrentRoom.IsOpen = " + PhotonNetwork.CurrentRoom.IsOpen, this);
|
||||
_toggle.isOn = PhotonNetwork.CurrentRoom.IsOpen;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public void ToggleValue(bool value)
|
||||
{
|
||||
if (PhotonNetwork.CurrentRoom != null)
|
||||
{
|
||||
Debug.Log("PhotonNetwork.CurrentRoom.IsOpen = " + value, this);
|
||||
PhotonNetwork.CurrentRoom.IsOpen = value;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
public void OnPointerClick(PointerEventData eventData)
|
||||
{
|
||||
ToggleValue(_toggle.isOn);
|
||||
}
|
||||
}
|
||||
}
|
@@ -0,0 +1,12 @@
|
||||
fileFormatVersion: 2
|
||||
guid: fa1f9506beac441fa984720f2b92a92a
|
||||
timeCreated: 1559569034
|
||||
licenseType: Store
|
||||
MonoImporter:
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
@@ -0,0 +1,65 @@
|
||||
// --------------------------------------------------------------------------------------------------------------------
|
||||
// <copyright file="CurrentRoomIsVisibleToggle.cs" company="Exit Games GmbH">
|
||||
// Part of: Pun Cockpit Demo
|
||||
// </copyright>
|
||||
// <author>developer@exitgames.com</author>
|
||||
// --------------------------------------------------------------------------------------------------------------------
|
||||
|
||||
using UnityEngine;
|
||||
using UnityEngine.EventSystems;
|
||||
using UnityEngine.UI;
|
||||
|
||||
namespace Photon.Pun.Demo.Cockpit
|
||||
{
|
||||
/// <summary>
|
||||
/// PhotonNetwork.CurrentRoom.IsVisible UI Toggle
|
||||
/// </summary>
|
||||
[RequireComponent(typeof(Toggle))]
|
||||
public class CurrentRoomIsVisibleToggle : MonoBehaviour, IPointerClickHandler
|
||||
{
|
||||
Toggle _toggle;
|
||||
|
||||
|
||||
// Use this for initialization
|
||||
void OnEnable()
|
||||
{
|
||||
_toggle = GetComponent<Toggle>();
|
||||
}
|
||||
|
||||
void Update()
|
||||
{
|
||||
if (PhotonNetwork.CurrentRoom == null && _toggle.interactable)
|
||||
{
|
||||
_toggle.interactable = false;
|
||||
|
||||
}
|
||||
else if (PhotonNetwork.CurrentRoom != null && !_toggle.interactable)
|
||||
{
|
||||
_toggle.interactable = true;
|
||||
}
|
||||
|
||||
if (PhotonNetwork.CurrentRoom!=null && PhotonNetwork.CurrentRoom.IsVisible != _toggle.isOn)
|
||||
{
|
||||
Debug.Log("Update toggle : PhotonNetwork.CurrentRoom.IsVisible = " + PhotonNetwork.CurrentRoom.IsVisible, this);
|
||||
_toggle.isOn = PhotonNetwork.CurrentRoom.IsVisible;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public void ToggleValue(bool value)
|
||||
{
|
||||
if (PhotonNetwork.CurrentRoom != null)
|
||||
{
|
||||
Debug.Log("PhotonNetwork.CurrentRoom.IsVisible = " + value, this);
|
||||
PhotonNetwork.CurrentRoom.IsVisible = value;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
public void OnPointerClick(PointerEventData eventData)
|
||||
{
|
||||
ToggleValue(_toggle.isOn);
|
||||
}
|
||||
}
|
||||
}
|
@@ -0,0 +1,12 @@
|
||||
fileFormatVersion: 2
|
||||
guid: d221ad35d6c3f4da9b735a5e819ed1d3
|
||||
timeCreated: 1559569034
|
||||
licenseType: Store
|
||||
MonoImporter:
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
@@ -0,0 +1,33 @@
|
||||
// --------------------------------------------------------------------------------------------------------------------
|
||||
// <copyright file="DocLinkButton.cs" company="Exit Games GmbH">
|
||||
// Part of: Pun demos
|
||||
// </copyright>
|
||||
// <author>developer@exitgames.com</author>
|
||||
// --------------------------------------------------------------------------------------------------------------------
|
||||
|
||||
using Photon.Pun.Demo.Shared;
|
||||
using UnityEngine;
|
||||
using UnityEngine.EventSystems;
|
||||
|
||||
namespace Photon.Pun.Demo.Cockpit
|
||||
{
|
||||
/// <summary>
|
||||
/// Open an Url on Pointer Click.
|
||||
/// </summary>
|
||||
public class DocLinkButton : MonoBehaviour, IPointerClickHandler
|
||||
{
|
||||
public DocLinks.DocTypes Type = DocLinks.DocTypes.Doc;
|
||||
|
||||
public string Reference = "getting-started/pun-intro";
|
||||
|
||||
|
||||
// Just so that Unity expose the enable Check Box inside the Component Inspector Header.
|
||||
public void Start(){}
|
||||
|
||||
//Detect if a click occurs
|
||||
public void OnPointerClick(PointerEventData pointerEventData)
|
||||
{
|
||||
Application.OpenURL(DocLinks.GetLink(Type,Reference));
|
||||
}
|
||||
}
|
||||
}
|
@@ -0,0 +1,12 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 09b634200c91b4206aa56038f7647fb5
|
||||
timeCreated: 1530884945
|
||||
licenseType: Store
|
||||
MonoImporter:
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
@@ -0,0 +1,68 @@
|
||||
// --------------------------------------------------------------------------------------------------------------------
|
||||
// <copyright file="GameVersionField.cs" company="Exit Games GmbH">
|
||||
// Part of: Pun Cockpit
|
||||
// </copyright>
|
||||
// <author>developer@exitgames.com</author>
|
||||
// --------------------------------------------------------------------------------------------------------------------
|
||||
|
||||
using UnityEngine;
|
||||
using UnityEngine.UI;
|
||||
|
||||
namespace Photon.Pun.Demo.Cockpit
|
||||
{
|
||||
/// <summary>
|
||||
/// Game version field.
|
||||
/// </summary>
|
||||
public class GameVersionField : MonoBehaviour
|
||||
{
|
||||
public InputField PropertyValueInput;
|
||||
|
||||
private string _cache;
|
||||
|
||||
private bool registered;
|
||||
|
||||
private void OnEnable()
|
||||
{
|
||||
if (!this.registered)
|
||||
{
|
||||
this.registered = true;
|
||||
this.PropertyValueInput.onEndEdit.AddListener(this.OnEndEdit);
|
||||
}
|
||||
}
|
||||
|
||||
private void OnDisable()
|
||||
{
|
||||
this.registered = false;
|
||||
this.PropertyValueInput.onEndEdit.RemoveListener(this.OnEndEdit);
|
||||
}
|
||||
|
||||
private void Update()
|
||||
{
|
||||
if (PhotonNetwork.PhotonServerSettings.AppSettings.AppVersion != this._cache)
|
||||
{
|
||||
this._cache = PhotonNetwork.PhotonServerSettings.AppSettings.AppVersion;
|
||||
this.PropertyValueInput.text = this._cache;
|
||||
}
|
||||
}
|
||||
|
||||
// new UI will fire "EndEdit" event also when loosing focus. So check "enter" key and only then submit form.
|
||||
public void OnEndEdit(string value)
|
||||
{
|
||||
if (Input.GetKey(KeyCode.Return) || Input.GetKey(KeyCode.KeypadEnter) || Input.GetKey(KeyCode.Tab))
|
||||
{
|
||||
this.SubmitForm(value.Trim());
|
||||
}
|
||||
else
|
||||
{
|
||||
this.SubmitForm(value);
|
||||
}
|
||||
}
|
||||
|
||||
public void SubmitForm(string value)
|
||||
{
|
||||
this._cache = value;
|
||||
PunCockpit.Instance.GameVersionOverride = this._cache;
|
||||
//Debug.Log("PunCockpit.GameVersionOverride = " + PunCockpit.Instance.GameVersionOverride, this);
|
||||
}
|
||||
}
|
||||
}
|
@@ -0,0 +1,12 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 74b76e97b5bf042e3b0a981241bce379
|
||||
timeCreated: 1524053508
|
||||
licenseType: Store
|
||||
MonoImporter:
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
@@ -0,0 +1,9 @@
|
||||
fileFormatVersion: 2
|
||||
guid: c6ff6c1b4167dd340a8b3aaae892b377
|
||||
folderAsset: yes
|
||||
timeCreated: 1519216796
|
||||
licenseType: Store
|
||||
DefaultImporter:
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
@@ -0,0 +1,54 @@
|
||||
// --------------------------------------------------------------------------------------------------------------------
|
||||
// <copyright file="CrcCheckToggle.cs" company="Exit Games GmbH">
|
||||
// Part of: Pun Cockpit Demo
|
||||
// </copyright>
|
||||
// <author>developer@exitgames.com</author>
|
||||
// --------------------------------------------------------------------------------------------------------------------
|
||||
|
||||
using UnityEngine;
|
||||
using UnityEngine.UI;
|
||||
using UnityEngine.Events;
|
||||
|
||||
namespace Photon.Pun.Demo.Cockpit
|
||||
{
|
||||
/// <summary>
|
||||
/// Boolean UI UI Toggle input.
|
||||
/// </summary>
|
||||
public class BoolInputField : MonoBehaviour
|
||||
{
|
||||
public Toggle PropertyValueInput;
|
||||
|
||||
[System.Serializable]
|
||||
public class OnSubmitEvent : UnityEvent<bool> { }
|
||||
|
||||
public OnSubmitEvent OnSubmit;
|
||||
|
||||
bool registered;
|
||||
|
||||
void OnEnable()
|
||||
{
|
||||
if (!registered)
|
||||
{
|
||||
registered = true;
|
||||
PropertyValueInput.onValueChanged.AddListener(OnValueChanged);
|
||||
}
|
||||
}
|
||||
|
||||
void OnDisable()
|
||||
{
|
||||
registered = false;
|
||||
PropertyValueInput.onValueChanged.RemoveListener(OnValueChanged);
|
||||
}
|
||||
|
||||
void OnValueChanged(bool value)
|
||||
{
|
||||
OnSubmit.Invoke(PropertyValueInput.isOn);
|
||||
}
|
||||
|
||||
public void SetValue(bool value)
|
||||
{
|
||||
PropertyValueInput.isOn = value;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
@@ -0,0 +1,12 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 0d7694afd58e94f988b7b524da7b97b9
|
||||
timeCreated: 1519218811
|
||||
licenseType: Store
|
||||
MonoImporter:
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
@@ -0,0 +1,67 @@
|
||||
// --------------------------------------------------------------------------------------------------------------------
|
||||
// <copyright file="CrcCheckToggle.cs" company="Exit Games GmbH">
|
||||
// Part of: Pun Cockpit Demo
|
||||
// </copyright>
|
||||
// <author>developer@exitgames.com</author>
|
||||
// --------------------------------------------------------------------------------------------------------------------
|
||||
|
||||
using UnityEngine;
|
||||
using UnityEngine.UI;
|
||||
using UnityEngine.Events;
|
||||
|
||||
namespace Photon.Pun.Demo.Cockpit
|
||||
{
|
||||
/// <summary>
|
||||
/// Int UI InputField.
|
||||
/// </summary>
|
||||
public class IntInputField : MonoBehaviour
|
||||
{
|
||||
public InputField PropertyValueInput;
|
||||
|
||||
[System.Serializable]
|
||||
public class OnSubmitEvent : UnityEvent<int> { }
|
||||
|
||||
public OnSubmitEvent OnSubmit;
|
||||
|
||||
bool registered;
|
||||
|
||||
void OnEnable()
|
||||
{
|
||||
if (!registered)
|
||||
{
|
||||
registered = true;
|
||||
PropertyValueInput.onEndEdit.AddListener(EndEditOnEnter);
|
||||
}
|
||||
}
|
||||
|
||||
void OnDisable()
|
||||
{
|
||||
registered = false;
|
||||
PropertyValueInput.onEndEdit.RemoveListener(EndEditOnEnter);
|
||||
}
|
||||
|
||||
public void SetValue(int value)
|
||||
{
|
||||
PropertyValueInput.text = value.ToString();
|
||||
}
|
||||
|
||||
public void EndEditOnEnter(string value)
|
||||
{
|
||||
if (Input.GetKey(KeyCode.Return) || Input.GetKey(KeyCode.KeypadEnter) || Input.GetKey(KeyCode.Tab))
|
||||
{
|
||||
this.SubmitForm(value.Trim());
|
||||
}
|
||||
else
|
||||
{
|
||||
this.SubmitForm(value);
|
||||
}
|
||||
}
|
||||
|
||||
public void SubmitForm(string value)
|
||||
{
|
||||
int _value = 0;
|
||||
int.TryParse(value, out _value);
|
||||
OnSubmit.Invoke(_value);
|
||||
}
|
||||
}
|
||||
}
|
@@ -0,0 +1,12 @@
|
||||
fileFormatVersion: 2
|
||||
guid: bd06272cdb8d849f0ab251f0678c9eca
|
||||
timeCreated: 1518011577
|
||||
licenseType: Store
|
||||
MonoImporter:
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
@@ -0,0 +1,65 @@
|
||||
// --------------------------------------------------------------------------------------------------------------------
|
||||
// <copyright file="StringInputField.cs" company="Exit Games GmbH">
|
||||
// Part of: Pun Cockpit Demo
|
||||
// </copyright>
|
||||
// <author>developer@exitgames.com</author>
|
||||
// --------------------------------------------------------------------------------------------------------------------
|
||||
|
||||
using UnityEngine;
|
||||
using UnityEngine.UI;
|
||||
using UnityEngine.Events;
|
||||
|
||||
namespace Photon.Pun.Demo.Cockpit
|
||||
{
|
||||
/// <summary>
|
||||
/// String UI InputField.
|
||||
/// </summary>
|
||||
public class StringInputField : MonoBehaviour
|
||||
{
|
||||
public InputField PropertyValueInput;
|
||||
|
||||
[System.Serializable]
|
||||
public class OnSubmitEvent : UnityEvent<string> { }
|
||||
|
||||
public OnSubmitEvent OnSubmit;
|
||||
|
||||
bool registered;
|
||||
|
||||
void OnEnable()
|
||||
{
|
||||
if (!registered)
|
||||
{
|
||||
registered = true;
|
||||
PropertyValueInput.onEndEdit.AddListener(EndEditOnEnter);
|
||||
}
|
||||
}
|
||||
|
||||
void OnDisable()
|
||||
{
|
||||
registered = false;
|
||||
PropertyValueInput.onEndEdit.RemoveListener(EndEditOnEnter);
|
||||
}
|
||||
|
||||
public void SetValue(string value)
|
||||
{
|
||||
PropertyValueInput.text = value.ToString();
|
||||
}
|
||||
|
||||
public void EndEditOnEnter(string value)
|
||||
{
|
||||
if (Input.GetKey(KeyCode.Return) || Input.GetKey(KeyCode.KeypadEnter) || Input.GetKey(KeyCode.Tab))
|
||||
{
|
||||
this.SubmitForm(value.Trim());
|
||||
}
|
||||
else
|
||||
{
|
||||
this.SubmitForm(value);
|
||||
}
|
||||
}
|
||||
|
||||
public void SubmitForm(string value)
|
||||
{
|
||||
OnSubmit.Invoke(value);
|
||||
}
|
||||
}
|
||||
}
|
@@ -0,0 +1,12 @@
|
||||
fileFormatVersion: 2
|
||||
guid: e02d5b184c20e43ebba343cc89e35962
|
||||
timeCreated: 1519216710
|
||||
licenseType: Store
|
||||
MonoImporter:
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
@@ -0,0 +1,45 @@
|
||||
// --------------------------------------------------------------------------------------------------------------------
|
||||
// <copyright file="ToggleExpand.cs" company="Exit Games GmbH">
|
||||
// Part of: Pun Cockpit Demo
|
||||
// </copyright>
|
||||
// <author>developer@exitgames.com</author>
|
||||
// --------------------------------------------------------------------------------------------------------------------
|
||||
|
||||
using UnityEngine;
|
||||
using UnityEngine.UI;
|
||||
|
||||
namespace Photon.Pun.Demo.Cockpit
|
||||
{
|
||||
/// <summary>
|
||||
/// UI toggle to activate GameObject.
|
||||
/// </summary>
|
||||
public class ToggleExpand : MonoBehaviour
|
||||
{
|
||||
public GameObject Content;
|
||||
|
||||
public Toggle Toggle;
|
||||
|
||||
bool _init;
|
||||
|
||||
void OnEnable()
|
||||
{
|
||||
Content.SetActive(Toggle.isOn);
|
||||
|
||||
if (!_init)
|
||||
{
|
||||
_init = true;
|
||||
Toggle.onValueChanged.AddListener(HandleToggleOnValudChanged);
|
||||
}
|
||||
|
||||
HandleToggleOnValudChanged(Toggle.isOn);
|
||||
|
||||
}
|
||||
|
||||
|
||||
void HandleToggleOnValudChanged(bool value)
|
||||
{
|
||||
Content.SetActive(value);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
@@ -0,0 +1,12 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 50b3f63970a204e72b36153eb93684bf
|
||||
timeCreated: 1525954565
|
||||
licenseType: Store
|
||||
MonoImporter:
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
@@ -0,0 +1,40 @@
|
||||
// --------------------------------------------------------------------------------------------------------------------
|
||||
// <copyright file="LayoutElementMatchSize.cs" company="Exit Games GmbH">
|
||||
// Part of: Pun Cockpit Demo
|
||||
// </copyright>
|
||||
// <author>developer@exitgames.com</author>
|
||||
// --------------------------------------------------------------------------------------------------------------------
|
||||
|
||||
using UnityEngine;
|
||||
using UnityEngine.UI;
|
||||
|
||||
namespace Photon.Pun.Demo.Cockpit
|
||||
{
|
||||
/// <summary>
|
||||
/// Force a LayoutElement to march a RectTransform sizeDelta. Useful for complex child content
|
||||
/// </summary>
|
||||
public class LayoutElementMatchSize : MonoBehaviour
|
||||
{
|
||||
|
||||
public LayoutElement layoutElement;
|
||||
public RectTransform Target;
|
||||
|
||||
|
||||
public bool MatchHeight = true;
|
||||
public bool MatchWidth;
|
||||
|
||||
|
||||
void Update()
|
||||
{
|
||||
|
||||
if (MatchHeight)
|
||||
{
|
||||
if (layoutElement.minHeight != Target.sizeDelta.y)
|
||||
{
|
||||
layoutElement.minHeight = Target.sizeDelta.y;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
@@ -0,0 +1,12 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 3ec618017b87f49b4a2bfc6a0a0bff3d
|
||||
timeCreated: 1526042927
|
||||
licenseType: Store
|
||||
MonoImporter:
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
@@ -0,0 +1,68 @@
|
||||
// --------------------------------------------------------------------------------------------------------------------
|
||||
// <copyright file="NickNameField.cs" company="Exit Games GmbH">
|
||||
// Part of: Pun Cockpit Demo
|
||||
// </copyright>
|
||||
// <author>developer@exitgames.com</author>
|
||||
// --------------------------------------------------------------------------------------------------------------------
|
||||
|
||||
using UnityEngine;
|
||||
using UnityEngine.UI;
|
||||
|
||||
namespace Photon.Pun.Demo.Cockpit
|
||||
{
|
||||
/// <summary>
|
||||
/// Nickname InputField.
|
||||
/// </summary>
|
||||
public class NickNameField : MonoBehaviour
|
||||
{
|
||||
public InputField PropertyValueInput;
|
||||
|
||||
string _cache;
|
||||
|
||||
bool registered;
|
||||
|
||||
void OnEnable()
|
||||
{
|
||||
if (!registered)
|
||||
{
|
||||
registered = true;
|
||||
PropertyValueInput.onEndEdit.AddListener(OnEndEdit);
|
||||
}
|
||||
}
|
||||
|
||||
void OnDisable()
|
||||
{
|
||||
registered = false;
|
||||
PropertyValueInput.onEndEdit.RemoveListener(OnEndEdit);
|
||||
}
|
||||
|
||||
void Update()
|
||||
{
|
||||
if (PhotonNetwork.NickName != _cache)
|
||||
{
|
||||
_cache = PhotonNetwork.NickName;
|
||||
PropertyValueInput.text = _cache;
|
||||
}
|
||||
}
|
||||
|
||||
// new UI will fire "EndEdit" event also when loosing focus. So check "enter" key and only then submit form.
|
||||
public void OnEndEdit(string value)
|
||||
{
|
||||
if (Input.GetKey(KeyCode.Return) || Input.GetKey(KeyCode.KeypadEnter) || Input.GetKey(KeyCode.Tab))
|
||||
{
|
||||
this.SubmitForm(value.Trim());
|
||||
}
|
||||
else
|
||||
{
|
||||
this.SubmitForm(value);
|
||||
}
|
||||
}
|
||||
|
||||
public void SubmitForm(string value)
|
||||
{
|
||||
_cache = value;
|
||||
PhotonNetwork.NickName = _cache;
|
||||
//Debug.Log("PhotonNetwork.NickName = " + PhotonNetwork.NickName, this);
|
||||
}
|
||||
}
|
||||
}
|
@@ -0,0 +1,12 @@
|
||||
fileFormatVersion: 2
|
||||
guid: ea425f69fa0f244a79a3514a6d64cab2
|
||||
timeCreated: 1521548922
|
||||
licenseType: Store
|
||||
MonoImporter:
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
@@ -0,0 +1,27 @@
|
||||
// --------------------------------------------------------------------------------------------------------------------
|
||||
// <copyright file="OnlineDocButton.cs" company="Exit Games GmbH">
|
||||
// Part of: Pun Cockpit Demo
|
||||
// </copyright>
|
||||
// <author>developer@exitgames.com</author>
|
||||
// --------------------------------------------------------------------------------------------------------------------
|
||||
|
||||
using UnityEngine;
|
||||
using UnityEngine.EventSystems;
|
||||
|
||||
namespace Photon.Pun.Demo.Cockpit
|
||||
{
|
||||
/// <summary>
|
||||
/// Open an Url on Pointer Click.
|
||||
/// </summary>
|
||||
public class OnlineDocButton : MonoBehaviour, IPointerClickHandler
|
||||
{
|
||||
public string Url = "https://doc.photonengine.com/en-us/pun/v2/getting-started/pun-intro";
|
||||
|
||||
//Detect if a click occurs
|
||||
public void OnPointerClick(PointerEventData pointerEventData)
|
||||
{
|
||||
Application.OpenURL(Url);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
@@ -0,0 +1,12 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 738f2e2e03bb948949a9823e60ee65d5
|
||||
timeCreated: 1519212778
|
||||
licenseType: Store
|
||||
MonoImporter:
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
@@ -0,0 +1,70 @@
|
||||
// --------------------------------------------------------------------------------------------------------------------
|
||||
// <copyright file="SendRateField.cs" company="Exit Games GmbH">
|
||||
// Part of: Pun Cockpit Demo
|
||||
// </copyright>
|
||||
// <author>developer@exitgames.com</author>
|
||||
// --------------------------------------------------------------------------------------------------------------------
|
||||
|
||||
using UnityEngine;
|
||||
using UnityEngine.UI;
|
||||
|
||||
namespace Photon.Pun.Demo.Cockpit
|
||||
{
|
||||
/// <summary>
|
||||
/// PhotonNetwork.SendRate InputField.
|
||||
/// </summary>
|
||||
public class SendRateField : MonoBehaviour
|
||||
{
|
||||
|
||||
public InputField PropertyValueInput;
|
||||
|
||||
int _cache;
|
||||
|
||||
bool registered;
|
||||
|
||||
void OnEnable()
|
||||
{
|
||||
if (!registered)
|
||||
{
|
||||
registered = true;
|
||||
PropertyValueInput.onEndEdit.AddListener(OnEndEdit);
|
||||
}
|
||||
}
|
||||
|
||||
void OnDisable()
|
||||
{
|
||||
registered = false;
|
||||
PropertyValueInput.onEndEdit.RemoveListener(OnEndEdit);
|
||||
}
|
||||
|
||||
void Update()
|
||||
{
|
||||
if (PhotonNetwork.SendRate != _cache)
|
||||
{
|
||||
_cache = PhotonNetwork.SendRate;
|
||||
PropertyValueInput.text = _cache.ToString();
|
||||
}
|
||||
}
|
||||
|
||||
// new UI will fire "EndEdit" event also when loosing focus. So check "enter" key and only then StartChat.
|
||||
public void OnEndEdit(string value)
|
||||
{
|
||||
if (Input.GetKey(KeyCode.Return) || Input.GetKey(KeyCode.KeypadEnter) || Input.GetKey(KeyCode.Tab))
|
||||
{
|
||||
this.SubmitForm(value.Trim());
|
||||
}
|
||||
else
|
||||
{
|
||||
this.SubmitForm(value);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public void SubmitForm(string value)
|
||||
{
|
||||
_cache = int.Parse(value);
|
||||
PhotonNetwork.SendRate = _cache;
|
||||
//Debug.Log("PhotonNetwork.SendRate = " + PhotonNetwork.SendRate, this);
|
||||
}
|
||||
}
|
||||
}
|
@@ -0,0 +1,12 @@
|
||||
fileFormatVersion: 2
|
||||
guid: f6ed1c2b7c01b4b3cba625a08a991c7f
|
||||
timeCreated: 1519133073
|
||||
licenseType: Store
|
||||
MonoImporter:
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
@@ -0,0 +1,69 @@
|
||||
// --------------------------------------------------------------------------------------------------------------------
|
||||
// <copyright file="SendRateOnSerializeField.cs" company="Exit Games GmbH">
|
||||
// Part of: Pun Cockpit Demo
|
||||
// </copyright>
|
||||
// <author>developer@exitgames.com</author>
|
||||
// --------------------------------------------------------------------------------------------------------------------
|
||||
|
||||
using UnityEngine;
|
||||
using UnityEngine.UI;
|
||||
|
||||
namespace Photon.Pun.Demo.Cockpit
|
||||
{
|
||||
/// <summary>
|
||||
/// PhotonNetwork.SerializationRate InputField
|
||||
/// </summary>
|
||||
public class SendRateOnSerializeField : MonoBehaviour
|
||||
{
|
||||
|
||||
public InputField PropertyValueInput;
|
||||
|
||||
int _cache;
|
||||
|
||||
bool registered;
|
||||
|
||||
void OnEnable()
|
||||
{
|
||||
if (!registered)
|
||||
{
|
||||
registered = true;
|
||||
PropertyValueInput.onEndEdit.AddListener(OnEndEdit);
|
||||
}
|
||||
}
|
||||
|
||||
void OnDisable()
|
||||
{
|
||||
registered = false;
|
||||
PropertyValueInput.onEndEdit.RemoveListener(OnEndEdit);
|
||||
}
|
||||
|
||||
void Update()
|
||||
{
|
||||
if (PhotonNetwork.SerializationRate != _cache)
|
||||
{
|
||||
_cache = PhotonNetwork.SerializationRate;
|
||||
PropertyValueInput.text = _cache.ToString();
|
||||
}
|
||||
}
|
||||
|
||||
// new UI will fire "EndEdit" event also when loosing focus. So check "enter" key and only then StartChat.
|
||||
public void OnEndEdit(string value)
|
||||
{
|
||||
if (Input.GetKey(KeyCode.Return) || Input.GetKey(KeyCode.KeypadEnter) || Input.GetKey(KeyCode.Tab))
|
||||
{
|
||||
this.SubmitForm(value.Trim());
|
||||
}
|
||||
else
|
||||
{
|
||||
this.SubmitForm(value);
|
||||
}
|
||||
}
|
||||
|
||||
public void SubmitForm(string value)
|
||||
{
|
||||
_cache = int.Parse(PropertyValueInput.text);
|
||||
PhotonNetwork.SerializationRate = _cache;
|
||||
//Debug.Log("PhotonNetwork.SerializationRate = " + PhotonNetwork.SerializationRate, this);
|
||||
}
|
||||
}
|
||||
}
|
@@ -0,0 +1,12 @@
|
||||
fileFormatVersion: 2
|
||||
guid: e8014b533c3a148558bd8c78ceea7a5f
|
||||
timeCreated: 1519134196
|
||||
licenseType: Store
|
||||
MonoImporter:
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
Reference in New Issue
Block a user