본문 바로가기
개발/Unity

Unity) 에디터 커스텀 프로그레스바 (EditorGUI Progress bar)

by 테샤르 2023. 10. 2.

EditorGUI Progress bar

Unity 에서 Progress bar를 커스텀해서 처리가 가능한 Editor Window 예시이다.

 

 

반응형
using UnityEngine;
using System.Collections;
using UnityEditor;

// Draw the armor and damage with bars in an Editor Window

public class EditorGUIProgressBar : EditorWindow
{
    float armor = 20;
    float damage  = 80;

    [MenuItem("Examples/Display Info")]

    static void Init()
    {
        EditorWindow window = GetWindow(typeof(EditorGUIProgressBar), false, "DisplayInfo");
        window.Show();
    }

    void OnGUI()
    {
        armor = EditorGUI.IntSlider(new Rect(3, 3, position.width - 6, 15), "Armor", Mathf.RoundToInt(armor), 0, 100);
        damage = EditorGUI.IntSlider(new Rect(3, 25, position.width - 6, 15), "Damage", Mathf.RoundToInt(damage), 0, 100);

        EditorGUI.ProgressBar(new Rect(3, 45, position.width - 6, 20), armor / 100, "Armor");
        EditorGUI.ProgressBar(new Rect(3, 70, position.width - 6, 20), damage / 100, "Damage");
    }
}

해당 코드를 참고해서 여러가지 방식으로도 구현이 가능하다.

 

 

Unity -EditorGUI.ProgressBar : [링크]

 

EditorGUI-ProgressBar - Unity 스크립팅 API

Makes a progress bar.

docs.unity3d.com

 

★☆☆ ☆ ☆

 

반응형

댓글