modular-avatar/Editor/Inspector/FirstPersonVisibleEditor.cs

50 lines
1.7 KiB
C#
Raw Normal View History

#if MA_VRCSDK3_AVATARS
using UnityEditor;
2022-11-11 12:39:58 +08:00
namespace nadena.dev.modular_avatar.core.editor
{
2022-11-10 09:39:52 +08:00
[CustomEditor(typeof(ModularAvatarVisibleHeadAccessory))]
internal class FirstPersonVisibleEditor : MAEditorBase
{
private VisibleHeadAccessoryValidation _validation;
private void OnEnable()
{
2022-11-10 09:39:52 +08:00
var target = (ModularAvatarVisibleHeadAccessory) this.target;
var avatar = RuntimeUtil.FindAvatarTransformInParents(target.transform);
if (avatar != null) _validation = new VisibleHeadAccessoryValidation(avatar.gameObject);
}
protected override void OnInnerInspectorGUI()
{
2022-11-10 09:39:52 +08:00
var target = (ModularAvatarVisibleHeadAccessory) this.target;
if (_validation != null)
{
var status = _validation.Validate(target);
switch (status)
{
case VisibleHeadAccessoryValidation.ReadyStatus.Ready:
case VisibleHeadAccessoryValidation.ReadyStatus.ParentMarked:
EditorGUILayout.HelpBox(Localization.S("fpvisible.normal"), MessageType.Info);
break;
case VisibleHeadAccessoryValidation.ReadyStatus.NotUnderHead:
EditorGUILayout.HelpBox(Localization.S("fpvisible.NotUnderHead"), MessageType.Warning);
break;
default:
{
var label = "fpvisible." + status;
EditorGUILayout.HelpBox(Localization.S(label), MessageType.Error);
break;
}
}
}
Localization.ShowLanguageUI();
}
}
}
#endif