[Unity] 동적 변경 검사기 표시
6071 단어 편집기 확장UnityEditorUnity
검사기의 속성에 따라 동적 변경 표시 내용을 변경합니다.
각 설정의 표시/숨겨진 단순 샘플을 체크 상자가 있는 경우에만 전환합니다.
using UnityEngine;
public class HogeObject : MonoBehaviour
{
public bool EnableShadow = false;
public ShadowSetteing Setteing = new ShadowSetteing();
[System.Serializable]
public class ShadowSetteing
{
public Color EffectColor;
public Vector2 Distance;
public bool UseAlpha;
}
}
#if UNITY_EDITOR
using UnityEditor;
[CustomEditor(typeof(HogeObject))]
public class HogeObjectEditor : Editor
{
private HogeObject _target;
private void Awake()
{
_target = target as HogeObject;
}
public override void OnInspectorGUI()
{
EditorGUI.BeginChangeCheck();
_target.EnableShadow = EditorGUILayout.ToggleLeft("EnableShadow", _target.EnableShadow);
if (_target.EnableShadow)
{
EditorGUILayout.LabelField("影の設定");
_target.Setteing.EffectColor = EditorGUILayout.ColorField("色", _target.Setteing.EffectColor);
_target.Setteing.Distance = EditorGUILayout.Vector2Field("距離", _target.Setteing.Distance);
_target.Setteing.UseAlpha = EditorGUILayout.Toggle("透過", _target.Setteing.UseAlpha);
}
// GUIの更新があったら実行
if (EditorGUI.EndChangeCheck())
{
EditorUtility.SetDirty(_target);
}
}
}
#endif
Reference
이 문제에 관하여([Unity] 동적 변경 검사기 표시), 우리는 이곳에서 더 많은 자료를 발견하고 링크를 클릭하여 보았다 https://qiita.com/PETITDIGI/items/a40a7477579f14a5a8e6텍스트를 자유롭게 공유하거나 복사할 수 있습니다.하지만 이 문서의 URL은 참조 URL로 남겨 두십시오.
우수한 개발자 콘텐츠 발견에 전념 (Collection and Share based on the CC Protocol.)