modular-avatar/Editor/Inspector/FirstPersonVisibleEditor.cs
kaikoga ae7103cf82
chore: use ndmf Avatar Root api where applicable (#482)
* expose ndmf AvatarRoot APIs through ma.RuntimeUtil

* refactor: prefer RuntimeUtil helpers for checking avatar root

* refactor: ndmf.BuildContext represents Avatar (log)

* refactor: ndmf.BuildContext represents Avatar (WorldFixed)

* refactor: ndmf.BuildContext represents Avatar (FirstPersonVisible)

* refactor: ndmf.BuildContext represents Avatar (BlendShapeSync)

* refactor: prefer FindAvatarTransformInParents() (ErrorReportUI)

* refactor: prefer FindAvatarTransformInParents() (Runtime)

* refactor: prefer FindAvatarTransformInParents() (Editor)

* delegate more ndmf AvatarRoot APIs through ma.RuntimeUtil
2023-10-15 18:44:53 +09:00

52 lines
1.6 KiB
C#

using UnityEditor;
namespace nadena.dev.modular_avatar.core.editor
{
[CustomEditor(typeof(ModularAvatarVisibleHeadAccessory))]
internal class FirstPersonVisibleEditor : MAEditorBase
{
private VisibleHeadAccessoryProcessor _processor;
private void OnEnable()
{
var target = (ModularAvatarVisibleHeadAccessory) this.target;
var avatar = RuntimeUtil.FindAvatarTransformInParents(target.transform);
if (avatar != null) _processor = new VisibleHeadAccessoryProcessor(new BuildContext(avatar.gameObject));
}
protected override void OnInnerInspectorGUI()
{
var target = (ModularAvatarVisibleHeadAccessory) this.target;
#if UNITY_ANDROID
EditorGUILayout.HelpBox(Localization.S("fpvisible.quest"), MessageType.Warning);
#else
if (_processor != null)
{
var status = _processor.Validate(target);
switch (status)
{
case VisibleHeadAccessoryProcessor.ReadyStatus.Ready:
case VisibleHeadAccessoryProcessor.ReadyStatus.ParentMarked:
EditorGUILayout.HelpBox(Localization.S("fpvisible.normal"), MessageType.Info);
break;
default:
{
var label = "fpvisible." + status;
EditorGUILayout.HelpBox(Localization.S(label), MessageType.Error);
break;
}
}
}
#endif
Localization.ShowLanguageUI();
}
}
}