블로그 이미지
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-25 09:56

EditorWindow에서 Input 클래스는 안먹히는가 보다.

(참조 : http://answers.unity3d.com/questions/15067/input-in-editor-scripts.html)

그래서 대신 사용하는 게 Event 클래스..



Event


A UnityGUI event.

Events correspond to user input (key presses, mouse actions), or are UnityGUI layout or rendering events.

For each event OnGUI is called in the scripts; so OnGUI is potentially called multiple times per frame. Event.current corresponds to "current" event inside OnGUI call.

See Also: GUI Scripting Guide, EventType.

Variables
rawType

type

The type of event.

mousePosition

The mouse position.

delta

The relative movement of the mouse compared to last event.

button

Which mouse button was pressed.

modifiers

Which modifier keys are held down.

clickCount

How many consecutive mouse clicks have we received.

character

The character typed.

commandName

The name of an ExecuteCommand or ValidateCommand Event.

keyCode

The raw key code for keyboard events.

shift

Is Shift held down? (Read Only)

control

Is Control key held down? (Read Only)

alt

Is Alt/Option key held down? (Read Only)

command

Is Command/Windows key held down? (Read Only)

capsLock

Is Caps Lock on? (Read Only)

numeric

Is the current keypress on the numeric keyboard? (Read Only)

functionKey

Is the current keypress a function key? (Read Only)

isKey

Is this event a keyboard event? (Read Only)

isMouse

Is this event a mouse event? (Read Only)

Functions
GetTypeForControl

Use

Use this event.

Class Variables
current

The current event that's being processed right now.

Class Functions
KeyboardEvent

Create a keyboard event.



링크 : http://docs.unity3d.com/Documentation/ScriptReference/Event.html

반응형

'Unity3D > Tips' 카테고리의 다른 글

유니티 소소한 TIP  (0) 2013.04.05
How to get SceneView Camera?  (0) 2013.03.25
비활성화 된 오브젝트 찾을 때..  (0) 2013.03.21
iOS 60프레임으로 셋팅하기  (0) 2013.03.08
씬 로딩화면  (0) 2013.03.08
Posted by blueasa
, |

1. 우선 새로 보여질 카메라를 하나 만든다.

2. 새 카메라의 Depth는 메인 카메라의 Depth보다 낮아야 된다.(같거나 높으면 메인 창에서도 새 카메라를 사용해버림)

3. 아래에서 m_strQuaterViewerName 은 카메라 오브젝트 이름이다. 임의로 집어넣게 만들어 놨음..

4. QuarterViewer.cs 스크립트는 Project 탭의 Editor 폴더 하위에 들어가야 한다.(에디트 시 사용될 스크립트라서..)


P.s. 예제에서는 RenderTextureFormat.ARGB32를 썼는데 Depth 문제가 있어서 RenderTextureFormat.Depth 로 고쳤다.


1 using UnityEngine; 2 using UnityEditor; 3 4 public class QuarterViewer : EditorWindow 5 { 6 private static EditorWindow editorWindow; 7 8 private string m_strQuaterViewerName; 9 private Camera m_camQuaterViewer; 10 private RenderTexture m_RenderTexture; 11 12 [MenuItem("Camera/Quarter Viewer")] 13 static void Init() 14 { 15 editorWindow = GetWindow(typeof(QuarterViewer)); 16 editorWindow.autoRepaintOnSceneChange = true; 17 editorWindow.Show(); 18 } 19 public void Awake() 20 { 21 m_RenderTexture = new RenderTexture((int)position.width, 22 (int)position.height, 23 (int)RenderTextureFormat.Depth); 24 25 m_strQuaterViewerName = "Camera - QuarterViewer"; 26 if (GameObject.Find(m_strQuaterViewerName)) 27 { 28 m_camQuaterViewer = GameObject.Find(m_strQuaterViewerName).GetComponent<Camera>(); 29 if (null == m_camQuaterViewer) 30 { 31 Debug.Log("Can't Find 'Camera - QuarterView'"); 32 } 33 } 34 } 35 public void Update() 36 { 37 if (null != m_camQuaterViewer && null != m_RenderTexture) 38 { 39 m_camQuaterViewer.targetTexture = m_RenderTexture; 40 m_camQuaterViewer.Render(); 41 m_camQuaterViewer.targetTexture = null; 42 43 if (m_RenderTexture.width != position.width || 44 m_RenderTexture.height != position.height) 45 { 46 m_RenderTexture = new RenderTexture((int)position.width, 47 (int)position.height, 48 (int)RenderTextureFormat.Depth); 49 } 50 } 51 } 52 void OnGUI() 53 { 54 if (null != m_camQuaterViewer && null != m_RenderTexture) 55 { 56 GUI.DrawTexture(new Rect(0.0f, 0.0f, position.width, position.height), m_RenderTexture); 57 } 58 59 } 60 }


[참조]

http://blueasa.tistory.com/943

http://docs.unity3d.com/Documentation/ScriptReference/EditorWindow-autoRepaintOnSceneChange.html

http://docs.unity3d.com/Documentation/ScriptReference/RenderTextureFormat.html


반응형
Posted by blueasa
, |

유니티에서 툴 만들기

Unity3D / 2012. 10. 12. 17:04

유니티에서 툴을 만들려면 어째야 되는지 이리저리 알아보니 맥스 비슷하게 툴자체에 추가하는 형식 같다.


EditorWindow 라는 클래스를 사용해서 제작 되는 것 같다.


확인한 커스텀 에디터 제작 순서는 아래와 같다.


1. EditorWindow 를 상속한 클래스를 하나 만든다.(아래 출처의 소스 참조)

   (※ 난 C#이므로 using UnityEditor; 추가)


2. 만들어진 스크립트 파일을 넣고 싶은 프로젝트의 'Assets/Editor' 폴더에 넣는다.(Editor 폴더 없으면 생성)


3. 해당 프로젝트를 켜보면 'Project' 패널에 Editor가 추가 돼 있는게 보인다.


4. 위 메뉴에서 'Window' 메뉴에 보면 추가했던 윈도우(소스대로 했으면 My Window)가 보인다.


5. 클릭해보면 창이 뜬다. 원하는 곳에 붙이고 레이아웃을 저장하면 끝..



출처 : http://www.devkorea.co.kr/reference/Documentation/ScriptReference/EditorWindow.html



반응형

'Unity3D' 카테고리의 다른 글

Gizmos로 카메라 프러스텀 보이게 하기  (0) 2012.10.15
유니티에 툴바 만들기..  (0) 2012.10.15
[링크] 유니티 관련 사이트  (0) 2012.10.12
Visual Studio C# Integration  (0) 2012.10.05
유니티 강좌  (0) 2012.10.03
Posted by blueasa
, |