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

카테고리

분류 전체보기 (2731)
Unity3D (814)
Programming (474)
Server (33)
Unreal (4)
Gamebryo (56)
Tip & Tech (228)
협업 (57)
3DS Max (3)
Game (12)
Utility (136)
Etc (96)
Link (32)
Portfolio (19)
Subject (90)
iOS,OSX (51)
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
03-29 07:22

'툴바'에 해당되는 글 1건

  1. 2012.10.15 유니티에 툴바 만들기..
using UnityEngine;
using UnityEditor;

public class MyToolbar : EditorWindow  
{
    // Add menu named "My Window" to the Window menu
    [MenuItem ("Window/Toolbar")]
    static void Init () {
        // Get existing open window or if none, make a new one:
        MyToolbar window = EditorWindow.GetWindow (typeof (MyToolbar)) as MyToolbar;
		//window.minSize = new Vector2(34f, 34f);
		//window.maxSize = new Vector2(1024f, 70f);
		window.position = new Rect(0,0,200,34);
    }
	
    void OnGUI()
	{
		// GUILayout, EditorGUILayout 둘 다 되는데 무슨 차이일까..
        //EditorGUILayout.BeginHorizontal ("Toolbar");
		GUILayout.BeginHorizontal ("Toolbar");

		// 텍스트이름 버튼
		if(GUILayout.Button ("AS", GUILayout.Width( 32f ), GUILayout.Height( 32f )))
		{
			// 유니티 메뉴에서 실행할 메뉴선택
			EditorApplication.ExecuteMenuItem( "Window/Asset Store" );	
		}
		
		GUILayout.Button ("Pop up", GUILayout.Width( 32f ), GUILayout.Height( 32f ));
		GUILayout.Space (10f);        // 표준 에디터 간격을 넣는다.
		GUILayout.Button ("Drop me down", GUILayout.Width( 32f ), GUILayout.Height( 32f ));
		
		// 이미지 버튼 넣기(이미지 없으면 텍스트로)
		string TPath = string.Format( "Assets/Room/Bluesky Up.jpg" ); 
        Texture tex = Resources.LoadAssetAtPath( TPath, typeof(Texture) ) as Texture; 
        if( tex != null ) 
        { 
            if( GUILayout.Button( tex, GUILayout.Width( 32f ), GUILayout.Height( 32f ) ) )
			{
                EditorApplication.ExecuteMenuItem( "Window/Asset Server" ); 
			}
        }
		else
		{
			if( GUILayout.Button( "Asset Server", GUILayout.Width( 32f ), GUILayout.Height( 32f ) ) )
			{
                EditorApplication.ExecuteMenuItem( "Window/Asset Server" ); 
			}
		}

		//EditorGUILayout.EndHorizontal ();
		GUILayout.EndHorizontal ();
    }
}



소스에 주석이 달려 있으므로 별로 설명은 필요 없을 것 같지만..


기본적으로 해야는 것 같은(?)건..


1. 툴바도 우선 메뉴는 필요한 듯..메뉴 포함 윈도우를 만듬.(크기 조절은 좀 필요할 듯 하다.)

2. 필요한 버튼을 만든다.(이미지로 처리된다면 Assets/아래 리소스를 첨부해야 될 듯)

3. 툴바 버튼 눌렀을 때 실행할 메뉴를 링크해 준다.(외부 프로그램도 실행방법이 있겠지? 나중에 확인해야지..)



P.s. 괴발자님의 블로그 글을 보고 이리저리 삽질하면서 만들었다.

       유니티는 아직 초보라 잘 설명해준 글도 삽질은 별 수 없나보다..

       정보 공유해주신 괴발자님 감사합니다. :)


참조 : http://blog.naver.com/clater11/80167664654

반응형

'Unity3D' 카테고리의 다른 글

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