Unity3D(59)
-
프리팹을 동적 생성 하고 싶을 때
프리팹을 동적 생성, 할당한다. 근데 동적 생성된 게임오브젝트에는 컴포넌트 미부착 상태이므로 addComponent를 해주어야 하고, 클래스 컴포넌트를 부착한 다음에도 그 클래스의 멤버를 모두 init해주어야 한다. 추가로 프리팹을 생성하기 전, 딕셔너리나 배열 같은 자료구조 멤버 변수에서 받은 데이터를 토대로 프리팹을 생성 및 초기화하는 것도 좋다.
2022.01.19 -
씬을 비동기로 Load하고 싶을 때
https://docs.unity3d.com/ScriptReference/SceneManagement.SceneManager.LoadSceneAsync.html Unity - Scripting API: SceneManagement.SceneManager.LoadSceneAsync You can provide the full Scene path, the path shown in the Build Settings window, or just the Scene name. If you only provide the Scene name, Unity loads the first Scene in the list that matches. If you have multiple Scenes with the same nam..
2022.01.19 -
public 이지만 인스펙터에서 감추고 싶을 때
키워드 HideInInspector
2022.01.19 -
구조체를 쓸 때
struct 구조체는 그 구조체 안의 모든 속성에 값을 채워야만 사용할 수 있다.
2022.01.19 -
22.01.18 Cat Escape 피하기 게임 만들기
실행 결과 소스코드------------------------------------------------------------------------------------------ using System.Collections; using System.Collections.Generic; using UnityEngine; public class PlayerController : MonoBehaviour { private float xRange; private float yPos; public float hp; private bool moveLeft = false; private bool moveRight = false; void Start() { yPos = -3.5f; xRange = 8.5f; hp =..
2022.01.18 -
UI 버튼을 누른 상태를 유지하고 싶을 때
https://daru-daru.tistory.com/55 [Unity 3D] 이벤트 트리거 (Event Trigger) 유니티에서는 이벤트 트리거라고 하는 이벤트 딜리게이트를 제공한다. 유니티에서 아무 UI를 생성하게 되면 이벤트 시스템이 생성된다. 이벤트 시스템은 Canvas 내에 있는 이미지들에 대한 Del daru-daru.tistory.com event trigger를 이용하는 방법으로, bool함수를 만들어서 pressed, unPressed를 구분하는 것이다.
2022.01.18