0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

VRC_AvatarParameterDriver

Last updated at Posted at 2024-09-13

VRC_AvatarParameterDriver

  • 割とよく使うので覚書
  • Local Onlyの定義がちょっと特殊(Avatar装着者のみでしか処理されなくなる)。注意
  • Random
    • Int,Float … min max valueの間でセット
    • bool … Chanceに設定した確率で1にセット

image.png

Set int

  • parametersはlist

image.png
image.png

using System;
using System.Collections.Generic;
using UnityEngine;

namespace VRC.SDKBase
{
    public abstract class VRC_AvatarParameterDriver : StateMachineBehaviour
    {
        public enum ChangeType
        {
            Set,
            Add,
            Random,
            Copy
        }

        [Serializable]
        public class Parameter
        {
            [Tooltip("The type of operation to be executed")]
            public ChangeType type;

            [Tooltip("Parameter that will be written to")]
            public string name;

            [Tooltip("Source parameter that will be read")]
            public string source;

            [Tooltip("The value used for this operation")]
            public float value;

            [Tooltip("Minimum value to be set")]
            public float valueMin;

            [Tooltip("Maximum value to be set")]
            public float valueMax = 1f;

            [Tooltip("Chance the value will be set.  When used with a Bool type, defines the chance the value is set to 1, otherwise it's set to 0.")]
            [Range(0f, 1f)]
            public float chance = 1f;

            [Tooltip("If true, we convert the range of the source and destination values according to the ranges given.")]
            public bool convertRange;

            public float sourceMin;

            public float sourceMax;

            public float destMin;

            public float destMax;

            public object sourceParam;

            public object destParam;
        }

        public List<Parameter> parameters = new List<Parameter>();

        [Tooltip("When true, only the client who is wearing this avatar will use this ParameterDriver.  This option is useful to avoid conflicts from non-deterministic operations like Random or Add across multiple clients.")]
        public bool localOnly;

        [Tooltip("Custom debug message that will be written to the client logs when the ParameterDriver is used.  Be careful to remove these before your final upload as this can spam your log files.")]
        public string debugString;

        [NonSerialized]
        public bool isLocalPlayer;

        [NonSerialized]
        public bool isEnabled;

        [NonSerialized]
        public bool initialized;

        public static Action<VRC_AvatarParameterDriver, Animator> OnApplySettings;

        public override void OnStateEnter(Animator animator, AnimatorStateInfo stateInfo, int layerIndex)
        {
            OnApplySettings?.Invoke(this, animator);
        }
    }
}
0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?