diff --git a/Editor/UniEyeControllerEditor.cs b/Editor/UniEyeControllerEditor.cs index df46968..af1cbfa 100644 --- a/Editor/UniEyeControllerEditor.cs +++ b/Editor/UniEyeControllerEditor.cs @@ -131,7 +131,13 @@ public override void OnInspectorGUI() break; case EyeAssignMethod.Generic: EditorExtensions.BeginErrorColor(_prefabForGenericAvatar.objectReferenceValue == null); - EditorGUILayout.PropertyField(_prefabForGenericAvatar, new GUIContent("基準となるPrefab")); + EditorGUI.BeginChangeCheck(); + // Scene上のGameObjectを指定させないためにObjectFieldを使う + script.prefabForGenericAvatar = EditorGUILayout.ObjectField("基準となるPrefab", script.prefabForGenericAvatar, typeof(GameObject), false) as GameObject; + if (EditorGUI.EndChangeCheck()) + { + EditorUtility.SetDirty(script); + } EditorExtensions.EndErrorColor(); GUILayout.BeginHorizontal(); diff --git a/Runtime/Timeline/LookAt/UniEyeLookAtMixer.cs b/Runtime/Timeline/LookAt/UniEyeLookAtMixer.cs index 3c88eb8..c2e5b27 100644 --- a/Runtime/Timeline/LookAt/UniEyeLookAtMixer.cs +++ b/Runtime/Timeline/LookAt/UniEyeLookAtMixer.cs @@ -39,6 +39,8 @@ public override void ProcessFrame(Playable playable, FrameData info, object play { var controller = playerData as UniEyeController; if (controller == null) return; + if (!controller.gameObject.activeInHierarchy) return; + if (!controller.IsSettingValid) return; _process = controller.lookAtProcess; if (_process == null) return; diff --git a/Runtime/UniEyeController.cs b/Runtime/UniEyeController.cs index 7e76603..d19ae54 100644 --- a/Runtime/UniEyeController.cs +++ b/Runtime/UniEyeController.cs @@ -6,6 +6,7 @@ using UniEyeController.Core.Process.Blink; using UniEyeController.Core.Process.LookAt; using UniEyeController.Core.Process.MicroMove; +using UnityEditor; using UnityEngine; namespace UniEyeController @@ -35,6 +36,20 @@ public partial class UniEyeController : MonoBehaviour public MicroMoveProcess microMoveProcess = new MicroMoveProcess(); public BlinkProcess blinkProcess = new BlinkProcess(); + public bool IsSettingValid + { + get + { + if (assignMethod == EyeAssignMethod.Generic && gameObject.scene == prefabForGenericAvatar.scene) + { + Debug.LogError("GenericAvatarの初期状態参照用のPrefabはScene上のものを使用しないでください"); + return false; + } + + return true; + } + } + private void OnEnable() { Init(); @@ -42,6 +57,15 @@ private void OnEnable() public void Init() { + // TODO : 仮の対応 + if (assignMethod == EyeAssignMethod.Generic && gameObject.scene == prefabForGenericAvatar.scene) + { + var prefab = PrefabUtility.GetCorrespondingObjectFromSource(gameObject); + prefabForGenericAvatar = prefab; + } + + if (!IsSettingValid) enabled = false; + GetRequiredComponents(); ChangeEyeBones(); }