first commit
This commit is contained in:
40
Assets/Photon/PhotonChat/Demos/Common/EventSystemSpawner.cs
Normal file
40
Assets/Photon/PhotonChat/Demos/Common/EventSystemSpawner.cs
Normal 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>();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,12 @@
|
||||
fileFormatVersion: 2
|
||||
guid: bd5ff9965d0784cad8e07f5eb9cb9c06
|
||||
timeCreated: 1538396402
|
||||
licenseType: Store
|
||||
MonoImporter:
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
24
Assets/Photon/PhotonChat/Demos/Common/OnStartDelete.cs
Normal file
24
Assets/Photon/PhotonChat/Demos/Common/OnStartDelete.cs
Normal 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);
|
||||
}
|
||||
}
|
||||
}
|
12
Assets/Photon/PhotonChat/Demos/Common/OnStartDelete.cs.meta
Normal file
12
Assets/Photon/PhotonChat/Demos/Common/OnStartDelete.cs.meta
Normal 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:
|
@ -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;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,12 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 060fe8295761a47268586d33ef5673e0
|
||||
timeCreated: 1538395273
|
||||
licenseType: Store
|
||||
MonoImporter:
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
@ -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;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
@ -0,0 +1,12 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 1e808171e8963498bb1db072a977d750
|
||||
timeCreated: 1538395754
|
||||
licenseType: Store
|
||||
MonoImporter:
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
Reference in New Issue
Block a user