UI 이벤트 추가
This commit is contained in:
@@ -2,6 +2,11 @@ using UnityEngine;
|
||||
|
||||
public class Define
|
||||
{
|
||||
public enum UIEvent
|
||||
{
|
||||
Click,
|
||||
Drag,
|
||||
}
|
||||
public enum MouseEvent
|
||||
{
|
||||
Press,
|
||||
|
||||
12
Assets/Scripts/Utils/Extension.cs
Normal file
12
Assets/Scripts/Utils/Extension.cs
Normal 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);
|
||||
}
|
||||
}
|
||||
2
Assets/Scripts/Utils/Extension.cs.meta
Normal file
2
Assets/Scripts/Utils/Extension.cs.meta
Normal file
@@ -0,0 +1,2 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 442b91d9fdae87b43b7b0c1c47026c65
|
||||
@@ -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);
|
||||
|
||||
Reference in New Issue
Block a user