mirror of
https://github.com/bdunderscore/modular-avatar.git
synced 2025-02-02 19:52:51 +08:00
Avoid scary errors when entering play mode
As part of our hook processing, we destroy modular-avatar components; however, when entering play mode (without av3emu), these components might be prefab assets. To avoid scary unity errors, unpack these prefabs when entering play mode.
This commit is contained in:
parent
8d4d1642cf
commit
1c6db2a01f
@ -23,6 +23,7 @@
|
||||
*/
|
||||
|
||||
using UnityEditor;
|
||||
using UnityEngine;
|
||||
using UnityEngine.SceneManagement;
|
||||
using VRC.SDK3.Avatars.Components;
|
||||
using VRC.SDKBase.Editor.BuildPipeline;
|
||||
@ -58,11 +59,27 @@ namespace net.fushizen.modular_avatar.core.editor
|
||||
{
|
||||
if (avatar.GetComponentsInChildren<AvatarTagComponent>(true).Length > 0)
|
||||
{
|
||||
UnpackPrefabsCompletely(avatar.gameObject);
|
||||
VRCBuildPipelineCallbacks.OnPreprocessAvatar(avatar.gameObject);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private static void UnpackPrefabsCompletely(GameObject obj)
|
||||
{
|
||||
if (PrefabUtility.IsAnyPrefabInstanceRoot(obj))
|
||||
{
|
||||
PrefabUtility.UnpackPrefabInstance(obj, PrefabUnpackMode.Completely, InteractionMode.AutomatedAction);
|
||||
}
|
||||
else
|
||||
{
|
||||
foreach (Transform child in obj.transform)
|
||||
{
|
||||
UnpackPrefabsCompletely(child.gameObject);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user