您最多选择25个主题
主题必须以中文或者字母或数字开头,可以包含连字符 (-),并且长度不得超过35个字符
66 行
1.9 KiB
66 行
1.9 KiB
using UnityEngine;
|
|
using NaughtyAttributes;
|
|
|
|
namespace GameplayIngredients.Rigs
|
|
{
|
|
[HelpURL(Help.URL + "rigs")]
|
|
public abstract class Rig : MonoBehaviour
|
|
{
|
|
public UpdateMode updateMode
|
|
{
|
|
get { return m_UpdateMode; }
|
|
}
|
|
|
|
public int rigPriority
|
|
{
|
|
get { return m_RigPriority; }
|
|
}
|
|
|
|
public enum UpdateMode
|
|
{
|
|
Update,
|
|
LateUpdate,
|
|
FixedUpdate,
|
|
}
|
|
|
|
public abstract UpdateMode defaultUpdateMode { get; }
|
|
public abstract int defaultPriority { get; }
|
|
public virtual bool canChangeUpdateMode { get { return false; } }
|
|
|
|
protected bool CanChangeUpdateMode() { return canChangeUpdateMode; }
|
|
|
|
[SerializeField, EnableIf("CanChangeUpdateMode")]
|
|
private UpdateMode m_UpdateMode;
|
|
[SerializeField]
|
|
private int m_RigPriority = 0;
|
|
|
|
|
|
private void Reset()
|
|
{
|
|
if(!canChangeUpdateMode)
|
|
m_UpdateMode = defaultUpdateMode;
|
|
m_RigPriority = defaultPriority;
|
|
}
|
|
|
|
protected virtual void OnEnable()
|
|
{
|
|
if (Manager.TryGet(out RigManager rigManager))
|
|
rigManager.RegistedRig(this);
|
|
else
|
|
Debug.LogWarning($"{gameObject.name} : Could not register the Rig of type {GetType().Name}. Rig Manager is not present or has been excluded. Please check your Assets/GameplayIngredientsSettings asset");
|
|
}
|
|
|
|
protected virtual void OnDisable()
|
|
{
|
|
if (Manager.TryGet(out RigManager rigManager))
|
|
rigManager.RemoveRig(this);
|
|
else
|
|
Debug.LogWarning($"{gameObject.name} : Could not remove the Rig of type {GetType().Name}. Rig Manager is not present or has been excluded. Please check your Assets/GameplayIngredientsSettings asset");
|
|
}
|
|
|
|
public abstract void UpdateRig(float deltaTime);
|
|
|
|
}
|
|
}
|
|
|
|
|