Genesis Game Client Project Setup
This commit is contained in:
18
Assets/02_Scripts/Core/GlobalObject.cs
Normal file
18
Assets/02_Scripts/Core/GlobalObject.cs
Normal file
@@ -0,0 +1,18 @@
|
||||
using UnityEngine;
|
||||
|
||||
public class GlobalObject : MonoBehaviour
|
||||
{
|
||||
private static GlobalObject _instance;
|
||||
void Awake()
|
||||
{
|
||||
if (_instance == null)
|
||||
{
|
||||
_instance = this;
|
||||
DontDestroyOnLoad(gameObject);
|
||||
}
|
||||
else
|
||||
{
|
||||
Destroy(gameObject);
|
||||
}
|
||||
}
|
||||
}
|
||||
2
Assets/02_Scripts/Core/GlobalObject.cs.meta
Normal file
2
Assets/02_Scripts/Core/GlobalObject.cs.meta
Normal file
@@ -0,0 +1,2 @@
|
||||
fileFormatVersion: 2
|
||||
guid: ce3ac8a759b61f0418a6d2b35c91d3df
|
||||
8
Assets/02_Scripts/Core/Utility.meta
Normal file
8
Assets/02_Scripts/Core/Utility.meta
Normal file
@@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: ae3853ab09af7874ebd1fe1a5cd44dec
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
34
Assets/02_Scripts/Core/Utility/Util.cs
Normal file
34
Assets/02_Scripts/Core/Utility/Util.cs
Normal file
@@ -0,0 +1,34 @@
|
||||
using System;
|
||||
using System.Threading;
|
||||
using UnityEngine;
|
||||
|
||||
public static class Util
|
||||
{
|
||||
/// 특정 시간(초) 후에 액션을 실행
|
||||
public static async Awaitable RunDelayed(float delay, Action action, CancellationToken token = default)
|
||||
{
|
||||
try
|
||||
{
|
||||
// 유니티 전용 비동기 대기
|
||||
await Awaitable.WaitForSecondsAsync(delay, token);
|
||||
|
||||
// 함수 실행
|
||||
action?.Invoke();
|
||||
}
|
||||
catch (OperationCanceledException)
|
||||
{
|
||||
// 취소되었을 때의 처리 (필요 시)
|
||||
}
|
||||
}
|
||||
|
||||
/// 다음 프레임에 액션을 실행
|
||||
public static async Awaitable RunNextFrame(Action action, CancellationToken token = default)
|
||||
{
|
||||
try
|
||||
{
|
||||
await Awaitable.EndOfFrameAsync(token);
|
||||
action?.Invoke();
|
||||
}
|
||||
catch (OperationCanceledException) { }
|
||||
}
|
||||
}
|
||||
2
Assets/02_Scripts/Core/Utility/Util.cs.meta
Normal file
2
Assets/02_Scripts/Core/Utility/Util.cs.meta
Normal file
@@ -0,0 +1,2 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 85e909089a6a8a74bb6ea540cfad87b1
|
||||
Reference in New Issue
Block a user