first commit
This commit is contained in:
@ -0,0 +1,53 @@
|
||||
// --------------------------------------------------------------------------------------------------------------------
|
||||
// <copyright file="ButtonInsideScrollList.cs" company="Exit Games GmbH">
|
||||
// Part of: Photon Unity Utilities,
|
||||
// </copyright>
|
||||
// <summary>
|
||||
// Used on Buttons inside UI lists to prevent scrollRect parent to scroll when down on buttons.
|
||||
// </summary>
|
||||
// <author>developer@exitgames.com</author>
|
||||
// --------------------------------------------------------------------------------------------------------------------
|
||||
|
||||
using UnityEngine;
|
||||
using UnityEngine.EventSystems;
|
||||
using UnityEngine.UI;
|
||||
|
||||
namespace Photon.Pun.UtilityScripts
|
||||
{
|
||||
/// <summary>
|
||||
/// Button inside scroll list will stop scrolling ability of scrollRect container, so that when pressing down on a button and draggin up and down will not affect scrolling.
|
||||
/// this doesn't do anything if no scrollRect component found in Parent Hierarchy.
|
||||
/// </summary>
|
||||
public class ButtonInsideScrollList : MonoBehaviour, IPointerDownHandler, IPointerUpHandler {
|
||||
|
||||
ScrollRect scrollRect;
|
||||
|
||||
// Use this for initialization
|
||||
void Start () {
|
||||
scrollRect = GetComponentInParent<ScrollRect>();
|
||||
}
|
||||
|
||||
#region IPointerDownHandler implementation
|
||||
void IPointerDownHandler.OnPointerDown (PointerEventData eventData)
|
||||
{
|
||||
if (scrollRect !=null)
|
||||
{
|
||||
scrollRect.StopMovement();
|
||||
scrollRect.enabled = false;
|
||||
}
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region IPointerUpHandler implementation
|
||||
|
||||
void IPointerUpHandler.OnPointerUp (PointerEventData eventData)
|
||||
{
|
||||
if (scrollRect !=null && !scrollRect.enabled)
|
||||
{
|
||||
scrollRect.enabled = true;
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: e0e8b381f2c05442ca5c01638958156a
|
||||
MonoImporter:
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
@ -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.Pun.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: 68187d3cf4c8746aaa64930f1a766a38
|
||||
timeCreated: 1529319867
|
||||
licenseType: Store
|
||||
MonoImporter:
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
@ -0,0 +1,64 @@
|
||||
// --------------------------------------------------------------------------------------------------------------------
|
||||
// <copyright file="ImageToggleIsOnTransition.cs" company="Exit Games GmbH">
|
||||
// </copyright>
|
||||
// <summary>
|
||||
// Use this on Toggle graphics to have some color transition as well without corrupting toggle's behaviour.
|
||||
// </summary>
|
||||
// <author>developer@exitgames.com</author>
|
||||
// --------------------------------------------------------------------------------------------------------------------
|
||||
|
||||
using UnityEngine;
|
||||
using UnityEngine.EventSystems;
|
||||
using UnityEngine.UI;
|
||||
|
||||
namespace Photon.Pun.UtilityScripts
|
||||
{
|
||||
/// <summary>
|
||||
/// Use this on toggles texts to have some color transition on the text depending on the isOn State.
|
||||
/// </summary>
|
||||
[RequireComponent(typeof(Graphic))]
|
||||
public class GraphicToggleIsOnTransition : MonoBehaviour, IPointerEnterHandler, IPointerExitHandler
|
||||
{
|
||||
public Toggle toggle;
|
||||
|
||||
private Graphic _graphic;
|
||||
|
||||
public Color NormalOnColor = Color.white;
|
||||
public Color NormalOffColor = Color.black;
|
||||
public Color HoverOnColor = Color.black;
|
||||
public Color HoverOffColor = Color.black;
|
||||
|
||||
private bool isHover;
|
||||
|
||||
public void OnPointerEnter(PointerEventData eventData)
|
||||
{
|
||||
this.isHover = true;
|
||||
this._graphic.color = this.toggle.isOn ? this.HoverOnColor : this.HoverOffColor;
|
||||
}
|
||||
|
||||
public void OnPointerExit(PointerEventData eventData)
|
||||
{
|
||||
this.isHover = false;
|
||||
this._graphic.color = this.toggle.isOn ? this.NormalOnColor : this.NormalOffColor;
|
||||
}
|
||||
|
||||
public void OnEnable()
|
||||
{
|
||||
this._graphic = this.GetComponent<Graphic>();
|
||||
|
||||
this.OnValueChanged(this.toggle.isOn);
|
||||
|
||||
this.toggle.onValueChanged.AddListener(this.OnValueChanged);
|
||||
}
|
||||
|
||||
public void OnDisable()
|
||||
{
|
||||
this.toggle.onValueChanged.RemoveListener(this.OnValueChanged);
|
||||
}
|
||||
|
||||
public void OnValueChanged(bool isOn)
|
||||
{
|
||||
this._graphic.color = isOn ? (this.isHover ? this.HoverOnColor : this.HoverOnColor) : (this.isHover ? this.NormalOffColor : this.NormalOffColor);
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,12 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 195602a009c4b42b6a62e0bdf601b70d
|
||||
timeCreated: 1524059610
|
||||
licenseType: Store
|
||||
MonoImporter:
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
@ -0,0 +1,45 @@
|
||||
// <copyright file="OnPointerOverTooltip.cs" company="Exit Games GmbH">
|
||||
// </copyright>
|
||||
// <summary>
|
||||
// Set focus to a given photonView when pointed is over
|
||||
// </summary>
|
||||
// <author>developer@exitgames.com</author>
|
||||
// --------------------------------------------------------------------------------------------------------------------
|
||||
|
||||
using UnityEngine;
|
||||
using UnityEngine.EventSystems;
|
||||
|
||||
namespace Photon.Pun.UtilityScripts
|
||||
{
|
||||
/// <summary>
|
||||
/// Set focus to a given photonView when pointed is over
|
||||
/// </summary>
|
||||
public class OnPointerOverTooltip : MonoBehaviour,IPointerEnterHandler,IPointerExitHandler
|
||||
{
|
||||
|
||||
void OnDestroy()
|
||||
{
|
||||
PointedAtGameObjectInfo.Instance.RemoveFocus(this.GetComponent<PhotonView>());
|
||||
}
|
||||
|
||||
#region IPointerExitHandler implementation
|
||||
|
||||
void IPointerExitHandler.OnPointerExit (PointerEventData eventData)
|
||||
{
|
||||
PointedAtGameObjectInfo.Instance.RemoveFocus (this.GetComponent<PhotonView>());
|
||||
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region IPointerEnterHandler implementation
|
||||
|
||||
void IPointerEnterHandler.OnPointerEnter (PointerEventData eventData)
|
||||
{
|
||||
PointedAtGameObjectInfo.Instance.SetFocus (this.GetComponent<PhotonView>());
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
}
|
||||
}
|
@ -0,0 +1,12 @@
|
||||
fileFormatVersion: 2
|
||||
guid: ff93154db96e843fbbc5e816ec0d2b48
|
||||
timeCreated: 1495545560
|
||||
licenseType: Store
|
||||
MonoImporter:
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
@ -0,0 +1,123 @@
|
||||
// --------------------------------------------------------------------------------------------------------------------
|
||||
// <copyright file="TabViewManager.cs" company="Exit Games GmbH">
|
||||
// Part of: PunCockpit
|
||||
// </copyright>
|
||||
// <summary>
|
||||
// Simple Management for Tabs, it requires a ToggleGroup, and then for each Tab, a Unique Name, the related Toggle and its associated RectTransform View
|
||||
// this manager handles Tab views activation and deactivation, and provides a Unity Event Callback when a tab was selected.
|
||||
// </summary>
|
||||
// <author>developer@exitgames.com</author>
|
||||
// --------------------------------------------------------------------------------------------------------------------
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
|
||||
using UnityEngine;
|
||||
using UnityEngine.UI;
|
||||
using UnityEngine.Events;
|
||||
|
||||
namespace Photon.Pun.UtilityScripts
|
||||
{
|
||||
/// <summary>
|
||||
/// Tab view manager. Handles Tab views activation and deactivation, and provides a Unity Event Callback when a tab was selected.
|
||||
/// </summary>
|
||||
public class TabViewManager : MonoBehaviour
|
||||
{
|
||||
|
||||
/// <summary>
|
||||
/// Tab change event.
|
||||
/// </summary>
|
||||
[System.Serializable]
|
||||
public class TabChangeEvent : UnityEvent<string> { }
|
||||
|
||||
[Serializable]
|
||||
public class Tab
|
||||
{
|
||||
public string ID = "";
|
||||
public Toggle Toggle;
|
||||
public RectTransform View;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// The toggle group component target.
|
||||
/// </summary>
|
||||
public ToggleGroup ToggleGroup;
|
||||
|
||||
/// <summary>
|
||||
/// all the tabs for this group
|
||||
/// </summary>
|
||||
public Tab[] Tabs;
|
||||
|
||||
/// <summary>
|
||||
/// The on tab changed Event.
|
||||
/// </summary>
|
||||
public TabChangeEvent OnTabChanged;
|
||||
|
||||
protected Tab CurrentTab;
|
||||
|
||||
Dictionary<Toggle, Tab> Tab_lut;
|
||||
|
||||
void Start()
|
||||
{
|
||||
|
||||
Tab_lut = new Dictionary<Toggle, Tab>();
|
||||
|
||||
foreach (Tab _tab in this.Tabs)
|
||||
{
|
||||
|
||||
Tab_lut[_tab.Toggle] = _tab;
|
||||
|
||||
_tab.View.gameObject.SetActive(_tab.Toggle.isOn);
|
||||
|
||||
if (_tab.Toggle.isOn)
|
||||
{
|
||||
CurrentTab = _tab;
|
||||
}
|
||||
_tab.Toggle.onValueChanged.AddListener((isSelected) =>
|
||||
{
|
||||
if (!isSelected)
|
||||
{
|
||||
return;
|
||||
}
|
||||
OnTabSelected(_tab);
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Selects a given tab.
|
||||
/// </summary>
|
||||
/// <param name="id">Tab Id</param>
|
||||
public void SelectTab(string id)
|
||||
{
|
||||
foreach (Tab _t in Tabs)
|
||||
{
|
||||
if (_t.ID == id)
|
||||
{
|
||||
_t.Toggle.isOn = true;
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// final method for a tab selection routine
|
||||
/// </summary>
|
||||
/// <param name="tab">Tab.</param>
|
||||
void OnTabSelected(Tab tab)
|
||||
{
|
||||
CurrentTab.View.gameObject.SetActive(false);
|
||||
|
||||
CurrentTab = Tab_lut[ToggleGroup.ActiveToggles().FirstOrDefault()];
|
||||
|
||||
CurrentTab.View.gameObject.SetActive(true);
|
||||
|
||||
OnTabChanged.Invoke(CurrentTab.ID);
|
||||
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,12 @@
|
||||
fileFormatVersion: 2
|
||||
guid: c94485733838d40fda441b2c0fbbec10
|
||||
timeCreated: 1521118118
|
||||
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.Pun.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,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 9d234639538a34b8d9e3cc6362a7afd0
|
||||
MonoImporter:
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
@ -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.Pun.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,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: ec99d371d7c8e44899ce4b834dfd4d6a
|
||||
MonoImporter:
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
Reference in New Issue
Block a user