Files
7d2dXG/XG-Rebirth/Mods/0A-KFCommonUtilityLib/KFAttached/KFUtilAttached/RigActivationBinding.cs
2025-05-30 00:19:27 +09:30

70 lines
1.7 KiB
C#

using UnityEngine;
using UnityEngine.Animations.Rigging;
[AddComponentMenu("KFAttachments/Binding Helpers/Rig Activation Binding")]
public class RigActivationBinding : MonoBehaviour
{
[SerializeField]
private RigLayer[] bindings;
[SerializeField]
private RigLayer[] inverseBindings;
[SerializeField]
private RigLayer[] enableOnDisable;
[SerializeField]
private RigLayer[] disableOnEnable;
private void OnEnable()
{
//Log.Out(gameObject.name + " OnEnable!");
if (bindings != null)
{
foreach (RigLayer t in bindings)
if (t != null)
t.active = true;
}
if (inverseBindings != null)
{
foreach (RigLayer t in inverseBindings)
{
if (t != null)
t.active = false;
}
}
if (disableOnEnable != null)
{
foreach (RigLayer t in disableOnEnable)
{
if (t != null)
t.active = false;
}
}
}
private void OnDisable()
{
//Log.Out(gameObject.name + " OnDisable!");
if (bindings != null)
{
foreach (RigLayer t in bindings)
if (t != null)
t.active = false;
}
if (inverseBindings != null)
{
foreach (RigLayer t in inverseBindings)
{
if (t != null)
t.active = true;
}
}
if (enableOnDisable != null)
{
foreach (RigLayer t in enableOnDisable)
{
if (t != null)
t.active = true;
}
}
}
}