지뢰찾기 RPG개발시 EditorWindow 사용예이다.
해당 게임씬이고 플레이시에만 보이도록 설정하고 스텟정보를 보이도록 했다.
게임플레이 도중 아이템 착용이나 스킬 적용후 스텟이 변화되는 부분을 실시간으로 볼수 있다.
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 |