Skip to content

Commit

Permalink
Allow setting default values for tracking type and debug from the mai…
Browse files Browse the repository at this point in the history
…n emulator control
  • Loading branch information
lyuma committed Dec 30, 2020
1 parent a496a60 commit aed5398
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 5 deletions.
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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:**

Expand Down Expand Up @@ -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.

Expand Down
4 changes: 4 additions & 0 deletions Scripts/LyumaAv3Emulator.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
20 changes: 16 additions & 4 deletions Scripts/LyumaAv3Runtime.cs
Original file line number Diff line number Diff line change
Expand Up @@ -514,15 +514,27 @@ void Awake()
AvatarSyncSource = GameObject.Find(SourceObjectPath).GetComponent<LyumaAv3Runtime>();
}

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<Animator>();
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<VRCAvatarDescriptor>();
if (avadesc.VisemeSkinnedMesh == null) {
mouthOpenBlendShapeIdx = -1;
Expand Down

0 comments on commit aed5398

Please sign in to comment.