본문 바로가기
반응형

개발/Unity336

Unity)Import Activity Window (Asset Import 정보) Import Activity Window Unity Version 2021.2.0a1 이상에서 지원하는 기능으로 자산 데이터베이스에서 가져오는데 얼마나 걸렸는지 알수있는 기능이 공식적으로 추가되었다. [Assets]-[View in import Activity Window] 해당 Import Activtiy에서는 임포트하는 과정에서 걸린 시관과 해당 정보를 알수있다. 에셋에 대한 설명은 다음과 같다. 속성 설명 Asset 현재 선택한 에셋의 이름입니다. 이 필드를 클릭하여 프로젝트 창에서 에셋을 찾을 수 있습니다. GUID 에셋에 할당된 고유 GUID입니다. 이를 사용하여 프로젝트 전체에서 레퍼런스를 추적할 수 있습니다. Asset Size 에셋의 소스 파일 크기입니다. Path 프로젝트의 루트 폴더를 .. 2022. 11. 7.
Unity) ScriptableObject Extended(스크립터블 오브젝트 확장) ScriptableObject Extended(스크립터블 오브젝트 확장) Scriptable Object 를 확장해서 Inspector에 노출되는 Eidtor Code이다. 하위 항목이 존재하면 Folder 형태로 표시가되고 편리하다. // Developed by Tom Kail at Inkle // Released under the MIT Licence as held at https://opensource.org/licenses/MIT // Must be placed within a folder named "Editor" using System; using System.Reflection; using System.Collections; using System.Collections.Generic; usi.. 2022. 11. 3.
문제해결)Unity)ReadPixels was called to read pixels from system frame buffer, while not inside drawing frame. ReadPixels was called to read pixels from system frame buffer, while not inside drawing frame. UnityEngine.Texture2D:ReadPixels (UnityEngine.Rect,int,int) 를 사용하는 과정에서 발생한 이슈이다. 텍스쳐를 생성하고 ReadPixels을 하는 과정에서 발생한 오류로 모두 다 그려지고 난 이후에 ReadPixels을 해줘야하는데 그렇지 않은 경우이다. 이 과정을 방지하기 위해서는 ReadPixels를 하기전에 WaitForEndOfFrame을 호출해주면 된다. public IEnumerator TakeSnapShotAndSave() { ... yield return new WaitForEn.. 2022. 11. 2.
Unity) 특정 영역 스크린샷 (RectTransform ScreenShot) 특정 영역 스크린샷 (RectTransform ScreenShot) 특정 영역에 대해서 스크린샷(Screen Shot)을 찍는 코드이다. Image를 기반으로 해당 영역을 기준으로 해상도와 사이즈를 계산한다. using System.Collections; using System.Collections.Generic; using UnityEngine; using UnityEngine.UI; public class CanvasInImagePosition : MonoBehaviour { [SerializeField] private Canvas Canvs = default; [SerializeField] private CanvasScaler scaler = default; [SerializeField] priva.. 2022. 11. 1.
Unity)GUILable(OutLine : 외곽선추가) GUILable(OutLine : 외곽선추가) GUI를 표현하는 과정에서 단색으로 처리 하면 잘 보이지 않아서Style을 추가해서 OutLine (Stroke)처리하는 코드이다.#if UNITY_EDITORprivate GUIStyle customStyle = null; void Initalize(){ if(customStyle == null) { customStyle= new GUIStyle(GUI.skin.box); customStyle.normal.textColor = Color.white; customStyle.fontSize=11; }}void OnDrawGizmos(){ Handles.BeginGUI(); .. 2022. 11. 1.
Unity)Tile Animation 적용하기 (Animated Tile) Tile Animation 적용하기 (Animated Tile) Unity Tile 도 Animation을 지원한다. Unity Package (UPM)으로 '2D Tilemap Extras' Package를 Import 한다. Import하고 난 이후에는 Animated Tile 생성이 가능하다. 생성한 Animated Tile 에 Sprite 를 여러개 넣고 셋팅한다. 속성 내용 Minimum Speed 타일의 애니메이션이 가능한 최소 속도 (초) Maximum Speed 타일의 재생이 가능한 최고 속도(초) Start Time 시작 애니메이션 타일 Start Frame 이 애니메이션 타일의 시작 프레임 Collider Type .. 2022. 10. 28.
Unity) Android Log Cat 사용방법 Unity 에서도 Android Log Cat 사용이 가능하다. 기존에서는 Android Studio를 실행해서 사용했었는데 Unity 2019.1+ 부터 사용 가능하게 PackageManager에 포함되어서 편하게 사용이 가능하다. PakageManager에서 Android Logcat을 설치한다. [Window]-[Analysis] -[Android Logcat] Android LogCat 확인할수있는 화면이 나온다 기본적으로 Device를 연동해야한다. (여기서부터는 Android Sutdio와 동일하다) 디바이스 연결방법은 동일하게 2가지를 지원한다. USB Debugging / Remote Debugging Filter 사용하는방법은 여러가지가 존재하는데 가장 많이사용.. 2022. 10. 25.
Unity) 사운드 Pause / UnPause 사운드 Pause / UnPause Unity 2017.1 Version 이후부터는 AudioSource.Pause라는 기능과 UnPause라는 기능이 추가되었다. 그 전에는 직접 구현했었어야하는데. 편리해졌다. 기존에는 Pause라는 순간에 해당 Audio 의 time을 저장하고 멈추고 난 이후에 UnPause 시점에서 Audio time을 셋팅해주고 Play를 시켰었다. 지금은 단순하게 Pause / UnPause를 호출해주기만 하면 된다. public void PauseSound(AudioSource _audioSource) { _audioSource.Pause(); } public void UnPauseSound(AudioSource _audioSource) { _audioSource.UnPaus.. 2022. 10. 24.
Unity)Android) 설치된 Android SDK 확인 방법 설치된 Android SDK 확인 방법 Unity 의 External Tools의 Recommended (추천)으로 설정된 경우에는 해당 Unity Hub의 하위 폴더에 SDK 가 설치되어있는걸 사용한다. 그 과정에서 현재 Unity에서 사용하고있는 SDK의 실제 버전을 확인하는 방법이다. Android SDK의 Path를 Copy 해서 폴더로 이동한다. 해당 경로에서 tools/bin로 들어가서 해당 명령어를 실행한다. sdkmanager --list 해당 경로의 패키지 정보가 나온다. 추가로 sdkmanager 명령어는 대략 다음과 같다. 명령어 내용 sdkmanager --list [options] [--channel=channel_id] // Channels: 0 (stable), 1 (beta).. 2022. 10. 24.
Unity) UPM(Unity Pacakage Manager)특정 버전 선택하기(Git Dependencies) UPM(Unity Pacakage Manager) 특정 버전 선택하기(Git Dependencies) UPM(Unity Package Manager)를 사용하는 과정에서 특정 패키지 버전을 사용해야하는 상황이 생길때(항상 최신이 아닌경우) Version 또는 Branch, Commit Hash를 고정할수 있다. 혹은 파일경로도 가능하다. 방법은 다음과 같다. 사용방법 예시 (기본주소 : https://github.example.com/myuser/myrepository.git) 가장 최근 버전 "https://github.example.com/myuser/myrepository.git" 특별한 브런치 "https://github.example.com/myuser/myrepository.git#my-bra.. 2022. 10. 23.
Unity) Texture Format (플랫폼 별 효율적인 텍스처 압축 포맷) Texture Format (플랫폼 별 효율적인 텍스처 압축 포맷) Unity 문서에보면 플랫폼별 기본 텍스쳐 압축 포맷이 존재한다. 사용하는 플랫폼에 따라서 압축 포맷을 설정해주면 좀더 효율적인 리소스 관리가 가능하다. 내부에서는 텍스처의 압축에 진행되는 프로세스는 다음과 같다. Image -> import -> Unity -> .png 복원 -> 알고리즘 압축 (PVRTC, ETC, ASTC) -> Compfile Build -> .apk or .ipa => GPU 압축풀어서 메모리 전송 => 화면 보여짐 모바일을 개발하면서 가장 많이 접하는 텍스처 압축 포맷은 다음과 같다. 적용하기전에 꼭 서비스하는 기기 목록에서 확인하고 진행하는것을 추천드린다. 형식 설명 RGBA 무압축 방식 RGBA ETC1 .. 2022. 10. 20.
문제해결)Unity)Some objects were not cleaned up when closing the scene. (Did you spawn new GameObjects from OnDestroy?)The following scene GameObjects were found:~ Some objects were not cleaned up when closing the scene. (Did you spawn new GameObjects from OnDestroy?)The following scene GameObjects were found:~ Singleton Class가 OnDestory에서 호출되면서 에러를 발생하는 상황으로 종료와 동시에 생성을하는 상황인데 디버깅으로 호출스택을 보면 좀더 수월하게 파악이 가능하다. 스크립트 LifeCylce의 OnDestory 상황이나 OnApplicationQuit에서 Flag 값을 셋팅하고 Instance getter에서 return 처리를 진행하면 된다. private static object _lock = new object(); pr.. 2022. 10. 13.
Unity)NDK Version 확인방법 Unity 에서 NDK Version 확인방법 NDK 버전을 업데이트 해야하는 상황이 생겨서 현재 버전을 확인하는것을 알게되어서 포스팅하게 되었다. [Edit]-[Preferences]-[External Tools] 의 NDK을 사용중이다. Copy Path 해서 해당 폴더로 이동한다. 해당 폴더의 스크린샷의 경로에 가면 source.properties 라는 폴더가 있는데 해당 파일이 Version정보를 가지고 있다. Unity 버전마다 NDK 버전이 정해져있는데 공식 Unity Documentation을 참조하면 된다. Unity Android 환경설정 : [링크] ★☆☆☆☆ 2022. 10. 12.
Unity) URL 이미지 다운 및 관리 코드 URL 이미지 다운 및 관리 코드 URL을 기준으로 Texture를 읽고 저장하는 코드이다. UnityWebRequestTexture를 사용해서 URL의 이미지를 Texture로 변환시킨다. using System.Collections.Generic; using UnityEngine; using System.Threading.Tasks; using UnityEngine.Networking; using System.IO; /// /// URL에서 이미지를 읽고 저장 처리하는 코드 /// public class TextureLoaderformURL { private static Dictionary _textureCahce = new Dictionary(); private static Dictionary Te.. 2022. 10. 5.
문제해결)Unity)UnityException: ~ can only be called from the main thread.Constructors and field initializers will be executed from the loading thread when loading a scene.Don't use this function in the constructor or field initializers, inst.. ~ can only be called from the main thread.Constructors and field initializers will be executed from the loading thread when loading a scene.Don't use this function in the constructor or field initializers, inst.. 해당이슈는 Unity에서 Main Thread가 아닌곳에서 UnityEngine의 기능을 호출할때 발생하는 이슈이다. 여러상황에서 발생이 가능한데. 외부 라이브러리 Unity 사이에서 발생하는 경우가 종종있다. Unity 에서 Main Thread를 보장하는곳에서 호출하려면 간단하게 Mono Update에서 호출하거나 Coroti.. 2022. 10. 3.
반응형