[Unity] TransformDirection()
TransformDirection()Transform.TransformDirection은 local space의 `direction`을 world space의 direction으로 변환한다. 해당 연산은 scale이나 position에 영향을 받지는 않는다. 반환된 벡터의 길이는 `direction`과 같다.  그러나 해당 공식 문서의 설명만으로는 헷갈리는 감이 있어, 아래에 첨부한 참고자료를 살펴보고, 직접 사용해보며 내린 결론을 정리해서 다음과 같이 부연 설명을 덧붙인다. `TransformDirection()`함수를 사용할 때는 인자로 넘겨준 direction을 로컬 좌표계로 취급하는데, 이는 TransformDirection()을 호출한 gameobject의 로컬 좌표계를 기준으로 잡는다.Vect..
2024.10.09
no image
[Unity] 3D Project에서 2D Scene 생성
3D Project에서 2D Scene 생성Edit → Project Settings → Editor 탭으로 이동 → Default Behaviour Mode 설정을 2D로 변경 Basic 2D (Built-in)을 선택하여 2D Scene 생성 (또는 Project 탭에서 우클릭을 통해 Scene 생성을 하면 자동으로 2D Scene이 생성된다)      참고자료- 티스토리 블로그
2024.08.14
no image
[Unity] Time 클래스의 프로퍼티들
Time.time Time.time은 프로젝트 재생이 시작된 이후의 시간을 반환한다. Time.deltaTime delta는 값의 차이를 뜻하는데, 현재 프레임의 시작시간과 이전 프레임의 시작시간과의 차이이다. 이는 지난 프레임이 완료되는 데까지 걸린 시간 차이를 의미하는 것과 동일한 의미이다. 즉, 한 프레임을 진행하는데 걸린 시간을 뜻한다. ※ FixedUpdate에서 Time.deltaTime이 호출되면, Time.fixedDeltaTime을 반환하게 된다. 30 프레임, 60 프레임에서의 deltaTime 보통 30프레임 기준에서는 Time.deltaTIme이 0.033초 정도가 나오고, 60프레임 기준의 게임에서는 0.016초정도가 나온다. 이동관련 코드에서 deltaTime을 사용하지 않을 경..
2022.01.28
no image
[Unity] 유니티 디버깅 하는 방법 (Visual Studio)
1. 유니티 스크립트 에디터 설정 1. Edit -> Preference -> External Script Editor로 들어가서 Visual Studio를 스크립트 에디터로 설정. 위 과정을 거치면 유니티와 Visual Stduio의 연결이 됩니다. 위 처럼 Unity에 연결이 뜨면, 유니티와 Visual Studio의 연결이 제대로 된 것입니다. 2. 디버깅 하기 전 설정 1. Visual Studio에서 Break Point를 설정해줍니다. 왼쪽 이미지처럼 초록색 영역 부분을 클릭하면 오른쪽 이미지 처럼 "빨간색 점"이 찍히는 것을 확인할 수 있습니다. 이것을 브레이크 포인트(중단점)이라고 합니다. 보통 문제가 있는 부분이라고 생각되는 라인, 동작 결과가 어떻게 되는지 보고 싶은 라인을 중단점으로 ..
2021.09.04
no image
[Unity, C#] 모바일 UI 터치방지
문제 해결링크 https://answers.unity.com/questions/1115464/ispointerovergameobject-not-working-with-touch-inp.html IsPointerOverGameObject not working with touch input - Unity Answers answers.unity.com 사용한 코드 private bool IsPointerOverUIObject() { PointerEventData eventDataCurrentPosition = new PointerEventData(EventSystem.current); eventDataCurrentPosition.position = new Vector2(Input.mousePosition.x,..
2021.06.02
[Unity] GameObject 코드에서 생성
Unity - Scripting API: GameObject.GameObject Transform is always added to the GameObject that is being created. The creation of a GameObject with no script arguments will add the Transform but nothing else. Similarly, the version with just a single string argument just adds this and the Transform. Fi docs.unity3d.com GameObject 생성자 public GameObject(); public GameObject(string name); public Game..
2021.04.18
no image
[Unity] 비활성화 된 GameObject찾기
문제점 GameObject가 비활성화 상태였는데. Find함수로 찾으려니 안찾아졌다. 해결방법 비활성화 된 객체를 활성화시키려면, 활성화된 부모를 찾아서 자식을 찾는 형식으로 접근해야 합니다. 참고로, 비활성화 된 게임오브젝트에 부모가 없는 경우라면 활성화된 빈 오브젝트를 만들고 비활성화된 오브젝트를 빈 오브젝트의 자식으로 만들면 문제를 해결할 수 있습니다. (당연한 말이지만, 스크립트 컴포넌트가 활성화되어 있는 곳에서 호출해야 한다. 즉, Cube 게임오브젝트에 스크립트 컴포넌트를 넣어놓고 Cube를 SetActive를 통해 비활성화시킨뒤, 다시 켜도록하면 당연히 켜지지 않는다. Cube게임오브젝트의 스크립트 컴포넌트까지 같이 꺼져버리기 때문.) 씬에는 Plane, CubeParent그리고 CubePa..
2021.04.05
[Unity] Mathf.Lefp / 유니티 Lerp에 대하여
Lerp함수에 대하여 [Unity] 유니티 3D Vector의 선형보간 Lerp 정확한 사용법[Unity] 유니티 3D Vector의 선형보간 Lerp  오늘은 유니티에서 굉장히 많이 이용되는 선형 보간 함수를 소개하겠습니다, 우선 선형보간이란 이런 것입니다. 선형 보간법 위키백과, 우리 모두의 백과iygames.tistory.com [C#] Mathf.Lerp 쉽게 이해하기유니티에서 Lerp는 대부분 선형 보간을 사용하여 부드러운 움직임을 표현하기 위해 Update에 넣어 사용하...blog.naver.com위 링크의 블로그를 보면 Lerp(선형보간)에 대해 자세한 설명이 적혀있습니다.위 블로그링크에서는 Vector3.Lerp()함수를 기준으로 설명하고 있습니다. 선형보간이란 a, b값이 주어졌을 때 ..
2021.03.24
[Unity] Object.Instantiate 함수 (자동 world space좌표로 변환)
Unity - Scripting API: Object.InstantiateThis function makes a copy of an object in a similar way to the Duplicate command in the editor. If you are cloning a GameObject you can specify its position and rotation (these default to the original GameObject's position and rotation otherwise). If youdocs.unity3d.comwergia.tistory.com/213위 링크에서 스크린 좌표와 월드 좌표에 관한 설명을 보던 중 마우스 위치 좌표가 월드 공간의 좌표로 변환된다는 내용..
2021.03.21
no image
[Unity] SetActive와 enabled
Unity - Scripting API: GameObject.SetActive A GameObject may be inactive because a parent is not active. In that case, calling SetActive will not activate it, but only set the local state of the GameObject, which you can check using GameObject.activeSelf. Unity can then use this state when all paren docs.unity3d.com Unity - Scripting API: Behaviour.enabled Success! Thank you for helping us impro..
2021.03.05
no image
[Unity] RequireComponent란?
Unity - Scripting API: RequireComponent When you add a script which uses RequireComponent to a GameObject, the required component will automatically be added to the GameObject. This is useful to avoid setup errors. For example a script might require that a Rigidbody is always added to the same G docs.unity3d.com RequireComponent RequireComponent속성은 요구되는 컴포넌트를 종속성으로 자동으로 추가해줍니다. RequireComponent를..
2021.03.05
[Unity] 공식 Documentation 읽을 때 주의점
docs.unity3d.com/kr/530/Manual/script-Serialization.html(구 버전 스크립트 직렬화에 대한 한글 문서)docs.unity3d.com/Manual/script-Serialization.html(신 버전 스크립트 직렬화에 대한 한글 문서) 스크립트 직렬화에 대해 글을 읽고 싶었는데, 영문서랑 비교해보던 중 내용이 달라서 확인해보니 유니티 버전이 서로 달랐다. 당연한 결과긴 하지만, 구버전 영문서를 찾아보았더니 구 버전 한글 문서랑 내용이 똑같았다. 즉, 한글 문서로 된 것은 유니티 버전을 확인해보고 웬만하면 신버전으로 가서 문서를 읽자.
2021.03.05