2024-02-21 19:40:31 +08:00
|
|
|
|
#region
|
|
|
|
|
|
|
|
|
|
using System;
|
2022-10-05 08:34:04 +08:00
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
using UnityEngine;
|
2024-02-21 19:40:31 +08:00
|
|
|
|
|
|
|
|
|
#endregion
|
2022-10-05 08:34:04 +08:00
|
|
|
|
|
2022-11-11 12:39:58 +08:00
|
|
|
|
namespace nadena.dev.modular_avatar.core
|
2022-10-05 08:34:04 +08:00
|
|
|
|
{
|
|
|
|
|
[Serializable]
|
|
|
|
|
public struct ParameterConfig
|
|
|
|
|
{
|
2024-01-28 13:27:43 +08:00
|
|
|
|
internal const float VALUE_EPSILON = 0.000001f;
|
|
|
|
|
|
2022-10-05 08:34:04 +08:00
|
|
|
|
public string nameOrPrefix;
|
|
|
|
|
public string remapTo;
|
|
|
|
|
public bool internalParameter, isPrefix;
|
2022-10-16 09:43:21 +08:00
|
|
|
|
public ParameterSyncType syncType;
|
2023-04-15 16:06:35 +08:00
|
|
|
|
public bool localOnly;
|
2024-01-28 13:27:43 +08:00
|
|
|
|
|
2022-10-16 09:43:21 +08:00
|
|
|
|
public float defaultValue;
|
|
|
|
|
public bool saved;
|
2024-01-28 13:27:43 +08:00
|
|
|
|
|
|
|
|
|
public bool hasExplicitDefaultValue;
|
|
|
|
|
|
2024-02-21 19:40:31 +08:00
|
|
|
|
/// <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
|
|
|
|
|
{
|
2024-02-22 17:30:24 +08:00
|
|
|
|
get => m_overrideAnimatorDefaults || syncType == ParameterSyncType.NotSynced && HasDefaultValue;
|
2024-02-21 19:40:31 +08:00
|
|
|
|
set => m_overrideAnimatorDefaults = value;
|
|
|
|
|
}
|
|
|
|
|
|
2024-01-28 13:27:43 +08:00
|
|
|
|
public bool HasDefaultValue => hasExplicitDefaultValue || Mathf.Abs(defaultValue) > VALUE_EPSILON;
|
2022-10-16 09:43:21 +08:00
|
|
|
|
}
|
|
|
|
|
|
2023-04-15 16:06:35 +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,
|
2022-10-05 08:34:04 +08:00
|
|
|
|
}
|
|
|
|
|
|
2022-10-16 07:35:16 +08:00
|
|
|
|
[DisallowMultipleComponent]
|
2022-11-10 09:49:00 +08:00
|
|
|
|
[AddComponentMenu("Modular Avatar/MA Parameters")]
|
2023-10-11 19:40:26 +08:00
|
|
|
|
[HelpURL("https://modular-avatar.nadena.dev/docs/reference/parameters?lang=auto")]
|
2022-10-05 08:34:04 +08:00
|
|
|
|
public class ModularAvatarParameters : AvatarTagComponent
|
|
|
|
|
{
|
|
|
|
|
public List<ParameterConfig> parameters = new List<ParameterConfig>();
|
2023-08-05 14:47:03 +08:00
|
|
|
|
|
2023-09-24 13:44:07 +08:00
|
|
|
|
public override void ResolveReferences()
|
2023-08-05 14:47:03 +08:00
|
|
|
|
{
|
|
|
|
|
// no-op
|
|
|
|
|
}
|
2022-10-05 08:34:04 +08:00
|
|
|
|
}
|
|
|
|
|
}
|