[Unity] 짧은 팁 - 사용중인 시스템 메모리 용량 구하기
Unity/C# 2024. 4. 29. 18:13[Unity] 짧은 팁 - 사용중인 시스템 메모리 용량 구하기

public void ShowMemoryStatus() { Debug.Log("Total Reserved memory by Unity: " + ((Profiler.GetTotalReservedMemoryLong() / 1024f) / 1024f) + "MB"); Debug.Log("- Allocated memory by Unity: " + ((Profiler.GetTotalAllocatedMemoryLong() / 1024f) / 1024f) + "MB"); Debug.Log("- Reserved but not allocated: " + ((Profiler.GetTotalUnusedReservedMemoryLong() / 1024f) / 1024f) + "MB"..

[C#] DateTime에서 남은시간 계산하기
Unity/C# 2023. 2. 25. 01:06[C#] DateTime에서 남은시간 계산하기

짧은 기록글 활용 용도 서버에서 받은 문자열 날짜(시간)를 DateTime 구조체로 파싱 현재 날짜(시간)과 비교하여 남은 시간을 계산할때 사용함 Unity식 예시 DateTime dt = DateTime.ParseExact("2023-02-23 16:54:06", "yyyy-MM-dd HH:mm:ss", null); Debug.Log(dt.ToString()); Debug.Log(string.Format("Now: {0}", DateTime.Now.ToString())); TimeSpan ts = dt - DateTime.Now; Debug.Log(string.Format("남은 시간: {0}", ts.ToString())); Debug.Log(string.Format("소숫점 제거: {0}", ts...

[Unity] Builder패턴으로 팝업 시스템 구현
Unity/C# 2023. 2. 16. 14:41[Unity] Builder패턴으로 팝업 시스템 구현

개요 GoF 디자인 패턴중 생성 패턴에 해당하는 Builder패턴을 이용하여 팝업UI 시스템을 구현한 것을 기록한다. GoF디자인 패턴은 아래 블로그에 자세하게 설명해주셨다. [Design Pattern] GoF(Gang of Four) 디자인 패턴 - HERSTORY 디자인 패턴이란 디자인 패턴은 모듈의 세분화된 역할이나 모듈들 간의 인터페이스 구현 방식을 설계할때 참조할 수 있는 전형적인 해결 방식을 말한다. 디자인 패턴을 통해 설계 문제, 해결 방 4z7l.github.io Builder패턴은 동일한 프로세스를 거쳐 다양한 구성의 인스턴스를 만드는 방법이다. 만들어야할 객체가 다른옵션 한두개만 가지고있다면 생성자 혹은 따로 Init()함수를 만들어서 파라미터로 옵션을 넘겨줘도 될것이다. 하지만, 옵..

[Unity] GoogleSheetsToUnity에셋 활용 동적 스크립터블 오브젝트 생성기 제작
Unity/C# 2022. 10. 25. 10:13[Unity] GoogleSheetsToUnity에셋 활용 동적 스크립터블 오브젝트 생성기 제작

개요 구글시트에서 데이터를 불러오는 작업을 하던중 데이터를 불러와서 기존 ScriptableObject에 덮어씌우기만 하지말고 있다면 덮어씌우고 없다면 생성하는 시스템을 만들고싶어졌다. 그래서 작업을 진행했고 해당내용을 기록한다. 사용한 에셋 https://assetstore.unity.com/packages/tools/utilities/google-sheets-to-unity-73410?locale=ko-KR Google Sheets To Unity | 유틸리티 도구 | Unity Asset Store Use the Google Sheets To Unity from Greener Games on your next project. Find this utility tool & more on the Unit..

Unity/C# 2022. 10. 4. 21:05[Unity, C#] 오브젝트 풀링

개요 Unity 프로젝트를 처음 생성할 때 꼭 하는 우선순위들이 있다. 1. DoTween에셋 임포트 2. 오딘 인스펙터 에셋 임포트(유료) 3. 오브젝트 풀링 구현 이 글에서는 오브젝트 풀링 구현을 기록할려고 한다. 오브젝트 풀링은 메모리 최적화를 위해 빼놓을 수 없는 시스템이라고 생각한다. Instantiate와 Destroy를 쓸때마다 괜히 죄책감이들고 그렇기 때문에 항상 구현해놓고 시작하는데 이 기회에 블로그에 적어놓을려고 한다. Pool을 관리하는 PoolManager클래스 먼저 풀을 관리하며 Push와 Pop을 해주는 PoolManager 클래스이다. 딕셔너리와 스택으로 풀을 관리하고 Pop을 할때는 오브젝트나 String키값을 인수로 받아서 오브젝트를 꺼내준다. poolableList에는 풀..

Unity/C# 2022. 10. 1. 17:30[Unity, C#] 박스 콜라이더안에 랜덤포인트 구하기

public static Vector3 GetRandomPointInsideCollider(BoxCollider boxCollider) { Vector3 extents = boxCollider.size / 2f; Vector3 point = new Vector3( Random.Range(-extents.x, extents.x), Random.Range(-extents.y, extents.y), Random.Range(-extents.z, extents.z) ) + boxCollider.center; return boxCollider.transform.TransformPoint(point); } Static클래스의 Static함수로 정의하면 어디서든 사용하기 편하다.

image