modular-avatar/Runtime/Activator.cs
Haï~ 3b067e4664
Make compatible with Unity 6 projects (#1232)
* Disable compilation for use in Unity 6 (6000.0.20f1):
- Do not compile some classes and code paths in non-VRChat projects.
- This has been tested in Unity 6 (6000.0.20f1).

* Fix hide internal components in Unity 6:
- [AddComponentMenu("")] does not work in Unity 6.
- Replace it with [AddComponentMenu("/")]
- This alternative is confirmed to also work in Unity 2022.

---------

Co-authored-by: Haï~ <hai-vr@users.noreply.github.com>
Co-authored-by: bd_ <bd_@nadena.dev>
2024-10-19 18:58:41 -07:00

44 lines
1.4 KiB
C#

#if UNITY_EDITOR
using UnityEngine;
#if MA_VRCSDK3_AVATARS
using VRC.SDKBase;
#endif
namespace nadena.dev.modular_avatar.core
{
/// <summary>
/// This component was previously used to trigger avatar processing when entering play mode. This functionality has
/// moved to NDMF, so we leave here a stub to clean up detritus left behind from older versions of MA.
/// We create it on a hidden object via AvatarTagObject's OnValidate, and it will proceed to add MAAvatarActivator
/// components to all avatar roots which contain MA components. This MAAvatarActivator component then performs MA
/// processing on Awake.
///
/// Note that we do not directly process the avatars from MAActivator. This is to avoid processing avatars that are
/// initially inactive in the scene (which can have high overhead if the user has a lot of inactive avatars in the
/// scene).
/// </summary>
[AddComponentMenu("/")]
[ExecuteInEditMode]
[DefaultExecutionOrder(-9998)]
public class Activator : MonoBehaviour, IEditorOnly
{
private void Update()
{
UnityEngine.Object.DestroyImmediate(gameObject);
}
}
[AddComponentMenu("/")]
[ExecuteInEditMode]
[DefaultExecutionOrder(-9997)]
public class AvatarActivator : MonoBehaviour, IEditorOnly
{
private void Update()
{
DestroyImmediate(this);
}
}
}
#endif