2023-09-24 16:59:15 +09:00
|
|
|
|
using System;
|
2023-09-27 20:24:42 +09:00
|
|
|
|
using nadena.dev.modular_avatar.core.armature_lock;
|
2023-09-24 16:59:15 +09:00
|
|
|
|
using UnityEngine;
|
2024-11-24 18:24:38 -08:00
|
|
|
|
#if UNITY_EDITOR
|
|
|
|
|
using UnityEditor;
|
|
|
|
|
#endif
|
2023-11-10 15:37:56 +09:00
|
|
|
|
#if MA_VRCSDK3_AVATARS
|
2023-09-24 16:59:15 +09:00
|
|
|
|
using VRC.SDKBase;
|
2023-11-10 15:37:56 +09:00
|
|
|
|
#endif
|
2023-09-24 16:59:15 +09:00
|
|
|
|
|
2024-11-24 18:24:38 -08:00
|
|
|
|
namespace nadena.dev.modular_avatar.core
|
2023-09-24 16:59:15 +09:00
|
|
|
|
{
|
|
|
|
|
[ExecuteInEditMode]
|
2024-08-13 20:33:08 -07:00
|
|
|
|
[AddComponentMenu("Modular Avatar/MA Move Independently")]
|
2023-09-24 16:59:15 +09:00
|
|
|
|
[DisallowMultipleComponent]
|
2023-10-11 20:40:26 +09:00
|
|
|
|
[HelpURL("https://modular-avatar.nadena.dev/docs/reference/move-independently?lang=auto")]
|
2023-09-24 16:59:15 +09:00
|
|
|
|
class MAMoveIndependently : MonoBehaviour, IEditorOnly
|
|
|
|
|
{
|
2024-08-30 19:19:46 -07:00
|
|
|
|
[SerializeField]
|
2023-09-24 16:59:15 +09:00
|
|
|
|
private GameObject[] m_groupedBones;
|
|
|
|
|
|
|
|
|
|
public GameObject[] GroupedBones
|
|
|
|
|
{
|
2024-11-24 18:24:38 -08:00
|
|
|
|
get => m_groupedBones?.Clone() as GameObject[] ?? Array.Empty<GameObject>();
|
2023-09-24 16:59:15 +09:00
|
|
|
|
set
|
|
|
|
|
{
|
|
|
|
|
m_groupedBones = value.Clone() as GameObject[];
|
2024-11-24 18:24:38 -08:00
|
|
|
|
MaMoveIndependentlyManager.Instance.Activate(this);
|
2023-09-24 16:59:15 +09:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void OnValidate()
|
|
|
|
|
{
|
2023-09-25 22:57:45 +09:00
|
|
|
|
#if UNITY_EDITOR
|
2024-11-24 18:24:38 -08:00
|
|
|
|
if (!PrefabUtility.IsPartOfPrefabAsset(this))
|
|
|
|
|
{
|
|
|
|
|
EditorApplication.delayCall += () =>
|
2023-09-24 16:59:15 +09:00
|
|
|
|
{
|
2024-11-24 18:24:38 -08:00
|
|
|
|
if (this != null) MaMoveIndependentlyManager.Instance.Activate(this);
|
2023-09-24 16:59:15 +09:00
|
|
|
|
};
|
|
|
|
|
}
|
2024-11-24 18:24:38 -08:00
|
|
|
|
#endif
|
2023-09-24 16:59:15 +09:00
|
|
|
|
}
|
|
|
|
|
|
2023-09-27 20:24:42 +09:00
|
|
|
|
private void OnEnable()
|
|
|
|
|
{
|
2024-11-24 18:24:38 -08:00
|
|
|
|
MaMoveIndependentlyManager.Instance.Activate(this);
|
2023-09-27 20:24:42 +09:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void OnDisable()
|
2023-09-24 16:59:15 +09:00
|
|
|
|
{
|
2024-11-24 18:24:38 -08:00
|
|
|
|
MaMoveIndependentlyManager.Instance.Deactivate(this);
|
2023-09-24 16:59:15 +09:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|