Imported UI Assets
This commit is contained in:
@ -0,0 +1,276 @@
|
||||
using System.Collections;
|
||||
using UnityEngine;
|
||||
using UnityEngine.Events;
|
||||
using UnityEngine.UI;
|
||||
using UnityEngine.EventSystems;
|
||||
using UnityEngine.InputSystem;
|
||||
using TMPro;
|
||||
|
||||
namespace Michsky.UI.Heat
|
||||
{
|
||||
[ExecuteInEditMode]
|
||||
[AddComponentMenu("Heat UI/Input/Hotkey Event")]
|
||||
public class HotkeyEvent : MonoBehaviour, IPointerClickHandler, IPointerEnterHandler, IPointerExitHandler
|
||||
{
|
||||
// Content
|
||||
public HotkeyType hotkeyType = HotkeyType.Custom;
|
||||
public ControllerPreset controllerPreset;
|
||||
public InputAction hotkey;
|
||||
public string keyID = "Escape";
|
||||
public string hotkeyLabel = "Exit";
|
||||
|
||||
// Resources
|
||||
[SerializeField] private GameObject iconParent;
|
||||
[SerializeField] private GameObject textParent;
|
||||
[SerializeField] private Image iconObj;
|
||||
[SerializeField] private TextMeshProUGUI labelObj;
|
||||
[SerializeField] private TextMeshProUGUI textObj;
|
||||
[SerializeField] private CanvasGroup normalCG;
|
||||
[SerializeField] private CanvasGroup highlightCG;
|
||||
|
||||
// Settings
|
||||
public bool useSounds = false;
|
||||
public bool useLocalization = true;
|
||||
[Range(1, 15)] public float fadingMultiplier = 8;
|
||||
|
||||
// Events
|
||||
public UnityEvent onHotkeyPress = new UnityEvent();
|
||||
|
||||
// Helpers
|
||||
bool isInitialized = false;
|
||||
LocalizedObject localizedObject;
|
||||
|
||||
#if UNITY_EDITOR
|
||||
public bool showOutputOnEditor = true;
|
||||
#endif
|
||||
|
||||
public enum HotkeyType { Dynamic, Custom }
|
||||
|
||||
void OnEnable()
|
||||
{
|
||||
#if UNITY_EDITOR
|
||||
if (!Application.isPlaying && controllerPreset != null && hotkeyType == HotkeyType.Dynamic) { UpdateVisual(); }
|
||||
if (!Application.isPlaying) { return; }
|
||||
#endif
|
||||
if (!isInitialized) { Initialize(); }
|
||||
if (ControllerManager.instance != null && hotkeyType == HotkeyType.Dynamic)
|
||||
{
|
||||
ControllerManager.instance.hotkeyObjects.Add(this);
|
||||
controllerPreset = ControllerManager.instance.currentControllerPreset;
|
||||
}
|
||||
|
||||
UpdateUI();
|
||||
}
|
||||
|
||||
void Update()
|
||||
{
|
||||
if (hotkey.triggered)
|
||||
{
|
||||
onHotkeyPress.Invoke();
|
||||
}
|
||||
}
|
||||
|
||||
void Initialize()
|
||||
{
|
||||
#if UNITY_EDITOR
|
||||
if (!Application.isPlaying) { return; }
|
||||
#endif
|
||||
hotkey.Enable();
|
||||
|
||||
if (hotkeyType == HotkeyType.Dynamic && gameObject.GetComponent<Image>() == null)
|
||||
{
|
||||
Image raycastImg = gameObject.AddComponent<Image>();
|
||||
raycastImg.color = new Color(0, 0, 0, 0);
|
||||
raycastImg.raycastTarget = true;
|
||||
}
|
||||
|
||||
if (UIManagerAudio.instance == null) { useSounds = false; }
|
||||
if (useLocalization)
|
||||
{
|
||||
localizedObject = gameObject.GetComponent<LocalizedObject>();
|
||||
|
||||
if (localizedObject == null || !localizedObject.CheckLocalizationStatus()) { useLocalization = false; }
|
||||
else if (localizedObject != null && !string.IsNullOrEmpty(localizedObject.localizationKey))
|
||||
{
|
||||
// Forcing object to take the localized output on awake
|
||||
hotkeyLabel = localizedObject.GetKeyOutput(localizedObject.localizationKey);
|
||||
|
||||
// Change label text on language change
|
||||
localizedObject.onLanguageChanged.AddListener(delegate
|
||||
{
|
||||
hotkeyLabel = localizedObject.GetKeyOutput(localizedObject.localizationKey);
|
||||
SetLabel(hotkeyLabel);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
if (useSounds)
|
||||
{
|
||||
onHotkeyPress.AddListener(delegate { UIManagerAudio.instance.audioSource.PlayOneShot(UIManagerAudio.instance.UIManagerAsset.clickSound); });
|
||||
}
|
||||
|
||||
isInitialized = true;
|
||||
}
|
||||
|
||||
public void UpdateUI()
|
||||
{
|
||||
if (hotkeyType == HotkeyType.Custom)
|
||||
return;
|
||||
|
||||
if (hotkeyType == HotkeyType.Dynamic)
|
||||
{
|
||||
if (controllerPreset == null) { return; }
|
||||
if (highlightCG != null) { highlightCG.alpha = 0; }
|
||||
|
||||
bool keyFound = false;
|
||||
|
||||
for (int i = 0; i < controllerPreset.items.Count; i++)
|
||||
{
|
||||
if (controllerPreset.items[i].itemID == keyID)
|
||||
{
|
||||
keyFound = true;
|
||||
gameObject.SetActive(true);
|
||||
if (labelObj != null) { labelObj.text = hotkeyLabel; }
|
||||
|
||||
if (controllerPreset.items[i].itemType == ControllerPreset.ItemType.Icon)
|
||||
{
|
||||
if (iconParent != null) { iconParent.SetActive(true); }
|
||||
if (textParent != null) { textParent.SetActive(false); }
|
||||
if (iconObj != null) { iconObj.sprite = controllerPreset.items[i].itemIcon; }
|
||||
}
|
||||
|
||||
else if (controllerPreset.items[i].itemType == ControllerPreset.ItemType.Text)
|
||||
{
|
||||
if (iconParent != null) { iconParent.SetActive(false); }
|
||||
if (textParent != null) { textParent.SetActive(true); }
|
||||
if (textObj != null) { textObj.text = controllerPreset.items[i].itemText; }
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (keyFound == false)
|
||||
{
|
||||
// gameObject.SetActive(false);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
if (gameObject.activeInHierarchy == true && Application.isPlaying) { StartCoroutine("LayoutFix"); }
|
||||
else
|
||||
{
|
||||
LayoutRebuilder.ForceRebuildLayoutImmediate(GetComponent<RectTransform>());
|
||||
if (normalCG != null) { LayoutRebuilder.ForceRebuildLayoutImmediate(normalCG.GetComponent<RectTransform>()); }
|
||||
}
|
||||
}
|
||||
|
||||
#if UNITY_EDITOR
|
||||
public void UpdateVisual()
|
||||
{
|
||||
if (controllerPreset == null) { return; }
|
||||
if (highlightCG != null) { highlightCG.alpha = 0; }
|
||||
for (int i = 0; i < controllerPreset.items.Count; i++)
|
||||
{
|
||||
if (controllerPreset.items[i].itemID == keyID)
|
||||
{
|
||||
if (controllerPreset.items[i].itemType == ControllerPreset.ItemType.Icon)
|
||||
{
|
||||
if (iconParent != null) { iconParent.SetActive(true); }
|
||||
if (textParent != null) { textParent.SetActive(false); }
|
||||
if (iconObj != null) { iconObj.sprite = controllerPreset.items[i].itemIcon; }
|
||||
}
|
||||
|
||||
else if (controllerPreset.items[i].itemType == ControllerPreset.ItemType.Text)
|
||||
{
|
||||
if (iconParent != null) { iconParent.SetActive(false); }
|
||||
if (textParent != null) { textParent.SetActive(true); }
|
||||
if (textObj != null) { textObj.text = controllerPreset.items[i].itemText; }
|
||||
}
|
||||
|
||||
if (labelObj != null) { labelObj.text = hotkeyLabel; }
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
LayoutRebuilder.ForceRebuildLayoutImmediate(GetComponent<RectTransform>());
|
||||
if (normalCG != null) { LayoutRebuilder.ForceRebuildLayoutImmediate(normalCG.GetComponent<RectTransform>()); }
|
||||
}
|
||||
#endif
|
||||
|
||||
public void SetLabel(string value)
|
||||
{
|
||||
if (labelObj == null)
|
||||
return;
|
||||
|
||||
labelObj.text = value;
|
||||
|
||||
if (gameObject.activeInHierarchy == true) { StartCoroutine("LayoutFix"); }
|
||||
else
|
||||
{
|
||||
if (normalCG != null) { LayoutRebuilder.ForceRebuildLayoutImmediate(normalCG.GetComponent<RectTransform>()); }
|
||||
LayoutRebuilder.ForceRebuildLayoutImmediate(GetComponent<RectTransform>());
|
||||
LayoutRebuilder.ForceRebuildLayoutImmediate(transform.parent.GetComponent<RectTransform>());
|
||||
}
|
||||
}
|
||||
|
||||
public void OnPointerClick(PointerEventData eventData)
|
||||
{
|
||||
onHotkeyPress.Invoke();
|
||||
|
||||
if (useSounds) { UIManagerAudio.instance.audioSource.PlayOneShot(UIManagerAudio.instance.UIManagerAsset.clickSound); }
|
||||
if (normalCG == null || highlightCG == null || gameObject.activeInHierarchy == false) { return; }
|
||||
|
||||
StopCoroutine("SetHighlight");
|
||||
StartCoroutine("SetNormal");
|
||||
}
|
||||
|
||||
public void OnPointerEnter(PointerEventData eventData)
|
||||
{
|
||||
if (useSounds) { UIManagerAudio.instance.audioSource.PlayOneShot(UIManagerAudio.instance.UIManagerAsset.hoverSound); }
|
||||
if (normalCG == null || highlightCG == null) { return; }
|
||||
|
||||
StopCoroutine("SetNormal");
|
||||
StartCoroutine("SetHighlight");
|
||||
}
|
||||
|
||||
public void OnPointerExit(PointerEventData eventData)
|
||||
{
|
||||
if (normalCG == null || highlightCG == null)
|
||||
return;
|
||||
|
||||
StopCoroutine("SetHighlight");
|
||||
StartCoroutine("SetNormal");
|
||||
}
|
||||
|
||||
IEnumerator LayoutFix()
|
||||
{
|
||||
yield return new WaitForSecondsRealtime(0.025f);
|
||||
if (normalCG != null) { LayoutRebuilder.ForceRebuildLayoutImmediate(normalCG.GetComponent<RectTransform>()); }
|
||||
LayoutRebuilder.ForceRebuildLayoutImmediate(GetComponent<RectTransform>());
|
||||
LayoutRebuilder.ForceRebuildLayoutImmediate(transform.parent.GetComponent<RectTransform>());
|
||||
}
|
||||
|
||||
IEnumerator SetNormal()
|
||||
{
|
||||
while (highlightCG.alpha > 0.01f)
|
||||
{
|
||||
highlightCG.alpha -= Time.unscaledDeltaTime * fadingMultiplier;
|
||||
yield return null;
|
||||
}
|
||||
|
||||
highlightCG.alpha = 0;
|
||||
}
|
||||
|
||||
IEnumerator SetHighlight()
|
||||
{
|
||||
while (highlightCG.alpha < 0.99f)
|
||||
{
|
||||
highlightCG.alpha += Time.unscaledDeltaTime * fadingMultiplier;
|
||||
yield return null;
|
||||
}
|
||||
|
||||
highlightCG.alpha = 1;
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,22 @@
|
||||
fileFormatVersion: 2
|
||||
guid: c9972513674083a4e8366856a6a50999
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences:
|
||||
- controllerIcons: {fileID: 11400000, guid: 6cb65bb6d668729438f86d7c7c1f4522, type: 2}
|
||||
- textPreset: {instanceID: 0}
|
||||
- iconPreset: {fileID: 2393741490227731184, guid: a58adb5252f8b5447ace87508e27b7d3,
|
||||
type: 3}
|
||||
executionOrder: 0
|
||||
icon: {fileID: 2800000, guid: f4007fbdb43231c4c8a13871706d7c46, type: 3}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
AssetOrigin:
|
||||
serializedVersion: 1
|
||||
productId: 264857
|
||||
packageName: Heat - Complete Modern UI
|
||||
packageVersion: 1.0.4
|
||||
assetPath: Assets/Heat - Complete Modern UI/Scripts/Events/HotkeyEvent.cs
|
||||
uploadId: 629893
|
@ -0,0 +1,196 @@
|
||||
#if UNITY_EDITOR
|
||||
using UnityEngine;
|
||||
using UnityEditor;
|
||||
using UnityEditor.SceneManagement;
|
||||
|
||||
namespace Michsky.UI.Heat
|
||||
{
|
||||
[CanEditMultipleObjects]
|
||||
[CustomEditor(typeof(HotkeyEvent))]
|
||||
public class HotkeyEventEditor : Editor
|
||||
{
|
||||
private HotkeyEvent heTarget;
|
||||
private GUISkin customSkin;
|
||||
private int latestTabIndex;
|
||||
private string searchString;
|
||||
Vector2 scrollPosition = Vector2.zero;
|
||||
|
||||
private void OnEnable()
|
||||
{
|
||||
heTarget = (HotkeyEvent)target;
|
||||
|
||||
if (EditorGUIUtility.isProSkin == true) { customSkin = HeatUIEditorHandler.GetDarkEditor(customSkin); }
|
||||
else { customSkin = HeatUIEditorHandler.GetLightEditor(customSkin); }
|
||||
|
||||
if (!Application.isPlaying && heTarget.hotkeyType == HotkeyEvent.HotkeyType.Dynamic) { heTarget.UpdateVisual(); }
|
||||
}
|
||||
|
||||
public override void OnInspectorGUI()
|
||||
{
|
||||
HeatUIEditorHandler.DrawComponentHeader(customSkin, "Hotkey Event Top Header");
|
||||
|
||||
GUIContent[] toolbarTabs = new GUIContent[3];
|
||||
toolbarTabs[0] = new GUIContent("Content");
|
||||
toolbarTabs[1] = new GUIContent("Resources");
|
||||
toolbarTabs[2] = new GUIContent("Settings");
|
||||
|
||||
latestTabIndex = HeatUIEditorHandler.DrawTabs(latestTabIndex, toolbarTabs, customSkin);
|
||||
|
||||
if (GUILayout.Button(new GUIContent("Content", "Content"), customSkin.FindStyle("Tab Content")))
|
||||
latestTabIndex = 0;
|
||||
if (GUILayout.Button(new GUIContent("Resources", "Resources"), customSkin.FindStyle("Tab Resources")))
|
||||
latestTabIndex = 1;
|
||||
if (GUILayout.Button(new GUIContent("Settings", "Settings"), customSkin.FindStyle("Tab Settings")))
|
||||
latestTabIndex = 2;
|
||||
|
||||
GUILayout.EndHorizontal();
|
||||
|
||||
var hotkeyType = serializedObject.FindProperty("hotkeyType");
|
||||
var controllerPreset = serializedObject.FindProperty("controllerPreset");
|
||||
var hotkey = serializedObject.FindProperty("hotkey");
|
||||
var keyID = serializedObject.FindProperty("keyID");
|
||||
var hotkeyLabel = serializedObject.FindProperty("hotkeyLabel");
|
||||
|
||||
var iconParent = serializedObject.FindProperty("iconParent");
|
||||
var textParent = serializedObject.FindProperty("textParent");
|
||||
var iconObj = serializedObject.FindProperty("iconObj");
|
||||
var labelObj = serializedObject.FindProperty("labelObj");
|
||||
var textObj = serializedObject.FindProperty("textObj");
|
||||
var normalCG = serializedObject.FindProperty("normalCG");
|
||||
var highlightCG = serializedObject.FindProperty("highlightCG");
|
||||
|
||||
var useSounds = serializedObject.FindProperty("useSounds");
|
||||
var useLocalization = serializedObject.FindProperty("useLocalization");
|
||||
var fadingMultiplier = serializedObject.FindProperty("fadingMultiplier");
|
||||
|
||||
var onHotkeyPress = serializedObject.FindProperty("onHotkeyPress");
|
||||
|
||||
switch (latestTabIndex)
|
||||
{
|
||||
case 0:
|
||||
HeatUIEditorHandler.DrawHeader(customSkin, "Content Header", 6);
|
||||
|
||||
GUILayout.BeginVertical(EditorStyles.helpBox);
|
||||
HeatUIEditorHandler.DrawPropertyPlainCW(hotkeyType, customSkin, "Hotkey Type", 82);
|
||||
|
||||
if (heTarget.hotkeyType == HotkeyEvent.HotkeyType.Dynamic)
|
||||
{
|
||||
EditorGUILayout.HelpBox("Dynamic: UI will adapt itself to the current controller scheme (if available). Recommended if you want to specify the hotkey in UI.", MessageType.Info);
|
||||
HeatUIEditorHandler.DrawProperty(controllerPreset, customSkin, "Default Preset");
|
||||
if (labelObj.objectReferenceValue != null) { HeatUIEditorHandler.DrawProperty(hotkeyLabel, customSkin, "Hotkey Label"); }
|
||||
|
||||
GUILayout.BeginHorizontal(EditorStyles.helpBox);
|
||||
EditorGUILayout.LabelField(new GUIContent("Key ID"), customSkin.FindStyle("Text"), GUILayout.Width(120));
|
||||
EditorGUILayout.PropertyField(keyID, new GUIContent(""));
|
||||
heTarget.showOutputOnEditor = GUILayout.Toggle(heTarget.showOutputOnEditor, new GUIContent("", "See output"), GUILayout.Width(15), GUILayout.Height(18));
|
||||
GUILayout.EndHorizontal();
|
||||
|
||||
// Search for keys
|
||||
if (heTarget.controllerPreset != null)
|
||||
{
|
||||
GUILayout.BeginVertical(EditorStyles.helpBox);
|
||||
EditorGUILayout.LabelField(new GUIContent("Search for keys in " + heTarget.controllerPreset.name), customSkin.FindStyle("Text"));
|
||||
|
||||
GUILayout.BeginHorizontal();
|
||||
searchString = GUILayout.TextField(searchString, GUI.skin.FindStyle("ToolbarSearchTextField"));
|
||||
if (!string.IsNullOrEmpty(searchString) && GUILayout.Button(new GUIContent("", "Clear search bar"), GUI.skin.FindStyle("ToolbarSearchCancelButton"))) { searchString = ""; GUI.FocusControl(null); }
|
||||
GUILayout.EndHorizontal();
|
||||
|
||||
if (!string.IsNullOrEmpty(searchString))
|
||||
{
|
||||
scrollPosition = GUILayout.BeginScrollView(scrollPosition, false, true, GUIStyle.none, GUI.skin.verticalScrollbar, GUILayout.Height(132));
|
||||
GUILayout.BeginVertical();
|
||||
|
||||
for (int i = 0; i < heTarget.controllerPreset.items.Count; i++)
|
||||
{
|
||||
if (heTarget.controllerPreset.items[i].itemID.ToLower().Contains(searchString.ToLower()))
|
||||
{
|
||||
if (GUILayout.Button(new GUIContent(heTarget.controllerPreset.items[i].itemID), customSkin.button))
|
||||
{
|
||||
heTarget.keyID = heTarget.controllerPreset.items[i].itemID;
|
||||
searchString = "";
|
||||
GUI.FocusControl(null);
|
||||
EditorUtility.SetDirty(heTarget);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
GUILayout.EndVertical();
|
||||
GUILayout.EndScrollView();
|
||||
}
|
||||
|
||||
GUILayout.EndVertical();
|
||||
|
||||
if (heTarget.showOutputOnEditor == true)
|
||||
{
|
||||
GUI.enabled = false;
|
||||
for (int i = 0; i < heTarget.controllerPreset.items.Count; i++)
|
||||
{
|
||||
if (heTarget.controllerPreset.items[i].itemID == heTarget.keyID)
|
||||
{
|
||||
EditorGUILayout.LabelField(new GUIContent("Output for " + heTarget.controllerPreset.items[i].itemID), customSkin.FindStyle("Text"));
|
||||
EditorGUILayout.LabelField(new GUIContent("[Type] " + heTarget.controllerPreset.items[i].itemType.ToString()), customSkin.FindStyle("Text"));
|
||||
if (heTarget.controllerPreset.items[i].itemType == ControllerPreset.ItemType.Text) { EditorGUILayout.LabelField(new GUIContent("[Text] " + heTarget.controllerPreset.items[i].itemText), customSkin.FindStyle("Text")); }
|
||||
else if (heTarget.controllerPreset.items[i].itemIcon != null) { GUILayout.Box(HeatUIEditorHandler.TextureFromSprite(heTarget.controllerPreset.items[i].itemIcon), GUILayout.Width(32), GUILayout.Height(32)); }
|
||||
}
|
||||
}
|
||||
GUI.enabled = true;
|
||||
}
|
||||
}
|
||||
|
||||
if (Application.isPlaying == false && GUILayout.Button(new GUIContent("Update Visual UI"), customSkin.button))
|
||||
{
|
||||
heTarget.UpdateVisual();
|
||||
EditorSceneManager.MarkSceneDirty(EditorSceneManager.GetActiveScene());
|
||||
}
|
||||
}
|
||||
|
||||
else
|
||||
{
|
||||
EditorGUILayout.HelpBox("Custom: You can manually change the content, but UI will not automatically adapt to the current controller scheme. " +
|
||||
"Recommended if you don't need to specify the hotkey in UI.", MessageType.Info);
|
||||
}
|
||||
|
||||
GUILayout.EndVertical();
|
||||
|
||||
HeatUIEditorHandler.DrawHeader(customSkin, "Customization Header", 10);
|
||||
EditorGUILayout.PropertyField(hotkey, new GUIContent("Hotkey"), true);
|
||||
HeatUIEditorHandler.DrawHeader(customSkin, "Events Header", 10);
|
||||
EditorGUILayout.PropertyField(onHotkeyPress, new GUIContent("On Hotkey Press"), true);
|
||||
break;
|
||||
|
||||
case 1:
|
||||
HeatUIEditorHandler.DrawHeader(customSkin, "Core Header", 6);
|
||||
|
||||
if (heTarget.hotkeyType == HotkeyEvent.HotkeyType.Dynamic)
|
||||
{
|
||||
HeatUIEditorHandler.DrawProperty(iconParent, customSkin, "Icon Parent");
|
||||
HeatUIEditorHandler.DrawProperty(textParent, customSkin, "Text Parent");
|
||||
HeatUIEditorHandler.DrawProperty(iconObj, customSkin, "Icon Object");
|
||||
HeatUIEditorHandler.DrawProperty(labelObj, customSkin, "Label Object");
|
||||
HeatUIEditorHandler.DrawProperty(textObj, customSkin, "Text Object");
|
||||
HeatUIEditorHandler.DrawProperty(normalCG, customSkin, "Normal CG");
|
||||
HeatUIEditorHandler.DrawProperty(highlightCG, customSkin, "Highlight CG");
|
||||
}
|
||||
|
||||
else
|
||||
{
|
||||
EditorGUILayout.HelpBox("Hotkey Type is set to Custom.", MessageType.Info);
|
||||
}
|
||||
|
||||
break;
|
||||
|
||||
case 2:
|
||||
HeatUIEditorHandler.DrawHeader(customSkin, "Options Header", 6);
|
||||
useSounds.boolValue = HeatUIEditorHandler.DrawToggle(useSounds.boolValue, customSkin, "Use Sounds");
|
||||
useLocalization.boolValue = HeatUIEditorHandler.DrawToggle(useLocalization.boolValue, customSkin, "Use Localization", "Bypasses localization functions when disabled.");
|
||||
HeatUIEditorHandler.DrawProperty(fadingMultiplier, customSkin, "Fading Multiplier", "Set the animation fade multiplier.");
|
||||
break;
|
||||
}
|
||||
|
||||
serializedObject.ApplyModifiedProperties();
|
||||
if (Application.isPlaying == false) { Repaint(); }
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
@ -0,0 +1,18 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 2cb311946f158964caf1293a25610dbf
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
AssetOrigin:
|
||||
serializedVersion: 1
|
||||
productId: 264857
|
||||
packageName: Heat - Complete Modern UI
|
||||
packageVersion: 1.0.4
|
||||
assetPath: Assets/Heat - Complete Modern UI/Scripts/Events/HotkeyEventEditor.cs
|
||||
uploadId: 629893
|
@ -0,0 +1,22 @@
|
||||
using UnityEngine;
|
||||
using UnityEngine.Events;
|
||||
using UnityEngine.EventSystems;
|
||||
|
||||
namespace Michsky.UI.Heat
|
||||
{
|
||||
public class PointerEvent : MonoBehaviour, IPointerClickHandler, IPointerEnterHandler, IPointerExitHandler
|
||||
{
|
||||
[Header("Settings")]
|
||||
public bool addEventTrigger = true;
|
||||
|
||||
[Header("Events")]
|
||||
[SerializeField] private UnityEvent onClick = new UnityEvent();
|
||||
[SerializeField] private UnityEvent onEnter = new UnityEvent();
|
||||
[SerializeField] private UnityEvent onExit = new UnityEvent();
|
||||
|
||||
void Awake() { if (addEventTrigger == true) { gameObject.AddComponent<EventTrigger>(); } }
|
||||
public void OnPointerClick(PointerEventData eventData) { onClick.Invoke(); }
|
||||
public void OnPointerEnter(PointerEventData eventData) { onEnter.Invoke(); }
|
||||
public void OnPointerExit(PointerEventData eventData) { onExit.Invoke(); }
|
||||
}
|
||||
}
|
@ -0,0 +1,18 @@
|
||||
fileFormatVersion: 2
|
||||
guid: cc0e0c4cc7eed094c9c7fdbe2e06b5b1
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {fileID: 2800000, guid: f4007fbdb43231c4c8a13871706d7c46, type: 3}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
AssetOrigin:
|
||||
serializedVersion: 1
|
||||
productId: 264857
|
||||
packageName: Heat - Complete Modern UI
|
||||
packageVersion: 1.0.4
|
||||
assetPath: Assets/Heat - Complete Modern UI/Scripts/Events/PointerEvent.cs
|
||||
uploadId: 629893
|
Reference in New Issue
Block a user