备份CatanBuilding瘦身独立工程
This commit is contained in:
2781
Assets/Scripts/UI/EnhancedScrollView/EnhancedScroller.cs
Normal file
2781
Assets/Scripts/UI/EnhancedScrollView/EnhancedScroller.cs
Normal file
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,26 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 9c1b74f910281224a8cae6d8e4fc1f43
|
||||
labels:
|
||||
- Cell
|
||||
- Cells
|
||||
- Data
|
||||
- Inventory
|
||||
- List
|
||||
- Recycle
|
||||
- Reuse
|
||||
- Scroll
|
||||
- ScrollRect
|
||||
- ScrollView
|
||||
- Scroller
|
||||
- UI
|
||||
- Virtualize
|
||||
timeCreated: 1435585470
|
||||
licenseType: Store
|
||||
MonoImporter:
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,44 @@
|
||||
using UnityEngine;
|
||||
using System;
|
||||
using System.Collections;
|
||||
|
||||
namespace EnhancedUI.EnhancedScroller
|
||||
{
|
||||
/// <summary>
|
||||
/// This is the base class that all cell views should derive from
|
||||
/// </summary>
|
||||
public class EnhancedScrollerCellView : MonoBehaviour
|
||||
{
|
||||
/// <summary>
|
||||
/// The cellIdentifier is a unique string that allows the scroller
|
||||
/// to handle different types of cells in a single list. Each type
|
||||
/// of cell should have its own identifier
|
||||
/// </summary>
|
||||
public string cellIdentifier;
|
||||
|
||||
/// <summary>
|
||||
/// The cell index of the cell view
|
||||
/// This will differ from the dataIndex if the list is looping
|
||||
/// </summary>
|
||||
[NonSerialized]
|
||||
public int cellIndex;
|
||||
|
||||
/// <summary>
|
||||
/// The data index of the cell view
|
||||
/// </summary>
|
||||
[NonSerialized]
|
||||
public int dataIndex;
|
||||
|
||||
/// <summary>
|
||||
/// Whether the cell is active or recycled
|
||||
/// </summary>
|
||||
[NonSerialized]
|
||||
public bool active;
|
||||
|
||||
/// <summary>
|
||||
/// This method is called by the scroller when the RefreshActiveCellViews is called on the scroller
|
||||
/// You can override it to update your cell's view UID
|
||||
/// </summary>
|
||||
public virtual void RefreshCellView() { }
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,26 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 1f75717e94199704f82f26fcf6953e84
|
||||
labels:
|
||||
- Cell
|
||||
- Cells
|
||||
- Data
|
||||
- Inventory
|
||||
- List
|
||||
- Recycle
|
||||
- Reuse
|
||||
- Scroll
|
||||
- ScrollRect
|
||||
- ScrollView
|
||||
- Scroller
|
||||
- UI
|
||||
- Virtualize
|
||||
timeCreated: 1435585579
|
||||
licenseType: Store
|
||||
MonoImporter:
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,38 @@
|
||||
using UnityEngine;
|
||||
using System.Collections;
|
||||
|
||||
namespace EnhancedUI.EnhancedScroller
|
||||
{
|
||||
/// <summary>
|
||||
/// All scripts that handle the scroller's callbacks should inherit from this interface
|
||||
/// </summary>
|
||||
public interface IEnhancedScrollerDelegate
|
||||
{
|
||||
/// <summary>
|
||||
/// Gets the number of cells in a list of data
|
||||
/// </summary>
|
||||
/// <param name="scroller"></param>
|
||||
/// <returns></returns>
|
||||
int GetNumberOfCells(EnhancedScroller scroller);
|
||||
|
||||
/// <summary>
|
||||
/// Gets the size of a cell view given the index of the data set.
|
||||
/// This allows you to have different sized cells
|
||||
/// </summary>
|
||||
/// <param name="scroller"></param>
|
||||
/// <param name="dataIndex"></param>
|
||||
/// <returns></returns>
|
||||
float GetCellViewSize(EnhancedScroller scroller, int dataIndex);
|
||||
|
||||
/// <summary>
|
||||
/// Gets the cell view that should be used for the data index. Your implementation
|
||||
/// of this function should request a new cell from the scroller so that it can
|
||||
/// properly recycle old cells.
|
||||
/// </summary>
|
||||
/// <param name="scroller"></param>
|
||||
/// <param name="dataIndex"></param>
|
||||
/// <param name="cellIndex"></param>
|
||||
/// <returns></returns>
|
||||
EnhancedScrollerCellView GetCellView(EnhancedScroller scroller, int dataIndex, int cellIndex);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,26 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 7701b31137fe72d47b256054738fd57d
|
||||
labels:
|
||||
- Cell
|
||||
- Cells
|
||||
- Data
|
||||
- Inventory
|
||||
- List
|
||||
- Recycle
|
||||
- Reuse
|
||||
- Scroll
|
||||
- ScrollRect
|
||||
- ScrollView
|
||||
- Scroller
|
||||
- UI
|
||||
- Virtualize
|
||||
timeCreated: 1435585741
|
||||
licenseType: Store
|
||||
MonoImporter:
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
230
Assets/Scripts/UI/EnhancedScrollView/SmallList.cs
Normal file
230
Assets/Scripts/UI/EnhancedScrollView/SmallList.cs
Normal file
@@ -0,0 +1,230 @@
|
||||
using UnityEngine;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace EnhancedUI
|
||||
{
|
||||
/// <summary>
|
||||
/// This is a super light implementation of an array that
|
||||
/// behaves like a list, automatically allocating new memory
|
||||
/// when needed, but not releasing it to garbage collection.
|
||||
/// </summary>
|
||||
/// <typeparam name="T">The type of the list</typeparam>
|
||||
public class SmallList<T>
|
||||
{
|
||||
/// <summary>
|
||||
/// internal storage of list data
|
||||
/// </summary>
|
||||
public T[] data;
|
||||
|
||||
/// <summary>
|
||||
/// The number of elements in the list
|
||||
/// </summary>
|
||||
public int Count = 0;
|
||||
|
||||
/// <summary>
|
||||
/// Indexed access to the list items
|
||||
/// </summary>
|
||||
/// <param name="i"></param>
|
||||
/// <returns></returns>
|
||||
public T this[int i]
|
||||
{
|
||||
get
|
||||
{
|
||||
if (data is null)
|
||||
{
|
||||
return default(T);
|
||||
}
|
||||
else
|
||||
{
|
||||
return data[i];
|
||||
}
|
||||
}
|
||||
|
||||
set { data[i] = value; }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Resizes the array when more memory is needed.
|
||||
/// </summary>
|
||||
private void ResizeArray()
|
||||
{
|
||||
T[] newData;
|
||||
|
||||
if (data != null)
|
||||
newData = new T[Mathf.Max(data.Length << 1, 64)];
|
||||
else
|
||||
newData = new T[64];
|
||||
|
||||
if (data != null && Count > 0)
|
||||
data.CopyTo(newData, 0);
|
||||
|
||||
data = newData;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Instead of releasing the memory to garbage collection,
|
||||
/// the list size is set back to zero
|
||||
/// </summary>
|
||||
public void Clear()
|
||||
{
|
||||
Count = 0;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns the first element of the list
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
public T First()
|
||||
{
|
||||
if (data == null || Count == 0) return default(T);
|
||||
return data[0];
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns the last element of the list
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
public T Last()
|
||||
{
|
||||
if (data == null || Count == 0) return default(T);
|
||||
return data[Count - 1];
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Adds a new element to the array, creating more
|
||||
/// memory if necessary
|
||||
/// </summary>
|
||||
/// <param name="item"></param>
|
||||
public void Add(T item)
|
||||
{
|
||||
if (data == null || Count == data.Length)
|
||||
ResizeArray();
|
||||
|
||||
data[Count] = item;
|
||||
Count++;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Adds a new element to the start of the array, creating more
|
||||
/// memory if necessary
|
||||
/// </summary>
|
||||
/// <param name="item"></param>
|
||||
public void AddStart(T item)
|
||||
{
|
||||
Insert(item, 0);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Inserts a new element to the array at the index specified, creating more
|
||||
/// memory if necessary
|
||||
/// </summary>
|
||||
/// <param name="item"></param>
|
||||
public void Insert(T item, int index)
|
||||
{
|
||||
if (data == null || Count == data.Length)
|
||||
ResizeArray();
|
||||
|
||||
for (var i = Count; i > index; i--)
|
||||
{
|
||||
data[i] = data[i - 1];
|
||||
}
|
||||
|
||||
data[index] = item;
|
||||
Count++;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Removes an item from the start of the data
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
public T RemoveStart()
|
||||
{
|
||||
return RemoveAt(0);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Removes an item from the index of the data
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
public T RemoveAt(int index)
|
||||
{
|
||||
if (data != null && Count != 0)
|
||||
{
|
||||
T val = data[index];
|
||||
|
||||
for (var i = index; i < Count - 1; i++)
|
||||
{
|
||||
data[i] = data[i + 1];
|
||||
}
|
||||
|
||||
Count--;
|
||||
data[Count] = default(T);
|
||||
return val;
|
||||
}
|
||||
else
|
||||
{
|
||||
return default(T);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Removes an item from the data
|
||||
/// </summary>
|
||||
/// <param name="item"></param>
|
||||
/// <returns></returns>
|
||||
public T Remove(T item)
|
||||
{
|
||||
if (data != null && Count != 0)
|
||||
{
|
||||
for (var i = 0; i < Count; i++)
|
||||
{
|
||||
if (data[i].Equals(item))
|
||||
{
|
||||
return RemoveAt(i);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return default(T);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Removes an item from the end of the data
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
public T RemoveEnd()
|
||||
{
|
||||
if (data != null && Count != 0)
|
||||
{
|
||||
Count--;
|
||||
T val = data[Count];
|
||||
data[Count] = default(T);
|
||||
|
||||
return val;
|
||||
}
|
||||
else
|
||||
{
|
||||
return default(T);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Determines if the data contains the item
|
||||
/// </summary>
|
||||
/// <param name="item">The item to compare</param>
|
||||
/// <returns>True if the item exists in teh data</returns>
|
||||
public bool Contains(T item)
|
||||
{
|
||||
if (data == null)
|
||||
return false;
|
||||
|
||||
for (var i = 0; i < Count; i++)
|
||||
{
|
||||
if (data[i].Equals(item))
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
26
Assets/Scripts/UI/EnhancedScrollView/SmallList.cs.meta
Normal file
26
Assets/Scripts/UI/EnhancedScrollView/SmallList.cs.meta
Normal file
@@ -0,0 +1,26 @@
|
||||
fileFormatVersion: 2
|
||||
guid: aab29d68fb4a95d49bca25f359d8f076
|
||||
labels:
|
||||
- Cell
|
||||
- Cells
|
||||
- Data
|
||||
- Inventory
|
||||
- List
|
||||
- Recycle
|
||||
- Reuse
|
||||
- Scroll
|
||||
- ScrollRect
|
||||
- ScrollView
|
||||
- Scroller
|
||||
- UI
|
||||
- Virtualize
|
||||
timeCreated: 1435585634
|
||||
licenseType: Store
|
||||
MonoImporter:
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
448
Assets/Scripts/UI/EnhancedScrollView/Tween.cs
Normal file
448
Assets/Scripts/UI/EnhancedScrollView/Tween.cs
Normal file
@@ -0,0 +1,448 @@
|
||||
using UnityEngine;
|
||||
using UnityEngine.UI;
|
||||
using EnhancedUI.EnhancedScroller;
|
||||
using EnhancedUI;
|
||||
using System;
|
||||
using System.Collections;
|
||||
|
||||
namespace EnhancedUI.EnhancedScroller
|
||||
{
|
||||
public class Tween : MonoBehaviour
|
||||
{
|
||||
/// <summary>
|
||||
/// The easing type
|
||||
/// </summary>
|
||||
public enum TweenType
|
||||
{
|
||||
immediate,
|
||||
linear,
|
||||
spring,
|
||||
easeInQuad,
|
||||
easeOutQuad,
|
||||
easeInOutQuad,
|
||||
easeInCubic,
|
||||
easeOutCubic,
|
||||
easeInOutCubic,
|
||||
easeInQuart,
|
||||
easeOutQuart,
|
||||
easeInOutQuart,
|
||||
easeInQuint,
|
||||
easeOutQuint,
|
||||
easeInOutQuint,
|
||||
easeInSine,
|
||||
easeOutSine,
|
||||
easeInOutSine,
|
||||
easeInExpo,
|
||||
easeOutExpo,
|
||||
easeInOutExpo,
|
||||
easeInCirc,
|
||||
easeOutCirc,
|
||||
easeInOutCirc,
|
||||
easeInBounce,
|
||||
easeOutBounce,
|
||||
easeInOutBounce,
|
||||
easeInBack,
|
||||
easeOutBack,
|
||||
easeInOutBack,
|
||||
easeInElastic,
|
||||
easeOutElastic,
|
||||
easeInOutElastic
|
||||
}
|
||||
|
||||
private float _tweenTimeLeft;
|
||||
|
||||
/// <summary>
|
||||
/// Moves the scroll position over time between two points given an easing function. When the
|
||||
/// tween is complete it will fire the jumpComplete delegate.
|
||||
/// </summary>
|
||||
/// <param name="tweenType">The type of easing to use</param>
|
||||
/// <param name="time">The amount of time to interpolate</param>
|
||||
/// <param name="start">The starting scroll position</param>
|
||||
/// <param name="end">The ending scroll position</param>
|
||||
/// <param name="jumpComplete">The action to fire when the tween is complete</param>
|
||||
/// <returns></returns>
|
||||
public IEnumerator TweenPosition(TweenType tweenType, float time, float start, float end, Action<float, float> tweenUpdated, Action tweenComplete)
|
||||
{
|
||||
if (!(tweenType == TweenType.immediate || time == 0))
|
||||
{
|
||||
_tweenTimeLeft = 0;
|
||||
var newPosition = 0f;
|
||||
var lastPosition = start;
|
||||
|
||||
// while the tween has time left, use an easing function
|
||||
while (_tweenTimeLeft < time)
|
||||
{
|
||||
switch (tweenType)
|
||||
{
|
||||
case TweenType.linear: newPosition = linear(start, end, (_tweenTimeLeft / time)); break;
|
||||
case TweenType.spring: newPosition = spring(start, end, (_tweenTimeLeft / time)); break;
|
||||
case TweenType.easeInQuad: newPosition = easeInQuad(start, end, (_tweenTimeLeft / time)); break;
|
||||
case TweenType.easeOutQuad: newPosition = easeOutQuad(start, end, (_tweenTimeLeft / time)); break;
|
||||
case TweenType.easeInOutQuad: newPosition = easeInOutQuad(start, end, (_tweenTimeLeft / time)); break;
|
||||
case TweenType.easeInCubic: newPosition = easeInCubic(start, end, (_tweenTimeLeft / time)); break;
|
||||
case TweenType.easeOutCubic: newPosition = easeOutCubic(start, end, (_tweenTimeLeft / time)); break;
|
||||
case TweenType.easeInOutCubic: newPosition = easeInOutCubic(start, end, (_tweenTimeLeft / time)); break;
|
||||
case TweenType.easeInQuart: newPosition = easeInQuart(start, end, (_tweenTimeLeft / time)); break;
|
||||
case TweenType.easeOutQuart: newPosition = easeOutQuart(start, end, (_tweenTimeLeft / time)); break;
|
||||
case TweenType.easeInOutQuart: newPosition = easeInOutQuart(start, end, (_tweenTimeLeft / time)); break;
|
||||
case TweenType.easeInQuint: newPosition = easeInQuint(start, end, (_tweenTimeLeft / time)); break;
|
||||
case TweenType.easeOutQuint: newPosition = easeOutQuint(start, end, (_tweenTimeLeft / time)); break;
|
||||
case TweenType.easeInOutQuint: newPosition = easeInOutQuint(start, end, (_tweenTimeLeft / time)); break;
|
||||
case TweenType.easeInSine: newPosition = easeInSine(start, end, (_tweenTimeLeft / time)); break;
|
||||
case TweenType.easeOutSine: newPosition = easeOutSine(start, end, (_tweenTimeLeft / time)); break;
|
||||
case TweenType.easeInOutSine: newPosition = easeInOutSine(start, end, (_tweenTimeLeft / time)); break;
|
||||
case TweenType.easeInExpo: newPosition = easeInExpo(start, end, (_tweenTimeLeft / time)); break;
|
||||
case TweenType.easeOutExpo: newPosition = easeOutExpo(start, end, (_tweenTimeLeft / time)); break;
|
||||
case TweenType.easeInOutExpo: newPosition = easeInOutExpo(start, end, (_tweenTimeLeft / time)); break;
|
||||
case TweenType.easeInCirc: newPosition = easeInCirc(start, end, (_tweenTimeLeft / time)); break;
|
||||
case TweenType.easeOutCirc: newPosition = easeOutCirc(start, end, (_tweenTimeLeft / time)); break;
|
||||
case TweenType.easeInOutCirc: newPosition = easeInOutCirc(start, end, (_tweenTimeLeft / time)); break;
|
||||
case TweenType.easeInBounce: newPosition = easeInBounce(start, end, (_tweenTimeLeft / time)); break;
|
||||
case TweenType.easeOutBounce: newPosition = easeOutBounce(start, end, (_tweenTimeLeft / time)); break;
|
||||
case TweenType.easeInOutBounce: newPosition = easeInOutBounce(start, end, (_tweenTimeLeft / time)); break;
|
||||
case TweenType.easeInBack: newPosition = easeInBack(start, end, (_tweenTimeLeft / time)); break;
|
||||
case TweenType.easeOutBack: newPosition = easeOutBack(start, end, (_tweenTimeLeft / time)); break;
|
||||
case TweenType.easeInOutBack: newPosition = easeInOutBack(start, end, (_tweenTimeLeft / time)); break;
|
||||
case TweenType.easeInElastic: newPosition = easeInElastic(start, end, (_tweenTimeLeft / time)); break;
|
||||
case TweenType.easeOutElastic: newPosition = easeOutElastic(start, end, (_tweenTimeLeft / time)); break;
|
||||
case TweenType.easeInOutElastic: newPosition = easeInOutElastic(start, end, (_tweenTimeLeft / time)); break;
|
||||
}
|
||||
|
||||
if (tweenUpdated != null) tweenUpdated(newPosition, newPosition - lastPosition);
|
||||
|
||||
lastPosition = newPosition;
|
||||
|
||||
// increase the time elapsed
|
||||
_tweenTimeLeft += Time.unscaledDeltaTime;
|
||||
|
||||
yield return null;
|
||||
}
|
||||
}
|
||||
|
||||
// the time has expired, so we make sure the final value
|
||||
// is the actual end position.
|
||||
if (tweenUpdated != null) tweenUpdated(end, 0);
|
||||
|
||||
// the tween jump is complete, so we fire the delegate
|
||||
if (tweenComplete != null) tweenComplete();
|
||||
}
|
||||
|
||||
private float linear(float start, float end, float val)
|
||||
{
|
||||
return Mathf.Lerp(start, end, val);
|
||||
}
|
||||
|
||||
private static float spring(float start, float end, float val)
|
||||
{
|
||||
val = Mathf.Clamp01(val);
|
||||
val = (Mathf.Sin(val * Mathf.PI * (0.2f + 2.5f * val * val * val)) * Mathf.Pow(1f - val, 2.2f) + val) * (1f + (1.2f * (1f - val)));
|
||||
return start + (end - start) * val;
|
||||
}
|
||||
|
||||
private static float easeInQuad(float start, float end, float val)
|
||||
{
|
||||
end -= start;
|
||||
return end * val * val + start;
|
||||
}
|
||||
|
||||
private static float easeOutQuad(float start, float end, float val)
|
||||
{
|
||||
end -= start;
|
||||
return -end * val * (val - 2) + start;
|
||||
}
|
||||
|
||||
private static float easeInOutQuad(float start, float end, float val)
|
||||
{
|
||||
val /= .5f;
|
||||
end -= start;
|
||||
if (val < 1) return end / 2 * val * val + start;
|
||||
val--;
|
||||
return -end / 2 * (val * (val - 2) - 1) + start;
|
||||
}
|
||||
|
||||
private static float easeInCubic(float start, float end, float val)
|
||||
{
|
||||
end -= start;
|
||||
return end * val * val * val + start;
|
||||
}
|
||||
|
||||
private static float easeOutCubic(float start, float end, float val)
|
||||
{
|
||||
val--;
|
||||
end -= start;
|
||||
return end * (val * val * val + 1) + start;
|
||||
}
|
||||
|
||||
private static float easeInOutCubic(float start, float end, float val)
|
||||
{
|
||||
val /= .5f;
|
||||
end -= start;
|
||||
if (val < 1) return end / 2 * val * val * val + start;
|
||||
val -= 2;
|
||||
return end / 2 * (val * val * val + 2) + start;
|
||||
}
|
||||
|
||||
private static float easeInQuart(float start, float end, float val)
|
||||
{
|
||||
end -= start;
|
||||
return end * val * val * val * val + start;
|
||||
}
|
||||
|
||||
private static float easeOutQuart(float start, float end, float val)
|
||||
{
|
||||
val--;
|
||||
end -= start;
|
||||
return -end * (val * val * val * val - 1) + start;
|
||||
}
|
||||
|
||||
private static float easeInOutQuart(float start, float end, float val)
|
||||
{
|
||||
val /= .5f;
|
||||
end -= start;
|
||||
if (val < 1) return end / 2 * val * val * val * val + start;
|
||||
val -= 2;
|
||||
return -end / 2 * (val * val * val * val - 2) + start;
|
||||
}
|
||||
|
||||
private static float easeInQuint(float start, float end, float val)
|
||||
{
|
||||
end -= start;
|
||||
return end * val * val * val * val * val + start;
|
||||
}
|
||||
|
||||
private static float easeOutQuint(float start, float end, float val)
|
||||
{
|
||||
val--;
|
||||
end -= start;
|
||||
return end * (val * val * val * val * val + 1) + start;
|
||||
}
|
||||
|
||||
private static float easeInOutQuint(float start, float end, float val)
|
||||
{
|
||||
val /= .5f;
|
||||
end -= start;
|
||||
if (val < 1) return end / 2 * val * val * val * val * val + start;
|
||||
val -= 2;
|
||||
return end / 2 * (val * val * val * val * val + 2) + start;
|
||||
}
|
||||
|
||||
private static float easeInSine(float start, float end, float val)
|
||||
{
|
||||
end -= start;
|
||||
return -end * Mathf.Cos(val / 1 * (Mathf.PI / 2)) + end + start;
|
||||
}
|
||||
|
||||
private static float easeOutSine(float start, float end, float val)
|
||||
{
|
||||
end -= start;
|
||||
return end * Mathf.Sin(val / 1 * (Mathf.PI / 2)) + start;
|
||||
}
|
||||
|
||||
private static float easeInOutSine(float start, float end, float val)
|
||||
{
|
||||
end -= start;
|
||||
return -end / 2 * (Mathf.Cos(Mathf.PI * val / 1) - 1) + start;
|
||||
}
|
||||
|
||||
private static float easeInExpo(float start, float end, float val)
|
||||
{
|
||||
end -= start;
|
||||
return end * Mathf.Pow(2, 10 * (val / 1 - 1)) + start;
|
||||
}
|
||||
|
||||
private static float easeOutExpo(float start, float end, float val)
|
||||
{
|
||||
end -= start;
|
||||
return end * (-Mathf.Pow(2, -10 * val / 1) + 1) + start;
|
||||
}
|
||||
|
||||
private static float easeInOutExpo(float start, float end, float val)
|
||||
{
|
||||
val /= .5f;
|
||||
end -= start;
|
||||
if (val < 1) return end / 2 * Mathf.Pow(2, 10 * (val - 1)) + start;
|
||||
val--;
|
||||
return end / 2 * (-Mathf.Pow(2, -10 * val) + 2) + start;
|
||||
}
|
||||
|
||||
private static float easeInCirc(float start, float end, float val)
|
||||
{
|
||||
end -= start;
|
||||
return -end * (Mathf.Sqrt(1 - val * val) - 1) + start;
|
||||
}
|
||||
|
||||
private static float easeOutCirc(float start, float end, float val)
|
||||
{
|
||||
val--;
|
||||
end -= start;
|
||||
return end * Mathf.Sqrt(1 - val * val) + start;
|
||||
}
|
||||
|
||||
private static float easeInOutCirc(float start, float end, float val)
|
||||
{
|
||||
val /= .5f;
|
||||
end -= start;
|
||||
if (val < 1) return -end / 2 * (Mathf.Sqrt(1 - val * val) - 1) + start;
|
||||
val -= 2;
|
||||
return end / 2 * (Mathf.Sqrt(1 - val * val) + 1) + start;
|
||||
}
|
||||
|
||||
private static float easeInBounce(float start, float end, float val)
|
||||
{
|
||||
end -= start;
|
||||
float d = 1f;
|
||||
return end - easeOutBounce(0, end, d - val) + start;
|
||||
}
|
||||
|
||||
private static float easeOutBounce(float start, float end, float val)
|
||||
{
|
||||
val /= 1f;
|
||||
end -= start;
|
||||
if (val < (1 / 2.75f))
|
||||
{
|
||||
return end * (7.5625f * val * val) + start;
|
||||
}
|
||||
else if (val < (2 / 2.75f))
|
||||
{
|
||||
val -= (1.5f / 2.75f);
|
||||
return end * (7.5625f * (val) * val + .75f) + start;
|
||||
}
|
||||
else if (val < (2.5 / 2.75))
|
||||
{
|
||||
val -= (2.25f / 2.75f);
|
||||
return end * (7.5625f * (val) * val + .9375f) + start;
|
||||
}
|
||||
else
|
||||
{
|
||||
val -= (2.625f / 2.75f);
|
||||
return end * (7.5625f * (val) * val + .984375f) + start;
|
||||
}
|
||||
}
|
||||
|
||||
private static float easeInOutBounce(float start, float end, float val)
|
||||
{
|
||||
end -= start;
|
||||
float d = 1f;
|
||||
if (val < d / 2) return easeInBounce(0, end, val * 2) * 0.5f + start;
|
||||
else return easeOutBounce(0, end, val * 2 - d) * 0.5f + end * 0.5f + start;
|
||||
}
|
||||
|
||||
private static float easeInBack(float start, float end, float val)
|
||||
{
|
||||
end -= start;
|
||||
val /= 1;
|
||||
float s = 1.70158f;
|
||||
return end * (val) * val * ((s + 1) * val - s) + start;
|
||||
}
|
||||
|
||||
private static float easeOutBack(float start, float end, float val)
|
||||
{
|
||||
float s = 1.70158f;
|
||||
end -= start;
|
||||
val = (val / 1) - 1;
|
||||
return end * ((val) * val * ((s + 1) * val + s) + 1) + start;
|
||||
}
|
||||
|
||||
private static float easeInOutBack(float start, float end, float val)
|
||||
{
|
||||
float s = 1.70158f;
|
||||
end -= start;
|
||||
val /= .5f;
|
||||
if ((val) < 1)
|
||||
{
|
||||
s *= (1.525f);
|
||||
return end / 2 * (val * val * (((s) + 1) * val - s)) + start;
|
||||
}
|
||||
val -= 2;
|
||||
s *= (1.525f);
|
||||
return end / 2 * ((val) * val * (((s) + 1) * val + s) + 2) + start;
|
||||
}
|
||||
|
||||
private static float easeInElastic(float start, float end, float val)
|
||||
{
|
||||
end -= start;
|
||||
|
||||
float d = 1f;
|
||||
float p = d * .3f;
|
||||
float s = 0;
|
||||
float a = 0;
|
||||
|
||||
if (val == 0) return start;
|
||||
val = val / d;
|
||||
if (val == 1) return start + end;
|
||||
|
||||
if (a == 0f || a < Mathf.Abs(end))
|
||||
{
|
||||
a = end;
|
||||
s = p / 4;
|
||||
}
|
||||
else
|
||||
{
|
||||
s = p / (2 * Mathf.PI) * Mathf.Asin(end / a);
|
||||
}
|
||||
val = val - 1;
|
||||
return -(a * Mathf.Pow(2, 10 * val) * Mathf.Sin((val * d - s) * (2 * Mathf.PI) / p)) + start;
|
||||
}
|
||||
|
||||
private static float easeOutElastic(float start, float end, float val)
|
||||
{
|
||||
end -= start;
|
||||
|
||||
float d = 1f;
|
||||
float p = d * .3f;
|
||||
float s = 0;
|
||||
float a = 0;
|
||||
|
||||
if (val == 0) return start;
|
||||
|
||||
val = val / d;
|
||||
if (val == 1) return start + end;
|
||||
|
||||
if (a == 0f || a < Mathf.Abs(end))
|
||||
{
|
||||
a = end;
|
||||
s = p / 4;
|
||||
}
|
||||
else
|
||||
{
|
||||
s = p / (2 * Mathf.PI) * Mathf.Asin(end / a);
|
||||
}
|
||||
|
||||
return (a * Mathf.Pow(2, -10 * val) * Mathf.Sin((val * d - s) * (2 * Mathf.PI) / p) + end + start);
|
||||
}
|
||||
|
||||
private static float easeInOutElastic(float start, float end, float val)
|
||||
{
|
||||
end -= start;
|
||||
|
||||
float d = 1f;
|
||||
float p = d * .3f;
|
||||
float s = 0;
|
||||
float a = 0;
|
||||
|
||||
if (val == 0) return start;
|
||||
|
||||
val = val / (d / 2);
|
||||
if (val == 2) return start + end;
|
||||
|
||||
if (a == 0f || a < Mathf.Abs(end))
|
||||
{
|
||||
a = end;
|
||||
s = p / 4;
|
||||
}
|
||||
else
|
||||
{
|
||||
s = p / (2 * Mathf.PI) * Mathf.Asin(end / a);
|
||||
}
|
||||
|
||||
if (val < 1)
|
||||
{
|
||||
val = val - 1;
|
||||
return -0.5f * (a * Mathf.Pow(2, 10 * val) * Mathf.Sin((val * d - s) * (2 * Mathf.PI) / p)) + start;
|
||||
}
|
||||
val = val - 1;
|
||||
return a * Mathf.Pow(2, -10 * val) * Mathf.Sin((val * d - s) * (2 * Mathf.PI) / p) * 0.5f + end + start;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
11
Assets/Scripts/UI/EnhancedScrollView/Tween.cs.meta
Normal file
11
Assets/Scripts/UI/EnhancedScrollView/Tween.cs.meta
Normal file
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: f69fd3a8609bb43668420e5ace2cb8ef
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
Reference in New Issue
Block a user