initial upload
This commit is contained in:
@ -0,0 +1,65 @@
|
||||
using UnityEngine;
|
||||
using UnityEngine.UI;
|
||||
|
||||
namespace Convai.Scripts.Runtime.UI
|
||||
{
|
||||
/// <summary>
|
||||
/// Base class to handle different toggle status, including loading and saving
|
||||
/// </summary>
|
||||
public class ActiveStatusHandler : MonoBehaviour
|
||||
{
|
||||
[SerializeField] protected Toggle _activeStatusToggle;
|
||||
|
||||
private void Awake()
|
||||
{
|
||||
// Subscribe to the toggle's value change event.
|
||||
_activeStatusToggle.onValueChanged.AddListener(OnStatusChange);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Subscribe to events when this component is enabled.
|
||||
/// </summary>
|
||||
private void OnEnable()
|
||||
{
|
||||
// Subscribe to the event when saved data is loaded.
|
||||
UISaveLoadSystem.Instance.OnLoad += UISaveLoadSystem_OnLoad;
|
||||
|
||||
// Subscribe to the event when data is saved.
|
||||
UISaveLoadSystem.Instance.OnSave += UISaveLoadSystem_OnSave;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Unsubscribe from events when this component is disabled.
|
||||
/// </summary>
|
||||
private void OnDisable()
|
||||
{
|
||||
// Subscribe to the event when saved data is loaded.
|
||||
UISaveLoadSystem.Instance.OnLoad -= UISaveLoadSystem_OnLoad;
|
||||
|
||||
// Subscribe to the event when data is saved.
|
||||
UISaveLoadSystem.Instance.OnSave -= UISaveLoadSystem_OnSave;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Event handler for when saved data is loaded.
|
||||
/// </summary>
|
||||
protected virtual void UISaveLoadSystem_OnLoad()
|
||||
{
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Event handler for when data is saved.
|
||||
/// </summary>
|
||||
protected virtual void UISaveLoadSystem_OnSave()
|
||||
{
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Set the activation status
|
||||
/// </summary>
|
||||
/// <param name="value"> The new activation status. </param>
|
||||
public virtual void OnStatusChange(bool value)
|
||||
{
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,3 @@
|
||||
fileFormatVersion: 2
|
||||
guid: ef81b07ac96d481f954ce8ce8431b7fb
|
||||
timeCreated: 1718273073
|
||||
25
Assets/Convai/Scripts/Runtime/UI/Utils/UIUtilities.cs
Normal file
25
Assets/Convai/Scripts/Runtime/UI/Utils/UIUtilities.cs
Normal file
@ -0,0 +1,25 @@
|
||||
using TMPro;
|
||||
using UnityEngine.UI;
|
||||
|
||||
namespace Convai.Scripts.Runtime.UI
|
||||
{
|
||||
public abstract class UIUtilities
|
||||
{
|
||||
/// <summary>
|
||||
/// Checks and return if any input field is focused or not
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
public static bool IsAnyInputFieldFocused()
|
||||
{
|
||||
foreach (Selectable selectable in Selectable.allSelectablesArray)
|
||||
switch (selectable)
|
||||
{
|
||||
case InputField { isFocused: true }:
|
||||
case TMP_InputField { isFocused: true }:
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
11
Assets/Convai/Scripts/Runtime/UI/Utils/UIUtilities.cs.meta
Normal file
11
Assets/Convai/Scripts/Runtime/UI/Utils/UIUtilities.cs.meta
Normal file
@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 33916f7f7f464544ba8f96a3a5c5e6f7
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
Reference in New Issue
Block a user