블로그 이미지
Every unexpected event is a path to learning for you.

카테고리

분류 전체보기 (2737)
Unity3D (817)
Programming (474)
Server (33)
Unreal (4)
Gamebryo (56)
Tip & Tech (228)
협업 (58)
3DS Max (3)
Game (12)
Utility (136)
Etc (96)
Link (32)
Portfolio (19)
Subject (90)
iOS,OSX (53)
Android (14)
Linux (5)
잉여 프로젝트 (2)
게임이야기 (3)
Memories (20)
Interest (38)
Thinking (38)
한글 (30)
PaperCraft (5)
Animation (408)
Wallpaper (2)
재테크 (18)
Exercise (3)
나만의 맛집 (3)
냥이 (10)
육아 (16)
Total
Today
Yesterday
04-24 00:01

'프러스텀'에 해당되는 글 1건

  1. 2012.10.15 Gizmos로 카메라 프러스텀 보이게 하기

나(me)같은 초보를 위해 사용법(?) 추가..;


1. C# 스크립트 생성.

2. 생성한 스크립트에 아래 소스 추가/저장.

3. 생성한 스크립트를 Main Camera에 드래그&드랍..

4. Scene창의 Gizmos에 보면 추가한 스크립트가 추가된 게 보이고, 토글이 가능하다.

------------------------------------------------------------------------------------------

NGUI(무료버전) 레이아웃 작업 중....


현재 화면에서 GUI배치하기가 너무 어려워서 현재 화면 크기를 카메라를 선택하지 않아도 계속 유지하고 싶었다.


역시나 나 같은 생각을 가진 사람이 있었다. 아래 링크를 참고하자.

http://answers.unity3d.com/questions/291467/scene-view-stretches-camera-frustum-gizmo.html


링크를 가고 싶지 않은 사람은 아래 코드를 가져다가 쓰면 된다.


    public static Vector2 GetMainGameViewSize()

{ System.Type T = System.Type.GetType("UnityEditor.GameView,UnityEditor"); System.Reflection.MethodInfo GetSizeOfMainGameView = T.GetMethod("GetSizeOfMainGameView",System.Reflection.BindingFlags.NonPublic | System.Reflection.BindingFlags.Static); System.Object Res = GetSizeOfMainGameView.Invoke(null,null); return (Vector2)Res; } void OnDrawGizmos() { Camera cam = this.camera; // Top left Vector3 tlN = cam.ScreenToWorldPoint(new Vector3(Screen.width*0, Screen.height, cam.nearClipPlane)); Vector3 tlF = cam.ScreenToWorldPoint(new Vector3(Screen.width*0, Screen.height, cam.farClipPlane)); // Top right Vector3 trN = cam.ScreenToWorldPoint(new Vector3(Screen.width, Screen.height, cam.nearClipPlane)); Vector3 trF = cam.ScreenToWorldPoint(new Vector3(Screen.width, Screen.height, cam.farClipPlane)); // Bottom left Vector3 blN = cam.ScreenToWorldPoint(new Vector3(0.0f, 0.0f, cam.nearClipPlane)); Vector3 blF = cam.ScreenToWorldPoint(new Vector3(0.0f, 0.0f, cam.farClipPlane)); // Bottom right Vector3 brN = cam.ScreenToWorldPoint(new Vector3(Screen.width, 0.0f, cam.nearClipPlane)); Vector3 brF = cam.ScreenToWorldPoint(new Vector3(Screen.width, 0.0f, cam.farClipPlane)); // Scale for aspect ratio Vector2 gameViewsize = GetMainGameViewSize(); // float gameViewAspect = gameViewsize.x / gameViewsize.y;

 // 화면 비율에 맞추기 위해서 수정[blueasa]

float gameViewAspect = Screen.width / Screen.height; float s = gameViewAspect / cam.aspect; tlN.x *= s; tlF.x *= s; trN.x *= s; trF.x *= s; blN.x *= s; blF.x *= s; brN.x *= s; brF.x *= s; Gizmos.color = Color.white; // Near Gizmos.DrawLine(tlN, trN); Gizmos.DrawLine(trN, brN); Gizmos.DrawLine(brN, blN); Gizmos.DrawLine(blN, tlN); // Far Gizmos.DrawLine(tlF, trF); Gizmos.DrawLine(trF, brF); Gizmos.DrawLine(brF, blF); Gizmos.DrawLine(blF, tlF); // Sides Gizmos.DrawLine(tlN, tlF); Gizmos.DrawLine(trN, trF); Gizmos.DrawLine(brN, brF); Gizmos.DrawLine(blN, blF); }


[출처] 유니티. Gizmos로 카메라 프러스텀 보이게 하기.|작성자 괴발자

반응형

'Unity3D' 카테고리의 다른 글

유니티 관련  (0) 2012.10.17
Transform Custom Editor  (0) 2012.10.15
유니티에 툴바 만들기..  (0) 2012.10.15
유니티에서 툴 만들기  (0) 2012.10.12
[링크] 유니티 관련 사이트  (0) 2012.10.12
Posted by blueasa
, |