본문 바로가기
반응형

유니티 공부/Unity100

Unity - 게임 에셋 사이트들 추천! https://itch.io/game-assets/tag-2d Top game assets tagged 2D Find game assets tagged 2D like Sprout Lands - Asset Pack, Modern exteriors - RPG Tileset [16X16], Modern interiors - RPG Tileset [16X16], Mystic Woods - 16x16 Pixel Art Asset Pack, Free Pixel Art Character Base - A "Mana Seed" Sprite Sheet on itch.io, the itch.io https://craftpix.net/freebies/ https://www.gamedevmarket.net/category/2d.. 2023. 3. 8.
Unity - Bind event, Extension Method 1. Bind에 Gameobject도 추가하기 01 enum 추가 enum GameObjects { TestObject, } GameObject type의 Bind도 받고 싶다고 추가 Bind(typeof(GameObjects)); 02 T의 타입이 GameObject인지 확인 if(typeof(T) == typeof(GameObject)) objects[i] = Util.FindChild(gameObject, names[i], true); else objects[i] = Util.FindChild(gameObject, names[i], true); if (objects[i] == null) Debug.Log($"Faild to bind!{names[i]}"); 03 GameObject반환 우리가 이전에.. 2023. 2. 22.
Unity - UI 자동화(Bind, Get) Bind 1. enum 이름들을 enum값으로 설정 enum Buttons { PointButton, } enum Texts { PoinText, scoreText, } enum값 넘겨주는 방법은 Reflection을 이용하면 된다. 2. Reflection 이용해서 enum 넘기기 Reflection은 객체를 X-Ray 기능을 가지고 있다. 이를 통해 형식, 메소드 프로퍼티, 필드, 이벤트등의 정보를 확인할 수 있다. Relfection 더 자세히 알아보러 가기 C# 문법 - Reflection, Attribute 1. Reflection class의 모든 필드의 정보를 가져오는 X-ray와 같은 기능을 가지고 있다. C#에서 모든 객체들은 오브젝트 객체에서 파생되어 나온 것이다. Pig클래스에서 없는.. 2023. 2. 21.
Unity - 플레이어가 이동할때 카메라가 플레이어 쳐다보게 하기 1. 카메라가 플레이어 쳐다보게 하기 01 Define.cs에 CamerMode 설정 public class Define { public enum CameraMode { QuaterView, } } 02 변수 설정 [SerializeField] Define.CameraMode _mode = Define.CameraMode.QuaterView; [SerializeField] Vector3 _delta = new Vector3(0.0f, 6.0f, -5.0f); [SerializeField] GameObject _player = null; _delta : 카메라의 위치를 플레이어 위치에서 얼마나 떨어져 배치할지 03 QuaterView setting public void SetQuaterView(Vector.. 2023. 2. 21.
Unity - Raycast, 좌표계, LayerMask, Tag 광선을 쏴서 충돌 되는 물체가 있는지 없는지를 검사 Raycast와 관련있는 함수들 1. Draw ray public static void DrawRay(Vector3 start, Vector3 dir, Color color = Color.white, float duration = 0.0f, bool depthTest = true); 파라미터 start : ray 시작 지점 dir : ray 방향 color : ray 색깔 duration : ray 길이 반환 Draws a line from start to start _ dir in world coordinates ex) Debug.DrawRay(transform.position, Vector3.forward, Color.red); ex) Debug(t.. 2023. 2. 19.
Unity - UI 기초, UI Rect Transform, Anchor Presets 설명 1. UI 기초 먼저 UI탭에서 버튼을 만들어보자 그러면 자동으로 Canvas와 EventSystem이 생긴걸 확인할 수 있다 01 Canvas 그림을 그릴 도화지로 인식하면 된다. 실제로 UI요소가 배치되는 영역이다. 02 EventSystem 사용자 입력 및 이벤트 처리를 관리한다. 이는 이벤트를 감지하고 해당 이벤트에 대한 콜백함수를 호출한다. 그러므로 Button을 사용하고 싶은데 EventSystem이 없는 경우 사용되어지지 않는다. 2. UI Rect Transform UI요소의 크기, 위치, 회전 및 확대/축소를 조절하는데 사용된다. 이는 모든 UI요소에 자동으로 추가되며 보통 UI를 조작할때는 RECT Transform을 이용한다. 01 Position Anchor를 기준으로 한 사각형의 .. 2023. 2. 15.
반응형