mirror of
https://github.com/bdunderscore/modular-avatar.git
synced 2025-04-24 13:29:01 +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
ae575fc5aa
commit
3f4885e707
@ -23,6 +23,7 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
using UnityEditor;
|
using UnityEditor;
|
||||||
|
using UnityEngine;
|
||||||
using UnityEngine.SceneManagement;
|
using UnityEngine.SceneManagement;
|
||||||
using VRC.SDK3.Avatars.Components;
|
using VRC.SDK3.Avatars.Components;
|
||||||
using VRC.SDKBase.Editor.BuildPipeline;
|
using VRC.SDKBase.Editor.BuildPipeline;
|
||||||
@ -58,11 +59,27 @@ namespace net.fushizen.modular_avatar.core.editor
|
|||||||
{
|
{
|
||||||
if (avatar.GetComponentsInChildren<AvatarTagComponent>(true).Length > 0)
|
if (avatar.GetComponentsInChildren<AvatarTagComponent>(true).Length > 0)
|
||||||
{
|
{
|
||||||
|
UnpackPrefabsCompletely(avatar.gameObject);
|
||||||
VRCBuildPipelineCallbacks.OnPreprocessAvatar(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…
x
Reference in New Issue
Block a user