Skip to content

Commit

Permalink
feat: skip apply-on-play when av3emu is present
Browse files Browse the repository at this point in the history
Closes: #16
  • Loading branch information
bdunderscore committed Sep 24, 2023
1 parent 40dcf08 commit 4f7182a
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 0 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

### Fixed

* Suppress apply-on-play when Lyuma's Av3Emulator is active (improves compatibility) (#16)

### Changed

### Removed
Expand Down
23 changes: 23 additions & 0 deletions Runtime/ApplyOnPlayGlobalActivator.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
#if UNITY_EDITOR

using System;
using UnityEditor;
using UnityEditor.SceneManagement;
using UnityEngine;
Expand Down Expand Up @@ -51,6 +52,28 @@ private void Awake()
if (!RuntimeUtil.IsPlaying || this == null) return;

var scene = gameObject.scene;

// Check if Lyuma's Av3Emulator is present and enabled; if so, we leave preprocessing up to it.
// First, find the type...

Type ty_av3emu = null;
foreach (var assembly in AppDomain.CurrentDomain.GetAssemblies())
{
ty_av3emu = assembly.GetType("Lyuma.Av3Emulator.Runtime.LyumaAv3Emulator", false);
if (ty_av3emu != null) break;
}

if (ty_av3emu != null)
{
foreach (var root in scene.GetRootGameObjects())
{
if (root.GetComponentInChildren(ty_av3emu) != null)
{
return;
}
}
}

foreach (var root in scene.GetRootGameObjects())
{
foreach (var avatar in root.GetComponentsInChildren<VRCAvatarDescriptor>())
Expand Down

0 comments on commit 4f7182a

Please sign in to comment.