Move third party assets to ThirdParty folder
This commit is contained in:
189
Assets/ThirdParty/UltimateXR/Editor/Animation/Interpolation/UxrEasingDrawer.cs
vendored
Normal file
189
Assets/ThirdParty/UltimateXR/Editor/Animation/Interpolation/UxrEasingDrawer.cs
vendored
Normal file
@@ -0,0 +1,189 @@
|
||||
// --------------------------------------------------------------------------------------------------------------------
|
||||
// <copyright file="UxrEasingDrawer.cs" company="VRMADA">
|
||||
// Copyright (c) VRMADA, All rights reserved.
|
||||
// </copyright>
|
||||
// --------------------------------------------------------------------------------------------------------------------
|
||||
using UltimateXR.Animation.Interpolation;
|
||||
using UltimateXR.Core;
|
||||
using UltimateXR.Extensions.Unity.Render;
|
||||
using UnityEditor;
|
||||
using UnityEngine;
|
||||
|
||||
namespace UltimateXR.Editor.Animation.Interpolation
|
||||
{
|
||||
/// <summary>
|
||||
/// Custom inspector drawer for <see cref="UxrEasing" />.
|
||||
/// </summary>
|
||||
[CustomPropertyDrawer(typeof(UxrEasing))]
|
||||
public class UxrEasingDrawer : PropertyDrawer
|
||||
{
|
||||
#region Public Types & Data
|
||||
|
||||
/// <summary>
|
||||
/// This constant determines the graph height in pixels.
|
||||
/// </summary>
|
||||
public const int GraphHeight = 80;
|
||||
|
||||
#endregion
|
||||
|
||||
#region Constructors & Finalizer
|
||||
|
||||
/// <summary>
|
||||
/// Creates the temporal material to draw the graph.
|
||||
/// </summary>
|
||||
public UxrEasingDrawer()
|
||||
{
|
||||
var shader = Shader.Find(UxrConstants.Shaders.HiddenInternalColoredShader);
|
||||
_lineMaterial = new Material(shader);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Destroys the temporal material to draw the graph.
|
||||
/// </summary>
|
||||
~UxrEasingDrawer()
|
||||
{
|
||||
Object.DestroyImmediate(_lineMaterial);
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Public Overrides PropertyDrawer
|
||||
|
||||
/// <summary>
|
||||
/// Gets the height in pixels required to draw the property.
|
||||
/// </summary>
|
||||
/// <param name="property">Serialized property describing an <see cref="UxrEasing" /></param>
|
||||
/// <param name="label">UI label</param>
|
||||
/// <returns>Height in pixels</returns>
|
||||
public override float GetPropertyHeight(SerializedProperty property, GUIContent label)
|
||||
{
|
||||
return EditorGUIUtility.singleLineHeight + GraphHeight;
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Public Methods
|
||||
|
||||
/// <summary>
|
||||
/// Draws the easing graph.
|
||||
/// </summary>
|
||||
/// <param name="rect">Target rect</param>
|
||||
/// <param name="material">Material used</param>
|
||||
/// <param name="color">The line color</param>
|
||||
/// <param name="easing">The easing used</param>
|
||||
/// <param name="loopMode">The loop mode</param>
|
||||
/// <param name="loops">The number of loops to draw</param>
|
||||
public static void DrawGraph(Rect rect, Material material, Color color, UxrEasing easing, UxrLoopMode loopMode = UxrLoopMode.None, int loops = 1)
|
||||
{
|
||||
// Make coordinates relative to the rect.
|
||||
GUI.BeginClip(rect);
|
||||
|
||||
// Enable the internal material.
|
||||
material.SetPass(0);
|
||||
|
||||
// Draw background. Use alpha to avoid getting too dark.
|
||||
GL.Begin(GL.QUADS);
|
||||
GL.Color(Color.black.WithAlpha(0.4f));
|
||||
GL.Vertex3(0, rect.height, 0);
|
||||
GL.Vertex3(rect.width, rect.height, 0);
|
||||
GL.Vertex3(rect.width, 0, 0);
|
||||
GL.Vertex3(0, 0, 0);
|
||||
GL.End();
|
||||
|
||||
// Now draw the graph as a connected set of points.
|
||||
GL.Begin(GL.LINE_STRIP);
|
||||
GL.Color(color);
|
||||
|
||||
// Get the min/max graph values.
|
||||
// This is important because some interpolation curves go out the [0, 1] range.
|
||||
GetGraphRange(easing, out float min, out float max);
|
||||
|
||||
// Iterate over points and draw vertices.
|
||||
for (int i = 0; i < CurveSegments + 1; ++i)
|
||||
{
|
||||
float t = (float)i / CurveSegments;
|
||||
float value = UxrInterpolator.Interpolate(Vector4.one, Vector4.zero, 1.0f, 0.0f, t * loops, easing, loopMode).x;
|
||||
float valueScaled = Mathf.InverseLerp(min, max, value);
|
||||
GL.Vertex3(t * rect.width, rect.height * valueScaled, 0);
|
||||
}
|
||||
|
||||
GL.End();
|
||||
GUI.EndClip();
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Unity
|
||||
|
||||
/// <summary>
|
||||
/// Draws the inspector and handles input.
|
||||
/// </summary>
|
||||
/// <param name="position">Position where to draw the inspector</param>
|
||||
/// <param name="property">Serialized property to draw</param>
|
||||
/// <param name="label">UI label</param>
|
||||
public override void OnGUI(Rect position, SerializedProperty property, GUIContent label)
|
||||
{
|
||||
// Draw the property label and value
|
||||
EditorGUI.PropertyField(UxrEditorUtils.GetRect(position, 0), property, label);
|
||||
|
||||
// Get the graph rect. Overwrite with graph height in pixels and indentation so that it is drawn below the values only and not taking the whole inspector width.
|
||||
Rect rect = UxrEditorUtils.GetRect(position, 1);
|
||||
rect.height = GraphHeight;
|
||||
rect.xMin += EditorGUIUtility.labelWidth;
|
||||
|
||||
// Get our easing value from the property.
|
||||
UxrEasing easing = (UxrEasing)property.enumValueIndex;
|
||||
|
||||
// Draw the graph!
|
||||
if (Event.current.type == EventType.Repaint)
|
||||
{
|
||||
DrawGraph(rect, _lineMaterial, Color.green, easing);
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Private Methods
|
||||
|
||||
/// <summary>
|
||||
/// Gets the min and max values for a type of interpolation.
|
||||
/// </summary>
|
||||
/// <param name="easing">Easing</param>
|
||||
/// <param name="min">Returns the min graph value</param>
|
||||
/// <param name="max">Returns the max graph value</param>
|
||||
private static void GetGraphRange(UxrEasing easing, out float min, out float max)
|
||||
{
|
||||
min = float.MaxValue;
|
||||
max = float.MinValue;
|
||||
|
||||
for (int i = 0; i < CurveSegments + 1; ++i)
|
||||
{
|
||||
float t = (float)i / CurveSegments;
|
||||
float value = UxrInterpolator.Interpolate(1.0f, 0.0f, t, easing);
|
||||
|
||||
if (value < min)
|
||||
{
|
||||
min = value;
|
||||
}
|
||||
|
||||
if (value > max)
|
||||
{
|
||||
max = value;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Private Types & Data
|
||||
|
||||
/// <summary>
|
||||
/// Determines the amount of segments to draw the graph with.
|
||||
/// </summary>
|
||||
private const int CurveSegments = 200;
|
||||
|
||||
private readonly Material _lineMaterial;
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
11
Assets/ThirdParty/UltimateXR/Editor/Animation/Interpolation/UxrEasingDrawer.cs.meta
vendored
Normal file
11
Assets/ThirdParty/UltimateXR/Editor/Animation/Interpolation/UxrEasingDrawer.cs.meta
vendored
Normal file
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 29edf75ae0a2aee4b88acb8a976dbb6e
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
139
Assets/ThirdParty/UltimateXR/Editor/Animation/Interpolation/UxrInterpolationSettingsDrawer.cs
vendored
Normal file
139
Assets/ThirdParty/UltimateXR/Editor/Animation/Interpolation/UxrInterpolationSettingsDrawer.cs
vendored
Normal file
@@ -0,0 +1,139 @@
|
||||
// --------------------------------------------------------------------------------------------------------------------
|
||||
// <copyright file="UxrInterpolationSettingsDrawer.cs" company="VRMADA">
|
||||
// Copyright (c) VRMADA, All rights reserved.
|
||||
// </copyright>
|
||||
// --------------------------------------------------------------------------------------------------------------------
|
||||
using UltimateXR.Animation.Interpolation;
|
||||
using UltimateXR.Core;
|
||||
using UnityEditor;
|
||||
using UnityEngine;
|
||||
|
||||
namespace UltimateXR.Editor.Animation.Interpolation
|
||||
{
|
||||
/// <summary>
|
||||
/// Custom inspector drawer for <see cref="UxrInterpolationSettings" />.
|
||||
/// </summary>
|
||||
[CustomPropertyDrawer(typeof(UxrInterpolationSettings))]
|
||||
public class UxrInterpolationSettingsDrawer : PropertyDrawer
|
||||
{
|
||||
#region Constructors & Finalizer
|
||||
|
||||
/// <summary>
|
||||
/// Creates the temporal material to draw the graph.
|
||||
/// </summary>
|
||||
public UxrInterpolationSettingsDrawer()
|
||||
{
|
||||
var shader = Shader.Find(UxrConstants.Shaders.HiddenInternalColoredShader);
|
||||
_lineMaterial = new Material(shader);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Destroys the temporal material to draw the graph.
|
||||
/// </summary>
|
||||
~UxrInterpolationSettingsDrawer()
|
||||
{
|
||||
Object.DestroyImmediate(_lineMaterial);
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Public Overrides PropertyDrawer
|
||||
|
||||
/// <summary>
|
||||
/// Gets the height in pixels required to draw the property.
|
||||
/// </summary>
|
||||
/// <param name="property">Serialized property describing an <see cref="UxrInterpolationSettings" /></param>
|
||||
/// <param name="label">UI label</param>
|
||||
/// <returns>Height in pixels</returns>
|
||||
public override float GetPropertyHeight(SerializedProperty property, GUIContent label)
|
||||
{
|
||||
int lineCount = 5;
|
||||
int loopGraphHeight = 0;
|
||||
|
||||
if (property.FindPropertyRelative(PropertyLoopMode).enumValueIndex != (int)UxrLoopMode.None)
|
||||
{
|
||||
lineCount++;
|
||||
loopGraphHeight += UxrEasingDrawer.GraphHeight;
|
||||
}
|
||||
|
||||
if (property.FindPropertyRelative(PropertyDelay).floatValue > 0.0f)
|
||||
{
|
||||
lineCount++;
|
||||
}
|
||||
|
||||
return lineCount * EditorGUIUtility.singleLineHeight + UxrEasingDrawer.GraphHeight + loopGraphHeight;
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Unity
|
||||
|
||||
/// <summary>
|
||||
/// Draws the inspector and handles input.
|
||||
/// </summary>
|
||||
/// <param name="position">Position where to draw the inspector</param>
|
||||
/// <param name="property">Serialized property to draw</param>
|
||||
/// <param name="label">UI label</param>
|
||||
public override void OnGUI(Rect position, SerializedProperty property, GUIContent label)
|
||||
{
|
||||
int line = 0;
|
||||
|
||||
EditorGUI.PropertyField(UxrEditorUtils.GetRect(position, line++), property.FindPropertyRelative(PropertyDurationSeconds), ContentDurationSeconds);
|
||||
EditorGUI.PropertyField(UxrEditorUtils.GetRect(position, line++), property.FindPropertyRelative(PropertyDelay), ContentDelay);
|
||||
EditorGUI.PropertyField(UxrEditorUtils.GetRect(position, line++), property.FindPropertyRelative(PropertyEasing), ContentEasing);
|
||||
position.y += UxrEasingDrawer.GraphHeight;
|
||||
EditorGUI.PropertyField(UxrEditorUtils.GetRect(position, line++), property.FindPropertyRelative(PropertyLoopMode), ContentLoopMode);
|
||||
|
||||
UxrLoopMode loopMode = (UxrLoopMode)property.FindPropertyRelative(PropertyLoopMode).enumValueIndex;
|
||||
|
||||
if (loopMode != (int)UxrLoopMode.None)
|
||||
{
|
||||
// Draw preview graph
|
||||
|
||||
Rect graphRect = UxrEditorUtils.GetRect(position, line);
|
||||
graphRect.height = UxrEasingDrawer.GraphHeight;
|
||||
graphRect.xMin += EditorGUIUtility.labelWidth;
|
||||
|
||||
UxrEasing easing = (UxrEasing)property.FindPropertyRelative(PropertyEasing).enumValueIndex;
|
||||
|
||||
UxrEasingDrawer.DrawGraph(graphRect, _lineMaterial, Color.green, easing, loopMode, 5);
|
||||
|
||||
position.y += UxrEasingDrawer.GraphHeight;
|
||||
|
||||
// Draw looped duration property
|
||||
EditorGUI.PropertyField(UxrEditorUtils.GetRect(position, line++), property.FindPropertyRelative(PropertyLoopedDurationSeconds), ContentLoopedDurationSeconds);
|
||||
}
|
||||
|
||||
EditorGUI.PropertyField(UxrEditorUtils.GetRect(position, line++), property.FindPropertyRelative(PropertyUnscaledTime), ContentUnscaledTime);
|
||||
|
||||
if (property.FindPropertyRelative(PropertyDelay).floatValue > 0.0f)
|
||||
{
|
||||
EditorGUI.PropertyField(UxrEditorUtils.GetRect(position, line), property.FindPropertyRelative(PropertyDelayUsingEndValue), ContentDelayUsingEndValue);
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Private Types & Data
|
||||
|
||||
private GUIContent ContentDurationSeconds { get; } = new GUIContent("Duration (Seconds)", "The duration in seconds of the interpolation. In a looped animation it specifies the duration of each loop.");
|
||||
private GUIContent ContentDelay { get; } = new GUIContent("Delay (Seconds)", "The seconds to wait before the interpolation starts");
|
||||
private GUIContent ContentEasing { get; } = new GUIContent("Easing", "The animation curve to use for the interpolation");
|
||||
private GUIContent ContentLoopMode { get; } = new GUIContent("Loop Mode", "The type of loop to use");
|
||||
private GUIContent ContentLoopedDurationSeconds { get; } = new GUIContent("Looped Duration (Seconds)", "The total duration in seconds in a looped interpolation. Use -1 to loop indefinitely.");
|
||||
private GUIContent ContentUnscaledTime { get; } = new GUIContent("Use Unscaled Time", "Whether to use unscaled time, which is unaffected by the timescale");
|
||||
private GUIContent ContentDelayUsingEndValue { get; } = new GUIContent("Use End Value During Delay?", "Whether to use the end value in the interpolation during the initial delay");
|
||||
|
||||
private const string PropertyDurationSeconds = "_durationSeconds";
|
||||
private const string PropertyDelay = "_delaySeconds";
|
||||
private const string PropertyEasing = "_easing";
|
||||
private const string PropertyLoopMode = "_loopMode";
|
||||
private const string PropertyLoopedDurationSeconds = "_loopedDurationSeconds";
|
||||
private const string PropertyUnscaledTime = "_useUnscaledTime";
|
||||
private const string PropertyDelayUsingEndValue = "_delayUsingEndValue";
|
||||
|
||||
private readonly Material _lineMaterial;
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
fileFormatVersion: 2
|
||||
guid: d13258678ccb1cf4fb668f0506bfce5b
|
||||
timeCreated: 1505111962
|
||||
licenseType: Pro
|
||||
MonoImporter:
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
Reference in New Issue
Block a user