지뢰찾기 RPG개발시 EditorWindow 사용예이다.
해당 게임씬이고 플레이시에만 보이도록 설정하고 스텟정보를 보이도록 했다.
게임플레이 도중 아이템 착용이나 스킬 적용후 스텟이 변화되는 부분을 실시간으로 볼수 있다.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 | using UnityEngine; using UnityEditor; using UnityEditor.SceneManagement; public class MRDebugWindow : EditorWindow { [MenuItem( "디버그메뉴/스텟정보" )] static void Init() { MRDebugWindow window = (MRDebugWindow)EditorWindow.GetWindow( typeof (MRDebugWindow)); window.titleContent.text = "영웅/몬스터 스텟정보" ; window.Show(); } private void OnGUI() { if (EditorApplication.isPlaying && EditorSceneManager.GetActiveScene().name == "ingame" ) //플레이시만 보이도록 { MRHero hero = MRGameManager.Instance.GetHero(); GUILayout.BeginVertical(); GUILayout.Space(10); GUILayout.Label( "[영웅]" ); GUILayout.Label( "위치 : " + hero.Position.x + "," + hero.Position.y); GUILayout.BeginHorizontal(); GUILayout.Label( "힘 : " + ( int )hero.Status.strength); GUILayout.Label( "지능 : " + ( int )hero.Status.intelligence); GUILayout.Label( "민첩 : " + ( int )hero.Status.agility); GUILayout.Label( "건강 : " + ( int )hero.Status.vitality); GUILayout.Label( "행운 : " + ( int )hero.Status.luck); GUILayout.EndHorizontal(); GUILayout.Space(10); GUILayout.BeginHorizontal(); GUILayout.Label( "무기 : " + hero.equipItems.weapon.name); GUILayout.Label( "방어 : " + hero.equipItems.armor.name); GUILayout.Label( "악세사리 : " + hero.equipItems.accessories.name); GUILayout.Label( "머리 : " + hero.equipItems.head.name); GUILayout.EndHorizontal(); GUILayout.Space(10); GUILayout.BeginHorizontal(); GUILayout.Label( "생명력 : " + ( int )hero.CurrentHealthPoint + " / " + ( int )hero.Status.healthPoint, GUILayout.Width(150)); GUILayout.Label( "공격력 : " + ( int )hero.Status.attack, GUILayout.Width(100)); GUILayout.Label( "마력 : " + ( int )hero.Status.magicAttack, GUILayout.Width(100)); GUILayout.Label( "방어력 : " + ( int )hero.Status.defence, GUILayout.Width(100)); GUILayout.Label( "저항력 : " + ( int )hero.Status.resistance, GUILayout.Width(100)); GUILayout.Label( "명중률 : " + hero.Status.hitRate, GUILayout.Width(100)); GUILayout.EndHorizontal(); GUILayout.BeginHorizontal(); GUILayout.Label( "회피율 : " + hero.Status.dodgeRate, GUILayout.Width(150)); GUILayout.Label( "치명타확률 : " + hero.Status.criticalRate, GUILayout.Width(100)); GUILayout.Label( "공격속도 : " + hero.Status.attackSpeed, GUILayout.Width(100)); GUILayout.Label( "자연회복량 : " + ( int )hero.Status.natureRestoration, GUILayout.Width(100)); GUILayout.Label( "만복도 : " + ( int )hero.CurrentHungerPoint + "/" + ( int )hero.Status.hungerPoint, GUILayout.Width(150)); GUILayout.EndHorizontal(); GUILayout.Space(20); if (hero.ActionTarget != null ) { GUILayout.Label( "[선택된 몬스터]" ); if (hero.ActionTarget.GetType().ToString() == "MRMonster" ) { MRMonster mon = (MRMonster)hero.ActionTarget; GUILayout.Label( "이름 : " + mon.Name); GUILayout.Label( "위치 : " + mon.Position.x + "," + mon.Position.y); GUILayout.BeginHorizontal(); GUILayout.Label( "힘 : " + ( int )mon.Status.strength); GUILayout.Label( "지능 : " + ( int )mon.Status.intelligence); GUILayout.Label( "민첩 : " + ( int )mon.Status.agility); GUILayout.Label( "건강 : " + ( int )mon.Status.vitality); GUILayout.Label( "행운 : " + ( int )mon.Status.luck); GUILayout.EndHorizontal(); GUILayout.Space(10); GUILayout.BeginHorizontal(); GUILayout.Label( "생명력 : " + ( int )mon.CurrentHealthPoint + " / " + ( int )mon.Status.healthPoint, GUILayout.Width(150)); GUILayout.Label( "공격력 : " + ( int )mon.Status.attack, GUILayout.Width(100)); GUILayout.Label( "마력 : " + ( int )mon.Status.magicAttack, GUILayout.Width(100)); GUILayout.Label( "방어력 : " + ( int )mon.Status.defence, GUILayout.Width(100)); GUILayout.Label( "저항력 : " + ( int )mon.Status.resistance, GUILayout.Width(100)); GUILayout.Label( "명중률 : " + mon.Status.hitRate, GUILayout.Width(100)); GUILayout.EndHorizontal(); GUILayout.BeginHorizontal(); GUILayout.Label( "회피율 : " + mon.Status.dodgeRate, GUILayout.Width(150)); GUILayout.Label( "치명타확률 : " + mon.Status.criticalRate, GUILayout.Width(100)); GUILayout.Label( "공격속도 : " + mon.Status.attackSpeed, GUILayout.Width(100)); GUILayout.EndHorizontal(); } else if (hero.ActionTarget.GetType().ToString() == "MRMine" ) { MRMine mon = (MRMine)hero.ActionTarget; GUILayout.Label( "이름 : " + mon.Name); GUILayout.Label( "위치 : " + mon.Position.x + "," + mon.Position.y); GUILayout.BeginHorizontal(); GUILayout.Label( "힘 : " + ( int )mon.Status.strength); GUILayout.Label( "지능 : " + ( int )mon.Status.intelligence); GUILayout.Label( "민첩 : " + ( int )mon.Status.agility); GUILayout.Label( "건강 : " + ( int )mon.Status.vitality); GUILayout.Label( "행운 : " + ( int )mon.Status.luck); GUILayout.EndHorizontal(); GUILayout.Space(10); GUILayout.BeginHorizontal(); GUILayout.Label( "생명력 : " + ( int )mon.CurrentHealthPoint + " / " + ( int )mon.Status.healthPoint, GUILayout.Width(150)); GUILayout.Label( "공격력 : " + ( int )mon.Status.attack, GUILayout.Width(100)); GUILayout.Label( "마력 : " + ( int )mon.Status.magicAttack, GUILayout.Width(100)); GUILayout.Label( "방어력 : " + ( int )mon.Status.defence, GUILayout.Width(100)); GUILayout.Label( "저항력 : " + ( int )mon.Status.resistance, GUILayout.Width(100)); GUILayout.Label( "명중률 : " + mon.Status.hitRate, GUILayout.Width(100)); GUILayout.EndHorizontal(); GUILayout.BeginHorizontal(); GUILayout.Label( "회피율 : " + mon.Status.dodgeRate, GUILayout.Width(150)); GUILayout.Label( "치명타확률 : " + mon.Status.criticalRate, GUILayout.Width(100)); GUILayout.Label( "공격속도 : " + mon.Status.attackSpeed, GUILayout.Width(100)); GUILayout.EndHorizontal(); } } GUILayout.EndVertical(); } } private void OnInspectorUpdate() { Repaint(); } } |
'Unity' 카테고리의 다른 글
Custom Editor - SerializedProperty (0) | 2017.05.03 |
---|---|
Custom Inspector (0) | 2017.05.03 |
Custom Editor Window - GUI (0) | 2017.05.02 |
Editor Scripting Tip [Built-in Attribute] (0) | 2017.05.02 |
unity gitignore 파일 (0) | 2017.03.07 |