From aed539855c42c365712a6fe6d9799f7cfbf37df7 Mon Sep 17 00:00:00 2001 From: Lyuma Date: Wed, 30 Dec 2020 12:56:14 -0800 Subject: [PATCH] Allow setting default values for tracking type and debug from the main emulator control --- README.md | 3 ++- Scripts/LyumaAv3Emulator.cs | 4 ++++ Scripts/LyumaAv3Runtime.cs | 20 ++++++++++++++++---- 3 files changed, 22 insertions(+), 5 deletions(-) diff --git a/README.md b/README.md index 26f365f..ab80644 100644 --- a/README.md +++ b/README.md @@ -6,6 +6,7 @@ * Support for testing Visemes. * Support for the Is VR checkbox, tracking type and more. (Thanks to @hai-vr for the contribution!) * Basic support for Generic avatars. +* After using **Tools** -> **Enable Avatars 3.0 Emulator**, set default VR tracking type and other settings by selecting the **Avatars 3.0 Emulator Control** object before entering Play Mode. ### **About the Avatar 3.0 Emulator:** @@ -36,7 +37,7 @@ This is an emulator for Avatars 3.0 reimplemented in the unity editor on top the ## How to use the Av3 Emulator: Go to the **Tools** menu, and select **Avatar 3.0 Emulator**. -This will add an object to your scene: you can always remove it if you don't want it to run. +This will add an object to your scene: you can always remove it if you don't want it to run. Use this object to set default VR mode, tracking type or Animator to Debug settings. Let me know if other settings would be useful here. To emulate walking and movement, click the avatar and scroll down the inspector to the bottom section with Lyuma Av3 Runtime component. Here you can change stuff. diff --git a/Scripts/LyumaAv3Emulator.cs b/Scripts/LyumaAv3Emulator.cs index 54cec91..36e451f 100644 --- a/Scripts/LyumaAv3Emulator.cs +++ b/Scripts/LyumaAv3Emulator.cs @@ -24,6 +24,10 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE [RequireComponent(typeof(Animator))] public class LyumaAv3Emulator : MonoBehaviour { + public bool DefaultToVR = false; + public bool DefaultTestInStation = false; + public LyumaAv3Runtime.TrackingTypeIndex DefaultTrackingType = LyumaAv3Runtime.TrackingTypeIndex.HeadHands; + public VRCAvatarDescriptor.AnimLayerType DefaultAnimatorToDebug = VRCAvatarDescriptor.AnimLayerType.Base; public bool RestartEmulator; private bool RestartingEmulator; public bool CreateNonLocalClone; diff --git a/Scripts/LyumaAv3Runtime.cs b/Scripts/LyumaAv3Runtime.cs index 7ed0147..d8721eb 100644 --- a/Scripts/LyumaAv3Runtime.cs +++ b/Scripts/LyumaAv3Runtime.cs @@ -514,15 +514,27 @@ void Awake() AvatarSyncSource = GameObject.Find(SourceObjectPath).GetComponent(); } + AnimatorToDebug = VRCAvatarDescriptor.AnimLayerType.Base; + + if (LyumaAv3Emulator.emulatorInstance == null) { + Debug.LogError("LyumaAv3Runtime awoken without an LyumaAv3Emulator instance!", this); + } else { + this.VRMode = LyumaAv3Emulator.emulatorInstance.DefaultToVR; + this.TrackingType = LyumaAv3Emulator.emulatorInstance.DefaultTrackingType; + this.InStation = LyumaAv3Emulator.emulatorInstance.DefaultTestInStation; + this.AnimatorToDebug = LyumaAv3Emulator.emulatorInstance.DefaultAnimatorToDebug; + } + animator = this.gameObject.GetOrAddComponent(); animatorAvatar = animator.avatar; // Default values. Grounded = true; Upright = 1.0f; - TrackingType = TrackingTypeIndex.HeadHands; - AnimatorToDebug = VRCAvatarDescriptor.AnimLayerType.Base; - // AnimatorToDebug = VRCAvatarDescriptor.AnimLayerType.FX; - + if (!animator.isHuman) { + TrackingType = TrackingTypeIndex.GenericRig; + } else if (!VRMode) { + TrackingType = TrackingTypeIndex.HeadHands; + } avadesc = this.gameObject.GetComponent(); if (avadesc.VisemeSkinnedMesh == null) { mouthOpenBlendShapeIdx = -1;