-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
- Loading branch information
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
// -------------------------------------------------------------------------------------------------------------------- | ||
// <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 instanciated 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 Start() | ||
{ | ||
EventSystem sceneEventSystem = FindObjectOfType<EventSystem>(); | ||
if (sceneEventSystem == null) | ||
{ | ||
GameObject eventSystem = new GameObject("EventSystem"); | ||
|
||
eventSystem.AddComponent<EventSystem>(); | ||
eventSystem.AddComponent<StandaloneInputModule>(); | ||
} | ||
} | ||
} | ||
} |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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); | ||
} | ||
} | ||
} |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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; | ||
} | ||
} | ||
} | ||
} |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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; | ||
} | ||
|
||
} | ||
} |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
using Photon.Chat; | ||
using Photon.Realtime; | ||
|
||
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 | ||
}; | ||
} | ||
} |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
using UnityEngine; | ||
using System.Collections; | ||
using UnityEngine.EventSystems; | ||
using UnityEngine.UI; | ||
|
||
public class ChannelSelector : MonoBehaviour, IPointerClickHandler | ||
{ | ||
public string Channel; | ||
|
||
public void SetChannel(string channel) | ||
{ | ||
this.Channel = channel; | ||
Text t = GetComponentInChildren<Text>(); | ||
t.text = this.Channel; | ||
} | ||
|
||
public void OnPointerClick(PointerEventData eventData) | ||
{ | ||
ChatGui handler = FindObjectOfType<ChatGui>(); | ||
handler.ShowChannel(this.Channel); | ||
} | ||
} |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.