modular-avatar/Runtime/ModularAvatarParameters.cs

70 lines
2.1 KiB
C#
Raw Normal View History

#region
using System;
using System.Collections.Generic;
using UnityEngine;
#endregion
2022-11-11 12:39:58 +08:00
namespace nadena.dev.modular_avatar.core
{
[Serializable]
public struct ParameterConfig
{
internal const float VALUE_EPSILON = 0.000001f;
public string nameOrPrefix;
public string remapTo;
public bool internalParameter, isPrefix;
2022-10-16 09:43:21 +08:00
public ParameterSyncType syncType;
public bool localOnly;
2022-10-16 09:43:21 +08:00
public float defaultValue;
public bool saved;
public bool hasExplicitDefaultValue;
/// <summary>
/// Indicates that the default value for this parameter should be applied to any animators attached to the
/// avatar as well, rather than just the expressions menu configuration.
///
/// Note: Private API for now; will be exposed in 1.10. This is always considered to be true if the parameter
/// is unsynced and has a default value override.
/// </summary>
[SerializeField]
internal bool m_overrideAnimatorDefaults;
internal bool OverrideAnimatorDefaults
{
get => m_overrideAnimatorDefaults || syncType == ParameterSyncType.NotSynced && HasDefaultValue;
set => m_overrideAnimatorDefaults = value;
}
public bool HasDefaultValue => hasExplicitDefaultValue || Mathf.Abs(defaultValue) > VALUE_EPSILON;
2022-10-16 09:43:21 +08:00
}
/**
* This enum is a bit poorly named, having been introduced before local-only parameters were a thing. In actuality,
* this is the parameter type - NotSynced indicates the parameter should not be registered in Expression Parameters.
*/
2022-10-16 09:43:21 +08:00
public enum ParameterSyncType
{
NotSynced,
Int,
Float,
Bool,
}
[DisallowMultipleComponent]
2022-11-10 09:49:00 +08:00
[AddComponentMenu("Modular Avatar/MA Parameters")]
[HelpURL("https://modular-avatar.nadena.dev/docs/reference/parameters?lang=auto")]
public class ModularAvatarParameters : AvatarTagComponent
{
public List<ParameterConfig> parameters = new List<ParameterConfig>();
2023-08-05 14:47:03 +08:00
public override void ResolveReferences()
2023-08-05 14:47:03 +08:00
{
// no-op
}
}
}