Unity/Unity(C#์ค‘๊ธ‰)

ํ™•์žฅ๋ฉ”์†Œ๋“œ

Rainbow๐ŸŒˆCoder 2022. 1. 13. 14:39
728x90
using System;
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.EventSystems;

//ํ™•์žฅ ๋ฉ”์†Œ๋“œ : ๊ธฐ์กด ํด๋ž˜์Šค ๋ฐ ๋‹ค๋ฅธ ํด๋ž˜์Šค์— ์ธ์Šคํ„ด์Šค ๋ฉ”์†Œ๋“œ๋ฅผ ์ถ”๊ฐ€ํ•  ์ˆ˜ ์žˆ์–ด, ๊ธฐ๋Šฅ์„ ํ™•์žฅํ•˜๋Š” ๊ธฐ๋ฒ•
//์กฐ๊ฑด 1 : static ํด๋ž˜์Šค์—ฌ์•ผ ํ•  ๊ฒƒ(MonoBehaviour๋Š” ํ•„์š”์—†์œผ๋ฏ€๋กœ ์ƒ์† ์ œ๊ฑฐ)
public static class Extension
{
    //์ฒซ๋ฒˆ์งธ ๋งค๊ฐœ ๋ณ€์ˆ˜ : ํ™•์žฅํ•˜๋ ค๊ณ  ํ•˜๋Š” ๋Œ€์ƒ
    //this ํ™•์žฅํ•  ํด๋ž˜์Šค ๋˜๋Š” ํ˜•์‹
    public static void AddUIEvent(this GameObject go, Action<PointerEventData> action, Define.UIEvent type = Define.UIEvent.Click)
    {
        UIBase.AddUIEvent(go,action, type);
    }

    public static void PrintData<T>(this T str) 
    {
        Debug.Log(str);
    }
}
728x90