summaryrefslogtreecommitdiff
path: root/Assets/Samples/XR Interaction Toolkit/3.1.2/Hands Interaction Demo/Scripts/Vector3ScaleAffordanceReceiver.cs
blob: 3845f1996af729ca3c76b03861ea78d8a79a844e (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
using System;
using Unity.Mathematics;
using UnityEngine.XR.Interaction.Toolkit.AffordanceSystem.Receiver.Primitives;

namespace UnityEngine.XR.Interaction.Toolkit.Samples.Hands
{
    /// <summary>
    /// Affordance receiver applying a Vector3 (Float3) affordance theme to a Transform local scale.
    /// Broadcasts new affordance value with Unity Event.
    /// </summary>
    [Obsolete("The Affordance System namespace and all associated classes have been deprecated. The existing affordance system will be moved, replaced and updated with a new interaction feedback system in a future version of XRI.")]
    public class Vector3ScaleAffordanceReceiver : Vector3AffordanceReceiver
    {
        [SerializeField]
        [Tooltip("The transform to apply the scale value to.")]
        Transform m_TargetTransform;

        /// <inheritdoc />
        protected override void OnEnable()
        {
            base.OnEnable();
            if (m_TargetTransform == null)
                m_TargetTransform = transform;
        }

        /// <inheritdoc />
        protected override void OnAffordanceValueUpdated(float3 newValue)
        {
            base.OnAffordanceValueUpdated(newValue);
            m_TargetTransform.localScale = newValue;
        }
    }
}