Show warning when components are outside of the avatar root

Closes: #39
This commit is contained in:
bd_ 2022-11-07 20:43:51 -08:00
parent f9c709dc51
commit 4f4faa929d
13 changed files with 43 additions and 28 deletions

View File

@ -413,7 +413,8 @@ namespace net.fushizen.modular_avatar.core.editor
public override void OnInspectorGUI()
{
LogoDisplay.DisplayLogo();
InspectorCommon.DisplayOutOfAvatarWarning(targets);
EditorGUI.BeginChangeCheck();
_devMode = EditorGUILayout.Toggle(G("params.devmode"), _devMode);
if (EditorGUI.EndChangeCheck() || _reorderableList == null || _needsRebuild) SetupList();

View File

@ -246,6 +246,8 @@ namespace net.fushizen.modular_avatar.core.editor
{
LogoDisplay.DisplayLogo();
InspectorCommon.DisplayOutOfAvatarWarning(targets);
serializedObject.Update();
_list.DoLayoutList();

View File

@ -29,7 +29,8 @@ namespace net.fushizen.modular_avatar.core.editor
public override void OnInspectorGUI()
{
LogoDisplay.DisplayLogo();
InspectorCommon.DisplayOutOfAvatarWarning(targets);
GameObject parentAvatar = null;
bool suppressTarget = false;

View File

@ -21,6 +21,10 @@ namespace net.fushizen.modular_avatar.core.editor
{
var target = (ModularAvatarFirstPersonVisible) this.target;
LogoDisplay.DisplayLogo();
InspectorCommon.DisplayOutOfAvatarWarning(targets);
#if UNITY_ANDROID
EditorGUILayout.HelpBox(Localization.S("fpvisible.quest"), MessageType.Warning);

View File

@ -1,21 +0,0 @@
using System;
using UnityEngine;
namespace net.fushizen.modular_avatar.core.editor
{
public class GUIColorScope : IDisposable
{
private readonly Color _oldColor;
public GUIColorScope(Color color)
{
_oldColor = GUI.color;
GUI.color = color;
}
public void Dispose()
{
GUI.color = _oldColor;
}
}
}

View File

@ -1,3 +0,0 @@
fileFormatVersion: 2
guid: 775469f355c64ef2b3e3f5de10e2cde4
timeCreated: 1667876954

View File

@ -0,0 +1,23 @@
using UnityEditor;
using UnityEditor.Experimental.SceneManagement;
using UnityEngine;
namespace net.fushizen.modular_avatar.core.editor
{
internal static class InspectorCommon
{
internal static void DisplayOutOfAvatarWarning(Object[] targets)
{
if (PrefabStageUtility.GetCurrentPrefabStage() != null) return;
if (targets.Length != 1) return;
var target = targets[0] as Component;
if (target == null) return;
if (RuntimeUtil.FindAvatarInParents(target.transform) == null)
{
EditorGUILayout.HelpBox(Localization.S("hint.not_in_avatar"), MessageType.Warning);
}
}
}
}

View File

@ -0,0 +1,3 @@
fileFormatVersion: 2
guid: 3f28108b9ff54e18af150d9172ae275b
timeCreated: 1667882294

View File

@ -50,6 +50,7 @@ namespace net.fushizen.modular_avatar.core.editor
public override void OnInspectorGUI()
{
LogoDisplay.DisplayLogo();
InspectorCommon.DisplayOutOfAvatarWarning(targets);
SetupMenuEditor();

View File

@ -49,6 +49,7 @@ namespace net.fushizen.modular_avatar.core.editor
public override void OnInspectorGUI()
{
LogoDisplay.DisplayLogo();
InspectorCommon.DisplayOutOfAvatarWarning(targets);
serializedObject.Update();

View File

@ -33,6 +33,7 @@ namespace net.fushizen.modular_avatar.core.editor
public override void OnInspectorGUI()
{
LogoDisplay.DisplayLogo();
InspectorCommon.DisplayOutOfAvatarWarning(targets);
var target = (ModularAvatarMergeArmature) this.target;
var priorMergeTarget = target.mergeTargetObject;

View File

@ -44,5 +44,6 @@
"fpvisible.InPhysBoneChain": "This object is controlled by a Physics Bone chain and cannot be made visible in first person safely. Select the start of the chain instead.",
"blendshape.mesh": "Mesh",
"blendshape.source": "Source blendshape",
"blendshape.target": "Target blendshape"
"blendshape.target": "Target blendshape",
"hint.not_in_avatar": "This component needs to be placed inside your avatar to work properly."
}

View File

@ -44,5 +44,6 @@
"fpvisible.InPhysBoneChain": "このオブジェクトはPhysBoneに制御されているため、一人視点で表示できません。PhysBoneの始点を指定してください。",
"blendshape.mesh": "メッシュ",
"blendshape.source": "元メッシュのブレンドシェープ",
"blendshape.target": "このメッシュのブレンドシェープ"
"blendshape.target": "このメッシュのブレンドシェープ",
"hint.not_in_avatar": "このコンポーネントが正しく動作するには、アバター内に配置する必要があります。"
}