본문 바로가기

개발24

클래스 전방선언 큰 규모의 프로젝트를 진행할 때 헤더파일들이 많아 지다보면 헤더파일간의 중복 참조로 인해 머리아픈일들이 발생할 때가 있다. 중복참조가 아니더라도 불필요한 헤더참조로 컴파일 속도가 저해 될 수 있다.이 때문에 헤더파일에는 가상의 클래스를 전방선언을 해두고 cpp파일에서 헤더참조를 한다. 사용예 - 헤더파일 코드class A; //전방선언 class B{private: A* m_a; } 2015. 9. 30.
RequireComponent 속성 RequireComponent 속성이 포함된 스크립트가 오브젝트의 컴포넌트로 추가될 때 RequireComponent에 선언된 컴퓨넌트가 자동으로 붙게되며 이 때 추가된 컴포넌트는 강제로 삭제할 수가 없다.Ex)[RequireComponent (typeof(Rigidbody2D))]public class Bullet : MonoBehaviour{} -> Bullet 스크립트를 어떠한 GameObject에 컴포넌트로 추가할 시 Rigidbody2D 컴포넌트가 해당 오브젝트에 자동으로 추가된다. 2015. 9. 14.
유니티에서 2D Picking 구현하기 유니티 5.0 버전에서는 2D 상의 Picking에서는 Physics.Raycast가 아닌 Physics2D.Raycast를 사용한다.또 이런 Picking을 하기위해서는 2D오브젝트가 2D Collider를 가지고 있어야 한다. if(Input.GetMouseButtonDown(0)){Vector2 pos = Camera.main.ScreenToWorldPoint(Input.mousePosition);//화면의 좌표계를 월드 좌표계로 전환해주는 함수(ex. 100 x 100 해상도의 경우 가운데 좌표가 스크린좌표로 나타내면 50,50 이지만 월드좌표는 0,0 이다.)RaycastHit2D hit = Physics2D.Raycast(pos, Vector2.zero);if(hit.collider != nu.. 2015. 9. 13.
알고스팟-URIDecoding 문제 출처 - Algospot ICPC Seoul Regional Warmup 2008- 문제URI (Uniform Resource Identifier) is a compact string used to identify or name resources on the Internet. Some examples of URI are below:http://icpc.baylor.edu.cn/mailto:foo@bar.orgftp://127.0.0.1/pub/linuxreadme.txtWhen transmitting *URI*s through the Internet, we escape some special characters in *URI*s with percent-encoding. Percent-encoding.. 2015. 7. 23.