Created
October 6, 2013 16:11
-
-
Save s2kw/6855815 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| using UnityEngine; | |
| using UnityEditor; | |
| using System.Collections; | |
| public class Question2Editor : EditorWindow { | |
| [UnityEditor.MenuItem("Editor10/Question2/EditorWindow #&w")] | |
| static void Q2_Basic() | |
| { | |
| // CreateInstance<Class name>複数のウィンドウを作成する | |
| // .Show()で表示 | |
| var window = (Question2Editor)EditorWindow.GetWindow (typeof (Question2Editor)); | |
| } | |
| string name = ""; | |
| float hp = 100f; | |
| float strength = 0f; | |
| float dex = 0f; | |
| string str = "aaaaaaaaaaaaa"; | |
| Texture2D texture; | |
| GameObject go; | |
| void OnGUI() | |
| { | |
| // button はEditorGUIには無い。 | |
| EditorGUILayout.BeginVertical(); | |
| EditorGUILayout.BeginHorizontal(); | |
| this.name = EditorGUILayout.TextField("名前",this.name); | |
| EditorGUILayout.EndHorizontal(); | |
| EditorGUILayout.BeginHorizontal(); | |
| this.hp = EditorGUILayout.Slider("HP",this.hp, 100f, 1000f); | |
| EditorGUILayout.EndHorizontal(); | |
| EditorGUILayout.BeginHorizontal(); | |
| this.strength = EditorGUILayout.Slider("力",this.strength,0f,100f); | |
| EditorGUILayout.EndHorizontal(); | |
| EditorGUILayout.BeginHorizontal(); | |
| this.dex = EditorGUILayout.Slider("すばやさ",this.dex,0f,100f); | |
| EditorGUILayout.EndHorizontal(); | |
| EditorGUILayout.EndVertical(); | |
| this.str = GUILayout.TextField(str); | |
| GUILayout.Space(10f); | |
| GUILayout.BeginHorizontal(); | |
| GUILayout.Label("名前"); | |
| this.str = GUILayout.TextField("Default Name"); | |
| GUILayout.EndHorizontal(); | |
| GUILayout.Space(10f); | |
| texture = (Texture2D)EditorGUILayout.ObjectField(texture, typeof(Texture2D), false, GUILayout.Width(64), GUILayout.Height(64)); | |
| // GameObjectでのテスト。第三引数の挙動について確認。 | |
| go = (GameObject)EditorGUILayout.ObjectField(go, typeof(GameObject), true, GUILayout.Width(64), GUILayout.Height(64)); | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment