[Unity] OnInspectorGUI 인스팩터를 커스터마이즈하자

ChangJin·2023년 12월 21일
0

Unity

목록 보기
8/17
post-thumbnail

공식 문서를 보면...

https://docs.unity3d.com/ScriptReference/Editor.OnInspectorGUI.html


OnInspectorGUI는 custom inspector를 만드는 함수입니다.


특정 object class의 인스펙터에 대해 GUI를 기반으로한 나만의 커스텀 IMGUI를 만들 수 있습니다.


using UnityEngine;
using System.Collections;
using UnityEditor;

// ScriptName이라는 모든 스크립트에 대해 custom Label을 인스펙터창에 생성함
// CustomEditor 때문에 반드시 ScriptName이 있어야함. 없으면 동작하지 않음.
[CustomEditor(typeof(ScriptName))]
public class TestOnInspector : Editor
{
    public override void OnInspectorGUI()
    {
        GUILayout.Label ("This is a Label in a Custom Editor");
    }
}

  • 다음처럼 Custom Label을 만들수 있습니다. 지금은 단순 Label이지만 슬라이더, 이미지 등을 넣을 수도 있습니다.
profile
게임 프로그래머

0개의 댓글

관련 채용 정보