UI 이벤트 추가

This commit is contained in:
2026-01-25 23:45:33 +09:00
parent 8b013830a0
commit 698300d465
7 changed files with 61 additions and 11 deletions

View File

@@ -2,6 +2,11 @@ using UnityEngine;
public class Define
{
public enum UIEvent
{
Click,
Drag,
}
public enum MouseEvent
{
Press,

View File

@@ -0,0 +1,12 @@
using System;
using UnityEngine;
using UnityEngine.EventSystems;
public static class Extension
{
public static void AddUIEvent(this GameObject go, Action<PointerEventData> action,
Define.UIEvent type = Define.UIEvent.Click)
{
UI_Base.AddUIEvent(go, action, type);
}
}

View File

@@ -0,0 +1,2 @@
fileFormatVersion: 2
guid: 442b91d9fdae87b43b7b0c1c47026c65

View File

@@ -2,6 +2,17 @@ using UnityEngine;
public class Util
{
public static T GetOrAddComponent<T>(GameObject go) where T : UnityEngine.Component
{
T component = go.GetComponent<T>();
if (component == null)
{
component = go.AddComponent<T>();
}
return component;
}
public static GameObject FindChild(GameObject go, string name = null, bool recursive = false)
{
Transform transform = FindChild<Transform>(go, name, recursive);