Add ultimate xr

This commit is contained in:
2024-08-06 21:58:35 +02:00
parent 864033bf10
commit 7165bacd9d
3952 changed files with 2162037 additions and 35 deletions

View File

@@ -0,0 +1,229 @@
// --------------------------------------------------------------------------------------------------------------------
// <copyright file="UxrCanvasAlphaTween.cs" company="VRMADA">
// Copyright (c) VRMADA, All rights reserved.
// </copyright>
// --------------------------------------------------------------------------------------------------------------------
using System;
using System.Threading;
using System.Threading.Tasks;
using UltimateXR.Animation.Interpolation;
using UltimateXR.Extensions.System.Threading;
using UltimateXR.Extensions.Unity;
using UnityEngine;
namespace UltimateXR.Animation.UI
{
/// <summary>
/// Tweening component to animate the <see cref="CanvasGroup.alpha" /> of a <see cref="CanvasGroup" /> component
/// programatically or using the inspector.
/// </summary>
[RequireComponent(typeof(CanvasGroup))]
public class UxrCanvasAlphaTween : UxrTween
{
#region Inspector Properties/Serialized Fields
[SerializeField] private float _startAlpha;
[SerializeField] private float _endAlpha;
#endregion
#region Public Types & Data
public CanvasGroup TargetCanvasGroup => GetCachedComponent<CanvasGroup>();
/// <summary>
/// Animation start alpha
/// </summary>
public float StartAlpha
{
get => _startAlpha;
set => _startAlpha = value;
}
/// <summary>
/// Animation end alpha
/// </summary>
public float EndAlpha
{
get => _endAlpha;
set => _endAlpha = value;
}
#endregion
#region Public Methods
/// <summary>
/// Creates and starts a tweening animation for the <see cref="CanvasGroup.alpha" /> value of a
/// <see cref="CanvasGroup" /> component.
/// </summary>
/// <param name="canvasGroup">Target <see cref="CanvasGroup" /></param>
/// <param name="startAlpha">Start alpha</param>
/// <param name="endAlpha">End alpha</param>
/// <param name="settings">Interpolation settings that control the animation</param>
/// <param name="finishedCallback">Optional callback when the animation finished</param>
/// <returns>
/// Tweening component that will update itself automatically. Can be used to stop the animation prematurely or
/// change parameters on the fly.
/// </returns>
public static UxrCanvasAlphaTween Animate(CanvasGroup canvasGroup, float startAlpha, float endAlpha, UxrInterpolationSettings settings, Action<UxrTween> finishedCallback = null)
{
UxrCanvasAlphaTween canvasAlphaTween = canvasGroup.GetOrAddComponent<UxrCanvasAlphaTween>();
canvasAlphaTween.StartAlpha = startAlpha;
canvasAlphaTween.EndAlpha = endAlpha;
canvasAlphaTween.InterpolationSettings = settings;
canvasAlphaTween.FinishedCallback = finishedCallback;
canvasAlphaTween.Restart();
return canvasAlphaTween;
}
/// <summary>
/// Creates and starts a fade-in tweening animation for the <see cref="CanvasGroup.alpha" /> value of a
/// <see cref="CanvasGroup" /> component. The alpha value will go from 0.0 to 1.0.
/// </summary>
/// <param name="canvasGroup">Target <see cref="CanvasGroup" /></param>
/// <param name="durationSeconds">Duration in seconds of the fade-in animation</param>
/// <param name="delaySeconds">Seconds to wait until the animation starts</param>
/// <param name="finishedCallback">Optional callback when the animation finished</param>
/// <returns>
/// Tweening component that will update itself automatically. Can be used to stop the animation prematurely or
/// change parameters on the fly.
/// </returns>
public static UxrCanvasAlphaTween FadeIn(CanvasGroup canvasGroup, float durationSeconds, float delaySeconds = 0.0f, Action<UxrTween> finishedCallback = null)
{
return Animate(canvasGroup, 0.0f, 1.0f, new UxrInterpolationSettings(durationSeconds, delaySeconds), finishedCallback);
}
/// <summary>
/// Creates and starts a fade-out tweening animation for the <see cref="CanvasGroup.alpha" /> value of a
/// <see cref="CanvasGroup" /> component. The alpha value will go from 1.0 to 0.0.
/// </summary>
/// <param name="canvasGroup">Target <see cref="CanvasGroup" /></param>
/// <param name="durationSeconds">Duration in seconds of the fade-in animation</param>
/// <param name="delaySeconds">Seconds to wait until the animation starts</param>
/// <param name="finishedCallback">Optional callback when the animation finished</param>
/// <returns>
/// Tweening component that will update itself automatically. Can be used to stop the animation prematurely or
/// change parameters on the fly.
/// </returns>
public static UxrCanvasAlphaTween FadeOut(CanvasGroup canvasGroup, float durationSeconds, float delaySeconds = 0.0f, Action<UxrTween> finishedCallback = null)
{
return Animate(canvasGroup, 1.0f, 0.0f, new UxrInterpolationSettings(durationSeconds, delaySeconds), finishedCallback);
}
/// <summary>
/// Same as <see cref="Animate" /> but for use with async/await.
/// </summary>
/// <param name="ct">
/// Cancellation token to cancel the asynchronous animation. <see cref="CancellationToken.None" /> to
/// ignore.
/// </param>
/// <param name="canvasGroup">Target <see cref="CanvasGroup" /></param>
/// <param name="startAlpha">Start alpha</param>
/// <param name="endAlpha">End alpha</param>
/// <param name="settings">Interpolation settings that control the animation</param>
/// <returns>
/// Task representing the asynchronous process.
/// </returns>
public static Task AnimateAsync(CancellationToken ct, CanvasGroup canvasGroup, float startAlpha, float endAlpha, UxrInterpolationSettings settings)
{
if (ct.IsCancellationRequested)
{
return null;
}
bool hasFinishedFading = false;
UxrCanvasAlphaTween canvasAlphaTween = Animate(canvasGroup, startAlpha, endAlpha, settings, t => hasFinishedFading = true);
return TaskExt.WaitUntil(() => hasFinishedFading, settings.DelaySeconds + settings.DurationSeconds, () => canvasAlphaTween.Stop(), ct);
}
/// <summary>
/// Same as <see cref="FadeIn" /> but for use with async/await.
/// </summary>
/// <param name="ct">
/// Cancellation token to cancel the asynchronous animation. <see cref="CancellationToken.None" /> to
/// ignore.
/// </param>
/// <param name="canvasGroup">Target <see cref="CanvasGroup" /></param>
/// <param name="durationSeconds">Duration in seconds of the fade-in animation</param>
/// <param name="delaySeconds">Seconds to wait until the animation starts</param>
/// <returns>
/// Task representing the asynchronous process.
/// </returns>
public static Task FadeInAsync(CancellationToken ct, CanvasGroup canvasGroup, float durationSeconds, float delaySeconds = 0.0f)
{
if (ct.IsCancellationRequested)
{
return null;
}
bool hasFinishedFading = false;
UxrCanvasAlphaTween canvasAlphaTween = FadeIn(canvasGroup, durationSeconds, delaySeconds, t => hasFinishedFading = true);
return TaskExt.WaitUntil(() => hasFinishedFading, delaySeconds + durationSeconds, () => canvasAlphaTween.Stop(), ct);
}
/// <summary>
/// Same as <see cref="FadeOut" /> but for use with async/await.
/// </summary>
/// <param name="ct">
/// Cancellation token to cancel the asynchronous animation. <see cref="CancellationToken.None" /> to
/// ignore.
/// </param>
/// <param name="canvasGroup">Target <see cref="CanvasGroup" /></param>
/// <param name="durationSeconds">Duration in seconds of the fade-in animation</param>
/// <param name="delaySeconds">Seconds to wait until the animation starts</param>
/// <returns>
/// Task representing the asynchronous process.
/// </returns>
public static Task FadeOutAsync(CancellationToken ct, CanvasGroup canvasGroup, float durationSeconds, float delaySeconds = 0.0f)
{
if (ct.IsCancellationRequested)
{
return null;
}
bool hasFinishedFading = false;
UxrCanvasAlphaTween canvasAlphaTween = FadeOut(canvasGroup, durationSeconds, delaySeconds, t => hasFinishedFading = true);
return TaskExt.WaitUntil(() => hasFinishedFading, delaySeconds + durationSeconds, () => canvasAlphaTween.Stop(), ct);
}
#endregion
#region Protected Overrides UxrTween
/// <inheritdoc />
protected override Behaviour TargetBehaviour => TargetCanvasGroup;
/// <inheritdoc />
protected override void StoreOriginalValue()
{
_originalAlpha = TargetCanvasGroup.alpha;
}
/// <inheritdoc />
protected override void RestoreOriginalValue()
{
TargetCanvasGroup.alpha = _originalAlpha;
}
/// <inheritdoc />
protected override void Interpolate(float t)
{
TargetCanvasGroup.alpha = Mathf.Lerp(StartAlpha, EndAlpha, t);
}
#endregion
#region Private Types & Data
private float _originalAlpha;
private Behaviour _targetBehaviour;
#endregion
}
}

View File

@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 534f568b31447414da551d2d841db6a7
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,142 @@
// --------------------------------------------------------------------------------------------------------------------
// <copyright file="UxrColorTween.cs" company="VRMADA">
// Copyright (c) VRMADA, All rights reserved.
// </copyright>
// --------------------------------------------------------------------------------------------------------------------
using System;
using UltimateXR.Animation.Interpolation;
using UltimateXR.Extensions.Unity;
using UltimateXR.Extensions.Unity.Render;
using UnityEngine;
using UnityEngine.UI;
namespace UltimateXR.Animation.UI
{
/// <summary>
/// Tweening component to animate the <see cref="Graphic.color" /> of a <see cref="Graphic" /> component
/// programatically or using the inspector.
/// </summary>
public class UxrColorTween : UxrGraphicTween
{
#region Inspector Properties/Serialized Fields
[SerializeField] private Color _startColor;
[SerializeField] private Color _endColor;
#endregion
#region Public Types & Data
/// <summary>
/// Animation start color
/// </summary>
public Color StartColor
{
get => _startColor;
set => _startColor = value;
}
/// <summary>
/// Animation end color
/// </summary>
public Color EndColor
{
get => _endColor;
set => _endColor = value;
}
#endregion
#region Public Methods
/// <summary>
/// Creates and starts a color tweening animation for the <see cref="Graphic.color" /> of a Unity UI component.
/// </summary>
/// <param name="graphic">Target graphic</param>
/// <param name="startColor">Start color</param>
/// <param name="endColor">End color</param>
/// <param name="settings">Interpolation settings that control the animation</param>
/// <param name="finishedCallback">Optional callback when the animation finished</param>
/// <returns>
/// Tweening component that will update itself automatically. Can be used to stop the animation prematurely or
/// change parameters on the fly.
/// </returns>
public static UxrColorTween Animate(Graphic graphic, Color startColor, Color endColor, UxrInterpolationSettings settings, Action<UxrTween> finishedCallback = null)
{
UxrColorTween colorTween = graphic.GetOrAddComponent<UxrColorTween>();
colorTween.StartColor = startColor;
colorTween.EndColor = endColor;
colorTween.InterpolationSettings = settings;
colorTween.FinishedCallback = finishedCallback;
colorTween.Restart();
return colorTween;
}
/// <summary>
/// Creates and starts an alpha tweening animation for the <see cref="Graphic.color" /> of a Unity UI component.
/// </summary>
/// <param name="graphic">Target graphic</param>
/// <param name="startAlpha">Start alpha</param>
/// <param name="endAlpha">End alpha</param>
/// <param name="settings">Interpolation settings that control the animation</param>
/// <param name="finishedCallback">Optional callback when the animation finished</param>
/// <returns>
/// Tweening component that will update itself automatically. Can be used to stop the animation prematurely or
/// change parameters on the fly.
/// </returns>
public static UxrColorTween AnimateAlpha(Graphic graphic, float startAlpha, float endAlpha, UxrInterpolationSettings settings, Action<UxrTween> finishedCallback = null)
{
return Animate(graphic, graphic.color.WithAlpha(startAlpha), graphic.color.WithAlpha(endAlpha), settings, finishedCallback);
}
/// <summary>
/// Creates and starts an alpha blinking tweening animation for the <see cref="Graphic.color" /> of a Unity UI
/// component.
/// </summary>
/// <param name="graphic">Target graphic</param>
/// <param name="blinksPerSecond">Number of blinks per second</param>
/// <param name="durationSeconds">Total duration of the animation in seconds</param>
/// <param name="restoreWhenFinished">Whether to restore the original color after the animation finished</param>
/// <param name="finishedCallback">Optional callback when the animation finished</param>
/// <param name="delaySeconds"></param>
/// <returns>
/// Tweening component that will update itself automatically. Can be used to stop the animation prematurely or
/// change parameters on the fly.
/// </returns>
public static UxrColorTween AnimateBlinkAlpha(Graphic graphic, float blinksPerSecond, float durationSeconds, float delaySeconds = 0.0f, float maxAlpha = 1.0f, float minAlpha = 0.0f, bool restoreWhenFinished = true, Action<UxrTween> finishedCallback = null)
{
return Animate(graphic,
graphic.color.WithAlpha(maxAlpha),
graphic.color.WithAlpha(minAlpha),
new UxrInterpolationSettings(1.0f / (blinksPerSecond * 2.0f), delaySeconds, UxrEasing.Linear, UxrLoopMode.PingPong, durationSeconds),
t =>
{
if (restoreWhenFinished && t is UxrColorTween colorTween)
{
colorTween.RestoreOriginalValue();
}
finishedCallback?.Invoke(t);
});
}
#endregion
#region Protected Overrides UxrTween
/// <inheritdoc />
protected override void RestoreOriginalValue()
{
RestoreColor();
}
/// <inheritdoc />
protected override void Interpolate(float t)
{
TargetGraphic.color = Color.Lerp(StartColor, EndColor, t);
}
#endregion
}
}

View File

@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 734971c637779324a8f17702f0de4693
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,98 @@
// --------------------------------------------------------------------------------------------------------------------
// <copyright file="UxrGraphicTween.cs" company="VRMADA">
// Copyright (c) VRMADA, All rights reserved.
// </copyright>
// --------------------------------------------------------------------------------------------------------------------
using UnityEngine;
using UnityEngine.UI;
namespace UltimateXR.Animation.UI
{
/// <summary>
/// Abstract base class for tweening animations on Unity <see cref="Graphic" /> components.
/// </summary>
[RequireComponent(typeof(Graphic))]
[DisallowMultipleComponent]
public abstract class UxrGraphicTween : UxrTween
{
#region Public Types & Data
public Graphic TargetGraphic => GetCachedComponent<Graphic>();
public RectTransform TargetRectTransform => GetCachedComponent<RectTransform>();
#endregion
#region Protected Overrides UxrTween
/// <inheritdoc />
protected override Behaviour TargetBehaviour => TargetGraphic;
/// <inheritdoc />
protected override void StoreOriginalValue()
{
_originalAnchoredPosition = TargetRectTransform.anchoredPosition;
_originalLocalScale = TargetRectTransform.localScale;
_originalLocalRotation = TargetRectTransform.localRotation;
_originalColor = TargetGraphic.color;
}
#endregion
#region Protected Methods
/// <summary>
/// Restores the original Graphic's anchored position.
/// </summary>
protected void RestoreAnchoredPosition()
{
if (HasOriginalValueStored)
{
TargetRectTransform.anchoredPosition = _originalAnchoredPosition;
}
}
/// <summary>
/// Restores the original Graphic's local scale.
/// </summary>
protected void RestoreLocalScale()
{
if (HasOriginalValueStored)
{
TargetRectTransform.localScale = _originalLocalScale;
}
}
/// <summary>
/// Restores the original Graphic's local rotation.
/// </summary>
protected void RestoreLocalRotation()
{
if (HasOriginalValueStored)
{
TargetRectTransform.localRotation = _originalLocalRotation;
}
}
/// <summary>
/// Restores the original Graphic's color.
/// </summary>
protected void RestoreColor()
{
if (HasOriginalValueStored)
{
TargetGraphic.color = _originalColor;
}
}
#endregion
#region Private Types & Data
private Vector2 _originalAnchoredPosition;
private Vector3 _originalLocalScale;
private Quaternion _originalLocalRotation;
private Color _originalColor;
#endregion
}
}

View File

@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 14602783b072d0145acbf35dac1db19e
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,117 @@
// --------------------------------------------------------------------------------------------------------------------
// <copyright file="UxrImageFillTween.cs" company="VRMADA">
// Copyright (c) VRMADA, All rights reserved.
// </copyright>
// --------------------------------------------------------------------------------------------------------------------
using System;
using UltimateXR.Animation.Interpolation;
using UltimateXR.Extensions.Unity;
using UnityEngine;
using UnityEngine.UI;
namespace UltimateXR.Animation.UI
{
/// <summary>
/// Tweening component to animate the <see cref="Image.fillAmount" /> of an an <see cref="Image" /> component
/// programatically or using the inspector.
/// </summary>
[RequireComponent(typeof(Image))]
public class UxrImageFillTween : UxrGraphicTween
{
#region Inspector Properties/Serialized Fields
[SerializeField] private float _startFillAmount;
[SerializeField] private float _endFillAmount;
#endregion
#region Public Types & Data
public Image TargetImage => GetCachedComponent<Image>();
/// <summary>
/// Animation start fill amount
/// </summary>
public float StartFillAmount
{
get => _startFillAmount;
set => _startFillAmount = value;
}
/// <summary>
/// Animation end fill amount
/// </summary>
public float EndFillAmount
{
get => _endFillAmount;
set => _endFillAmount = value;
}
#endregion
#region Public Methods
/// <summary>
/// Creates and starts a tweening animation for the <see cref="Image.fillAmount" /> value in an <see cref="Image" />
/// component.
/// </summary>
/// <param name="image">Target image</param>
/// <param name="startFillAmount">Start fill amount</param>
/// <param name="endFillAmount">End fill amount</param>
/// <param name="settings">Interpolation settings that control the animation</param>
/// <param name="finishedCallback">Optional callback when the animation finished</param>
/// <returns>
/// Tweening component that will update itself automatically. Can be used to stop the animation prematurely or
/// change parameters on the fly.
/// </returns>
public static UxrImageFillTween Animate(Image image, float startFillAmount, float endFillAmount, UxrInterpolationSettings settings, Action<UxrTween> finishedCallback = null)
{
UxrImageFillTween imageFillTween = image.GetOrAddComponent<UxrImageFillTween>();
imageFillTween.StartFillAmount = startFillAmount;
imageFillTween.EndFillAmount = endFillAmount;
imageFillTween.InterpolationSettings = settings;
imageFillTween.FinishedCallback = finishedCallback;
imageFillTween.Restart();
return imageFillTween;
}
#endregion
#region Protected Overrides UxrGraphicTween
/// <inheritdoc />
protected override void StoreOriginalValue()
{
_originalFillAmount = TargetImage.fillAmount;
}
#endregion
#region Protected Overrides UxrTween
/// <inheritdoc />
protected override void RestoreOriginalValue()
{
if (HasOriginalValueStored)
{
TargetImage.fillAmount = _originalFillAmount;
}
}
/// <inheritdoc />
protected override void Interpolate(float t)
{
TargetImage.fillAmount = Mathf.Lerp(StartFillAmount, EndFillAmount, t);
}
#endregion
#region Private Types & Data
private float _originalFillAmount;
#endregion
}
}

View File

@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: fca480389dfb0e24c8e1e945da2a33d2
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,150 @@
// --------------------------------------------------------------------------------------------------------------------
// <copyright file="UxrPositionTween.cs" company="VRMADA">
// Copyright (c) VRMADA, All rights reserved.
// </copyright>
// --------------------------------------------------------------------------------------------------------------------
using System;
using UltimateXR.Animation.Interpolation;
using UltimateXR.Extensions.Unity;
using UnityEngine;
using UnityEngine.UI;
namespace UltimateXR.Animation.UI
{
/// <summary>
/// Tweening component to animate <see cref="RectTransform.anchoredPosition" /> programatically or using the inspector.
/// </summary>
public class UxrPositionTween : UxrGraphicTween
{
#region Inspector Properties/Serialized Fields
[SerializeField] private Vector2 _startPosition;
[SerializeField] private Vector2 _endPosition;
#endregion
#region Public Types & Data
/// <summary>
/// Animation start position
/// </summary>
public Vector2 StartPosition
{
get => _startPosition;
set => _startPosition = value;
}
/// <summary>
/// Animation end position
/// </summary>
public Vector2 EndPosition
{
get => _endPosition;
set => _endPosition = value;
}
#endregion
#region Public Methods
/// <summary>
/// Creates and starts a position tweening animation for the <see cref="RectTransform.anchoredPosition" /> of a Unity
/// UI <see cref="Graphic" /> component.
/// </summary>
/// <param name="graphic">Target graphic</param>
/// <param name="startPosition">Start position</param>
/// <param name="endPosition">End position</param>
/// <param name="settings">Interpolation settings that control the animation</param>
/// <param name="finishedCallback">Optional callback when the animation finished</param>
/// <returns>
/// Tweening component that will update itself automatically. Can be used to stop the animation prematurely or
/// change parameters on the fly.
/// </returns>
public static UxrPositionTween Animate(Graphic graphic, Vector2 startPosition, Vector2 endPosition, UxrInterpolationSettings settings, Action<UxrTween> finishedCallback = null)
{
UxrPositionTween positionTween = graphic.GetOrAddComponent<UxrPositionTween>();
positionTween.StartPosition = startPosition;
positionTween.EndPosition = endPosition;
positionTween.InterpolationSettings = settings;
positionTween.FinishedCallback = finishedCallback;
positionTween.Restart();
return positionTween;
}
/// <summary>
/// Creates and starts a position tweening animation for the <see cref="RectTransform.anchoredPosition" /> of a Unity
/// UI <see cref="Graphic" /> component. The animation will start using an offset with respect to the initial graphic
/// position and will end in the initial graphic position.
/// </summary>
/// <param name="graphic">Target graphic</param>
/// <param name="horizontalOffset">Horizontal offset to the initial x position where the animation will start.</param>
/// <param name="verticalOffset">Vertical offset to the initial y position where the animation will start.</param>
/// <param name="settings">Interpolation settings that control the animation</param>
/// <param name="finishedCallback">Optional callback when the animation finished</param>
/// <returns>
/// Tweening component that will update itself automatically. Can be used to stop the animation prematurely or
/// change parameters on the fly.
/// </returns>
public static UxrPositionTween MoveIn(Graphic graphic, float horizontalOffset, float verticalOffset, UxrInterpolationSettings settings, Action<UxrTween> finishedCallback = null)
{
UxrPositionTween positionTween = graphic.GetOrAddComponent<UxrPositionTween>();
positionTween.RestoreOriginalValue();
positionTween.StartPosition = positionTween.TargetRectTransform.anchoredPosition + new Vector2(horizontalOffset, verticalOffset);
positionTween.EndPosition = positionTween.TargetRectTransform.anchoredPosition;
positionTween.InterpolationSettings = settings;
positionTween.FinishedCallback = finishedCallback;
positionTween.Restart();
return positionTween;
}
/// <summary>
/// Creates and starts a position tweening animation for the <see cref="RectTransform.anchoredPosition" /> of a Unity
/// UI <see cref="Graphic" /> component. The animation will start in the initial graphic position and end with an
/// offset with respect to the initial graphic position.
/// </summary>
/// <param name="graphic">Target graphic</param>
/// <param name="horizontalOffset">Horizontal offset to the initial x position where the animation will end.</param>
/// <param name="verticalOffset">Vertical offset to the initial y position where the animation will end.</param>
/// <param name="settings">Interpolation settings that control the animation</param>
/// <param name="finishedCallback">Optional callback when the animation finished</param>
/// <returns>
/// Tweening component that will update itself automatically. Can be used to stop the animation prematurely or
/// change parameters on the fly.
/// </returns>
public static UxrPositionTween MoveOut(Graphic graphic, float horizontalOffset, float verticalOffset, UxrInterpolationSettings settings, Action<UxrTween> finishedCallback = null)
{
UxrPositionTween positionTween = graphic.GetOrAddComponent<UxrPositionTween>();
positionTween.RestoreOriginalValue();
positionTween.StartPosition = positionTween.TargetRectTransform.anchoredPosition;
positionTween.EndPosition = positionTween.TargetRectTransform.anchoredPosition + new Vector2(horizontalOffset, verticalOffset);
positionTween.InterpolationSettings = settings;
positionTween.FinishedCallback = finishedCallback;
positionTween.Restart();
return positionTween;
}
#endregion
#region Protected Overrides UxrTween
/// <inheritdoc />
protected override void RestoreOriginalValue()
{
RestoreAnchoredPosition();
}
/// <inheritdoc />
protected override void Interpolate(float t)
{
TargetRectTransform.anchoredPosition = Vector2.Lerp(StartPosition, EndPosition, t);
}
#endregion
}
}

View File

@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 918219acf586d43478bb0af8760a13a2
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,94 @@
// --------------------------------------------------------------------------------------------------------------------
// <copyright file="UxrRotationTween.cs" company="VRMADA">
// Copyright (c) VRMADA, All rights reserved.
// </copyright>
// --------------------------------------------------------------------------------------------------------------------
using System;
using UltimateXR.Animation.Interpolation;
using UltimateXR.Extensions.Unity;
using UnityEngine;
using UnityEngine.UI;
namespace UltimateXR.Animation.UI
{
/// <summary>
/// Tweening component to animate <see cref="RectTransform.localRotation" /> programatically or using the inspector.
/// </summary>
public class UxrRotationTween : UxrGraphicTween
{
#region Inspector Properties/Serialized Fields
[SerializeField] private Vector3 _startAngles;
[SerializeField] private Vector3 _endAngles;
#endregion
#region Public Types & Data
/// <summary>
/// The start local Euler angles in the rotation animation.
/// </summary>
public Vector3 StartAngles
{
get => _startAngles;
set => _startAngles = value;
}
/// <summary>
/// The end local Euler angles in the rotation animation.
/// </summary>
public Vector3 EndAngles
{
get => _endAngles;
set => _endAngles = value;
}
#endregion
#region Public Methods
/// <summary>
/// Creates and starts a rotation tweening animation for the <see cref="RectTransform.localEulerAngles" /> of a Unity
/// UI <see cref="Graphic" /> component.
/// </summary>
/// <param name="graphic">Target graphic</param>
/// <param name="startAngles">Start local angles</param>
/// <param name="endAngles">End local angles</param>
/// <param name="settings">Interpolation settings that control the animation</param>
/// <param name="finishedCallback">Optional callback when the animation finished</param>
/// <returns>
/// Tweening component that will update itself automatically. Can be used to stop the animation prematurely or
/// change parameters on the fly.
/// </returns>
public static UxrRotationTween Animate(Graphic graphic, Vector3 startAngles, Vector3 endAngles, UxrInterpolationSettings settings, Action<UxrTween> finishedCallback = null)
{
UxrRotationTween rotationTween = graphic.GetOrAddComponent<UxrRotationTween>();
rotationTween.StartAngles = startAngles;
rotationTween.EndAngles = endAngles;
rotationTween.InterpolationSettings = settings;
rotationTween.FinishedCallback = finishedCallback;
rotationTween.Restart();
return rotationTween;
}
#endregion
#region Protected Overrides UxrTween
/// <inheritdoc />
protected override void RestoreOriginalValue()
{
RestoreLocalRotation();
}
/// <inheritdoc />
protected override void Interpolate(float t)
{
TargetRectTransform.localEulerAngles = Vector3.Lerp(StartAngles, EndAngles, t);
}
#endregion
}
}

View File

@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 8690e0c36b900b74aa5ddf325f8de528
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,94 @@
// --------------------------------------------------------------------------------------------------------------------
// <copyright file="UxrScaleTween.cs" company="VRMADA">
// Copyright (c) VRMADA, All rights reserved.
// </copyright>
// --------------------------------------------------------------------------------------------------------------------
using System;
using UltimateXR.Animation.Interpolation;
using UltimateXR.Extensions.Unity;
using UnityEngine;
using UnityEngine.UI;
namespace UltimateXR.Animation.UI
{
/// <summary>
/// Tweening component to animate <see cref="RectTransform.localScale" /> programatically or using the inspector.
/// </summary>
public class UxrScaleTween : UxrGraphicTween
{
#region Inspector Properties/Serialized Fields
[SerializeField] private Vector3 _startScale;
[SerializeField] private Vector3 _endScale;
#endregion
#region Public Types & Data
/// <summary>
/// Animation start scale
/// </summary>
public Vector3 StartScale
{
get => _startScale;
set => _startScale = value;
}
/// <summary>
/// Animation end scale
/// </summary>
public Vector3 EndScale
{
get => _endScale;
set => _endScale = value;
}
#endregion
#region Public Methods
/// <summary>
/// Creates and starts a scale tweening animation for the <see cref="RectTransform.localScale" /> of a Unity
/// UI <see cref="Graphic" /> component.
/// </summary>
/// <param name="graphic">Target graphic</param>
/// <param name="startScale">Start local scale</param>
/// <param name="endScale">End local scale</param>
/// <param name="settings">Interpolation settings that control the animation</param>
/// <param name="finishedCallback">Optional callback when the animation finished</param>
/// <returns>
/// Tweening component that will update itself automatically. Can be used to stop the animation prematurely or
/// change parameters on the fly.
/// </returns>
public static UxrScaleTween Animate(Graphic graphic, Vector3 startScale, Vector3 endScale, UxrInterpolationSettings settings, Action<UxrTween> finishedCallback = null)
{
UxrScaleTween scaleTween = graphic.GetOrAddComponent<UxrScaleTween>();
scaleTween.StartScale = startScale;
scaleTween.EndScale = endScale;
scaleTween.InterpolationSettings = settings;
scaleTween.FinishedCallback = finishedCallback;
scaleTween.Restart();
return scaleTween;
}
#endregion
#region Protected Overrides UxrTween
/// <inheritdoc />
protected override void RestoreOriginalValue()
{
RestoreLocalScale();
}
/// <inheritdoc />
protected override void Interpolate(float t)
{
TargetRectTransform.localScale = Vector2.Lerp(StartScale, EndScale, t);
}
#endregion
}
}

View File

@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 8aeb025b7257c3142b9e1e8e4d0aaf94
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,268 @@
// --------------------------------------------------------------------------------------------------------------------
// <copyright file="UxrTextContentTween.cs" company="VRMADA">
// Copyright (c) VRMADA, All rights reserved.
// </copyright>
// --------------------------------------------------------------------------------------------------------------------
using System;
using System.Collections.Generic;
using System.Linq;
using UltimateXR.Animation.Interpolation;
using UltimateXR.Extensions.Unity;
using UnityEngine;
using UnityEngine.UI;
#if ULTIMATEXR_UNITY_TMPRO
using TMPro;
#endif
namespace UltimateXR.Animation.UI
{
/// <summary>
/// Tweening component to animate a UI text component programatically or using the inspector. Supports both Unity's
/// Text and TMPro.
/// The text interpolation can be used to create a typewriter kind of effect.
/// Programatically it also offers the possibility to interpolate parameters in a text string.
/// </summary>
[DisallowMultipleComponent]
public class UxrTextContentTween : UxrTween
{
#region Inspector Properties/Serialized Fields
[SerializeField] private string _startText;
[SerializeField] private string _endText;
#endregion
#region Public Types & Data
/// <summary>
/// Gets the <see cref="UnityEngine.UI.Text" /> component whose string will be interpolated.
/// </summary>
public Text TargetText => GetCachedComponent<Text>();
#if ULTIMATEXR_UNITY_TMPRO
/// <summary>
/// Gets the <see cref="TextMeshProUGUI" /> component whose string will be interpolated.
/// </summary>
public TextMeshProUGUI TargetTextTMPro => GetCachedComponent<TextMeshProUGUI>();
#endif
/// <summary>
/// Gets or sets the text value.
/// </summary>
public string Text
{
get
{
if (TargetText != null)
{
return TargetText.text;
}
#if ULTIMATEXR_UNITY_TMPRO
if (TargetTextTMPro != null)
{
return TargetTextTMPro.text;
}
#endif
return null;
}
set
{
if (TargetText != null)
{
TargetText.text = value;
}
#if ULTIMATEXR_UNITY_TMPRO
if (TargetTextTMPro != null)
{
TargetTextTMPro.text = value;
}
#endif
}
}
/// <summary>
/// Gets whether the interpolation uses format string parameters.
/// <list type="bullet">
/// <item>
/// false: Interpolation will be a plain typewriter effect from <see cref="StartText" /> to
/// <see cref="EndText" />
/// </item>
/// <item>
/// true: Interpolation will use <see cref="FormatString" /> and <see cref="FormatStringArgs" />. For more
/// information on how these are used see
/// <see cref="UxrInterpolator.InterpolateText(float,bool,string,object[])">UxrInterpolator.InterpolateText</see>
/// </item>
/// </list>
/// </summary>
public bool UsesFormatString { get; private set; }
/// <summary>
/// Animation start text
/// </summary>
public string StartText
{
get => _startText;
set => _startText = value;
}
/// <summary>
/// Animation end text
/// </summary>
public string EndText
{
get => _endText;
set => _endText = value;
}
/// <summary>
/// Animation format string, when <see cref="UsesFormatString" /> is true.
/// </summary>
public string FormatString { get; set; }
/// <summary>
/// Animation format string parameter list, when <see cref="UsesFormatString" /> is true.
/// </summary>
public List<object> FormatStringArgs { get; set; }
#endregion
#region Public Methods
/// <summary>
/// Creates and starts a tweening animation for a Unity UI Text component or TMPro text component.
/// </summary>
/// <param name="gameObject">Target GameObject with either a Unity UI Text component or Text Mesh Pro text component</param>
/// <param name="startText">Start text</param>
/// <param name="endText">End text</param>
/// <param name="settings">Interpolation settings that control the animation</param>
/// <param name="finishedCallback">Optional callback when the animation finished</param>
/// <returns>
/// Tweening component that will update itself automatically. Can be used to stop the animation prematurely or
/// change parameters on the fly.
/// </returns>
public static UxrTextContentTween Animate(GameObject gameObject, string startText, string endText, UxrInterpolationSettings settings, Action<UxrTween> finishedCallback = null)
{
UxrTextContentTween textContentTween = gameObject.GetOrAddComponent<UxrTextContentTween>();
textContentTween.UsesFormatString = false;
textContentTween.StartText = startText;
textContentTween.EndText = endText;
textContentTween.InterpolationSettings = settings;
textContentTween.FinishedCallback = finishedCallback;
textContentTween.Restart();
return textContentTween;
}
/// <summary>
/// Creates and starts a tweening animation for a Unity UI Text component or TMPro text component. See
/// <see cref="UxrInterpolator.InterpolateText(float,bool,string,object[])">UxrInterpolator.InterpolateText</see> for
/// information on how <paramref name="formatString" /> and <paramref name="formatStringArgs" /> work.
/// </summary>
/// <param name="gameObject">Target GameObject with either a Unity UI Text component or Text Mesh Pro text component</param>
/// <param name="settings">Interpolation settings that control the animation</param>
/// <param name="finishedCallback">Optional callback when the animation finished. Use null to ignore.</param>
/// <param name="formatString">
/// Format string. See
/// <see cref="UxrInterpolator.InterpolateText(float,bool,string,object[])">UxrInterpolator.InterpolateText</see>
/// </param>
/// <param name="formatStringArgs">
/// Format string arguments. See
/// <see cref="UxrInterpolator.InterpolateText(float,bool,string,object[])">UxrInterpolator.InterpolateText</see>
/// </param>
/// <returns>
/// Tweening component that will update itself automatically. Can be used to stop the animation prematurely or
/// change parameters on the fly.
/// </returns>
public static UxrTextContentTween Animate(GameObject gameObject, UxrInterpolationSettings settings, Action<UxrTween> finishedCallback, string formatString, object[] formatStringArgs)
{
UxrTextContentTween textContentTween = gameObject.GetOrAddComponent<UxrTextContentTween>();
textContentTween.UsesFormatString = true;
textContentTween.InterpolationSettings = settings;
textContentTween.FinishedCallback = finishedCallback;
textContentTween.FormatString = formatString;
textContentTween.FormatStringArgs = formatStringArgs.ToList();
textContentTween.Restart();
return textContentTween;
}
#endregion
#region Protected Overrides UxrTween
/// <inheritdoc />
protected override Behaviour TargetBehaviour
{
get
{
if (TargetText != null)
{
return TargetText;
}
#if ULTIMATEXR_UNITY_TMPRO
if (TargetTextTMPro != null)
{
return TargetTextTMPro;
}
#endif
return null;
}
}
/// <inheritdoc />
protected override void StoreOriginalValue()
{
_originalText = Text;
}
/// <inheritdoc />
protected override void RestoreOriginalValue()
{
if (HasOriginalValueStored)
{
Text = _originalText;
}
}
/// <inheritdoc />
protected override void Interpolate(float t)
{
if (StartText == null || EndText == null)
{
return;
}
if (!UsesFormatString)
{
Text = UxrInterpolator.InterpolateText(StartText, EndText, t, true);
}
else
{
Text = UxrInterpolator.InterpolateText(t, true, FormatString, FormatStringArgs);
}
}
#endregion
#region Private Types & Data
private string _originalText;
#endregion
}
}

View File

@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 8bb2b7d51ef72974d85d2f9725e1c221
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,355 @@
// --------------------------------------------------------------------------------------------------------------------
// <copyright file="UxrTween.cs" company="VRMADA">
// Copyright (c) VRMADA, All rights reserved.
// </copyright>
// --------------------------------------------------------------------------------------------------------------------
using System;
using System.Linq;
using UltimateXR.Animation.Interpolation;
using UltimateXR.Attributes;
using UltimateXR.Core.Components;
using UltimateXR.Extensions.System.Collections;
using UnityEngine;
namespace UltimateXR.Animation.UI
{
/// <summary>
/// <para>
/// Base abstract class to create tweening components to animate Unity UI elements.
/// </para>
/// <para>
/// Tweens are <see cref="UxrComponent" /> components to allow access to the global list of tweens
/// or filter by type.
/// </para>
/// <para>
/// They are also <see cref="UxrComponent{TP,TC}" /> to allow access to the global list of tweens in a
/// given parent canvas.
/// </para>
/// </summary>
public abstract class UxrTween : UxrComponent<Canvas, UxrTween>
{
#region Inspector Properties/Serialized Fields
[SerializeField] [ReadOnly(HideInEditMode = true)] private bool _hasFinished;
[SerializeField] private UxrInterpolationSettings _interpolationSettings = new UxrInterpolationSettings();
[SerializeField] private UxrTweenFinishedActions _finishedActions = UxrTweenFinishedActions.None;
#endregion
#region Public Types & Data
/// <summary>
/// Called when the animation finished.
/// </summary>
public event Action Finished;
/// <summary>
/// Gets the current animation time in seconds. The animation time is the scaled or unscaled time relative to the time
/// the component was enabled.
/// </summary>
public float AnimationTime => CurrentTime - _startTime;
/// <summary>
/// Gets or sets the interpolation settings.
/// </summary>
public UxrInterpolationSettings InterpolationSettings
{
get => _interpolationSettings;
protected set => _interpolationSettings = value;
}
/// <summary>
/// Gets whether the animation finished.
/// </summary>
public bool HasFinished
{
get => _hasFinished;
private set => _hasFinished = value;
}
#endregion
#region Public Methods
/// <summary>
/// Checks if the given behaviour has a running tween of any type.
/// </summary>
/// <returns>Whether there is a running tween animation.</returns>
public static bool HasActiveTween(Behaviour behaviour)
{
UxrTween[] tweens = behaviour.GetComponents<UxrTween>();
return tweens.Length > 0 && tweens.Any(t => !t.HasFinished);
}
/// <summary>
/// Checks if the given behaviour has a running tween of a specific type.
/// </summary>
/// <typeparam name="T">Type of <see cref="UxrTween" />s to check for.</typeparam>
/// <returns>Whether there is a running animation of the given type.</returns>
public static bool HasActiveTween<T>(Behaviour behaviour) where T : UxrTween
{
T tween = behaviour.GetComponent<T>();
return tween && !tween.HasFinished;
}
/// <summary>
/// Stops all enabled tweens.
/// </summary>
/// <param name="restoreOriginal">Whether to reset each animated component to the state before its animation started</param>
public static void StopAll(bool restoreOriginal = true)
{
EnabledComponents.ForEach(t => t.Stop(restoreOriginal));
}
/// <summary>
/// Stops all enabled tweens of a given type.
/// </summary>
/// <param name="restoreOriginal">Whether to reset each animated component to the state before its animation started</param>
/// <typeparam name="T">Type of <see cref="UxrTween" />s to stop</typeparam>
public static void StopAll<T>(bool restoreOriginal = true) where T : UxrTween
{
EnabledComponents.OfType<T>().ForEach(t => t.Stop(restoreOriginal));
}
/// <summary>
/// Stops all enabled tweens that are in a given canvas.
/// </summary>
/// <param name="canvas">Canvas to disable all enabled tweens from</param>
/// <param name="restoreOriginal">Whether to reset each animated component to the state before its animation started</param>
public static void StopAllInParentCanvas(Canvas canvas, bool restoreOriginal = true)
{
GetParentChildren(canvas).ForEach(t => t.Stop(restoreOriginal));
}
/// <summary>
/// Stops all enabled tweens of a given type that are in a given canvas.
/// </summary>
/// <param name="restoreOriginal">Whether to reset each animated component to the state before its animation started</param>
/// <param name="canvas">Canvas to disable all enabled tweens from</param>
/// <typeparam name="T">Type of <see cref="UxrTween" />s to stop</typeparam>
public static void StopAllInParentCanvas<T>(Canvas canvas, bool restoreOriginal = true) where T : UxrTween
{
GetParentChildren(canvas).OfType<T>().ForEach(t => t.Stop(restoreOriginal));
}
/// <summary>
/// Stops all the tweening components of a <see cref="Behaviour" />.
/// </summary>
/// <param name="behaviour"><see cref="Behaviour" /> whose tweens to stop</param>
/// <param name="restoreOriginal">Whether to reset each animated component to the state before its animation started</param>
public static void StopAll(Behaviour behaviour, bool restoreOriginal = true)
{
foreach (UxrTween tween in behaviour.gameObject.GetComponents<UxrTween>())
{
tween.Stop(restoreOriginal);
}
}
/// <summary>
/// Stops the tweening animation on an object if it has a <typeparamref name="T" /> component currently added.
/// </summary>
/// <param name="behaviour">UI Component whose GameObject has the tween added</param>
/// <param name="restoreOriginal">Whether to reset the animated component to the state before the animation started</param>
/// <typeparam name="T">Type of <see cref="UxrTween" /> to stop</typeparam>
public static void Stop<T>(Behaviour behaviour, bool restoreOriginal = true) where T : UxrTween
{
T tween = behaviour.GetComponent<T>();
if (tween)
{
tween.Stop(restoreOriginal);
}
}
/// <summary>
/// Stops the tweening animation.
/// </summary>
/// <param name="restoreOriginal">Whether to reset the animated component to the state before the animation started</param>
public void Stop(bool restoreOriginal = true)
{
HasFinished = true;
if (restoreOriginal)
{
RestoreOriginalValue();
}
}
/// <summary>
/// Sets the actions to perform when the animation finished.
/// </summary>
/// <param name="actions">Action flags</param>
/// <returns>The <see cref="UxrTween" /> component to concatenate additional calls if desired.</returns>
public UxrTween SetFinishedActions(UxrTweenFinishedActions actions)
{
_finishedActions = actions;
return this;
}
#endregion
#region Unity
/// <summary>
/// Stores the start time each time the component is enabled.
/// </summary>
protected override void OnEnable()
{
base.OnEnable();
_startTime = CurrentTime;
if (!HasOriginalValueStored)
{
HasOriginalValueStored = true;
StoreOriginalValue();
}
if (InterpolationSettings != null)
{
Interpolate(InterpolationSettings.GetInterpolationFactor(0.0f));
}
HasFinished = false;
}
/// <summary>
/// Updates the interpolation.
/// </summary>
private void Update()
{
if (HasFinished || InterpolationSettings == null)
{
return;
}
Interpolate(InterpolationSettings.GetInterpolationFactor(AnimationTime));
if (InterpolationSettings.CheckInterpolationHasFinished(AnimationTime))
{
Interpolate(1.0f);
HasFinished = true;
OnFinished();
}
}
#endregion
#region Event Trigger Methods
/// <summary>
/// Event trigger for the <see cref="Finished" /> event.
/// </summary>
protected virtual void OnFinished()
{
Finished?.Invoke();
FinishedCallback?.Invoke(this);
if (_finishedActions.HasFlag(UxrTweenFinishedActions.RestoreOriginalValue))
{
RestoreOriginalValue();
}
if (_finishedActions.HasFlag(UxrTweenFinishedActions.DisableTargetComponent) && TargetBehaviour)
{
TargetBehaviour.enabled = false;
}
if (_finishedActions.HasFlag(UxrTweenFinishedActions.DeactivateGameObject) && TargetBehaviour && TargetBehaviour.gameObject)
{
TargetBehaviour.gameObject.SetActive(false);
}
if (_finishedActions.HasFlag(UxrTweenFinishedActions.DestroyTween))
{
Destroy(this);
}
if (_finishedActions.HasFlag(UxrTweenFinishedActions.DestroyTargetComponent) && TargetBehaviour)
{
Destroy(TargetBehaviour);
}
if (_finishedActions.HasFlag(UxrTweenFinishedActions.DestroyGameObject))
{
Destroy(gameObject);
}
}
#endregion
#region Protected Methods
/// <summary>
/// Restores the animated component to the state before the animation started.
/// </summary>
protected abstract void RestoreOriginalValue();
/// <summary>
/// Stores the original value before the animation, in order to be able to restore it later using
/// <see cref="RestoreOriginalValue" />.
/// </summary>
protected abstract void StoreOriginalValue();
/// <summary>
/// Interpolates and assigns the value corresponding to the given LERP value.
/// </summary>
/// <param name="t">LERP interpolation t value [0.0, 1.0]</param>
protected abstract void Interpolate(float t);
/// <summary>
/// Restarts the animation with the current parameters.
/// It also forces the execution of the first frame.
/// </summary>
protected void Restart()
{
if (InterpolationSettings != null)
{
_startTime = CurrentTime;
_finishedActions = UxrTweenFinishedActions.None;
HasFinished = false;
Interpolate(InterpolationSettings.GetInterpolationFactor(0.0f));
}
}
#endregion
#region Protected Types & Data
/// <summary>
/// Gets the <see cref="Behaviour" /> the tween animates.
/// </summary>
protected abstract Behaviour TargetBehaviour { get; }
/// <summary>
/// Gets if the tween has gathered the original animated parameter value.
/// </summary>
protected bool HasOriginalValueStored { get; private set; }
/// <summary>
/// Optional finished callback assigned by child classes.
/// </summary>
protected Action<UxrTween> FinishedCallback { get; set; }
#endregion
#region Private Types & Data
/// <summary>
/// Gets the current time in seconds. It computes the correct time, either <see cref="Time.unscaledTime" /> or
/// <see cref="Time.time" />, depending on the animation configuration.
/// </summary>
private float CurrentTime
{
get
{
if (InterpolationSettings != null)
{
return InterpolationSettings.UseUnscaledTime ? Time.unscaledTime : Time.time;
}
return Time.time;
}
}
private float _startTime;
#endregion
}
}

View File

@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 3333050faee415e4fa77f2889a427b2e
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,52 @@
// --------------------------------------------------------------------------------------------------------------------
// <copyright file="UxrTweenFinishedActions.cs" company="VRMADA">
// Copyright (c) VRMADA, All rights reserved.
// </copyright>
// --------------------------------------------------------------------------------------------------------------------
using System;
using UnityEngine;
namespace UltimateXR.Animation.UI
{
/// <summary>
/// Different actions that can be executed once a <see cref="UxrTween" /> animation finished.
/// </summary>
[Flags]
public enum UxrTweenFinishedActions
{
/// <summary>
/// No action.
/// </summary>
None = 0,
/// <summary>
/// Restores the original animated value that the component had before the animation.
/// </summary>
RestoreOriginalValue = 1 << 0,
/// <summary>
/// Disable the component that the <see cref="UxrTween" /> is animating.
/// </summary>
DisableTargetComponent = 1 << 1,
/// <summary>
/// Deactivate the <see cref="GameObject" /> where the component is located.
/// </summary>
DeactivateGameObject = 1 << 2,
/// <summary>
/// Destroy the <see cref="UxrTween" /> component.
/// </summary>
DestroyTween = 1 << 3,
/// <summary>
/// Destroy the component that the tween is animating.
/// </summary>
DestroyTargetComponent = 1 << 4,
/// <summary>
/// Destroy the <see cref="GameObject" /> where the component is located.
/// </summary>
DestroyGameObject = 1 << 5
}
}

View File

@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 6c142bdad0223a64fad3076f29f297f8
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant: