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, C#] 스크립트 작성 규칙 / naming convention
Why do C# developers newline opening brackets? I've spent most of the last several years working mainly with C# and SQL. Every programmer I've worked with over that time was in the habit of placing the opening brace of a function or control flow softwareengineering.stackexchange.com C# 개발자들의 중괄호 style에 관한 글입니다. 재밌으니 읽어보시는 것도.. 위 링크의 글에 따르면 예전 C가 개발되었을 때 컴퓨터 디스플레이의 상태는 지금의 디스플레이보다 작은 상태이기에, 수직 공간..
2021.03.31
[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.Instantiate This 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 you docs.unity3d.com wergia.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