1. Change the 02.Main_TG2 scene for testing

2. Add DebugType used for Utils.GetComponentAndAssert()
This commit is contained in:
NTG_Lenovo 2023-08-08 14:33:49 +09:00
parent ea03670618
commit f6d858dfec
2 changed files with 77 additions and 20097 deletions

File diff suppressed because it is too large Load Diff

View File

@ -1,13 +1,26 @@
using System;
using System.Diagnostics;
using UnityEngine;
using UnityEngine.AI;
using UnityEngine.Assertions;
using Debug = UnityEngine.Debug;
using Random = UnityEngine.Random;
// ReSharper disable once CheckNamespace
namespace BlueWaterProject
{
public class Utils
{
public enum DebugType
{
NONE,
LOG,
WARNING,
ERROR,
DEBUG_ASSERT,
ASSERT //
}
/// <summary>
/// 각도를 통해 방향값을 반환하는 함수
/// </summary>
@ -25,10 +38,33 @@ namespace BlueWaterProject
// return newBehaviorTask;
// }
public static T GetComponentAndAssert<T>(Transform componentLocation) where T : class
public static T GetComponentAndAssert<T>(Transform componentLocation, DebugType debugType = DebugType.DEBUG_ASSERT) where T : class
{
var newComponent = componentLocation.GetComponent<T>();
Assert.IsNotNull(newComponent, typeof(T) + "타입의 Component가 존재하지 않습니다.");
switch (debugType)
{
case DebugType.NONE:
Debug.Log("DebugType is None.");
break;
case DebugType.LOG:
Debug.Log(typeof(T) + "타입의 Component가 존재하지 않습니다.");
break;
case DebugType.WARNING:
Debug.LogWarning(typeof(T) + "타입의 Component가 존재하지 않습니다.");
break;
case DebugType.ERROR:
Debug.LogError(typeof(T) + "타입의 Component가 존재하지 않습니다.");
break;
case DebugType.DEBUG_ASSERT:
Debug.Assert(newComponent != null, typeof(T) + "타입의 Component가 존재하지 않습니다.");
break;
case DebugType.ASSERT:
Assert.IsNotNull(newComponent, typeof(T) + "타입의 Component가 존재하지 않습니다.");
break;
default:
throw new ArgumentOutOfRangeException(nameof(debugType), debugType, null);
}
return newComponent;
}