feat: SongCreator 씬 완성 — Beat Sage URL 지원, info.dat 메타데이터 자동 추출
- BeatSageUploader: audio_url 지원(UploadFromUrl), PollAndDownload 공통화, ZIP 500 오류 3회 재시도 - BeatSageConverter: info.dat 파싱(SongMetadata), BPM 자동 감지 → 노트 타이밍 변환에 적용 - SongCreatorManager: title/BPM 필수 입력 제거, 난이도 4개 자동 선택, GenerateFlowFromUrl 버그 수정 - NasPublisher: audioPath null 허용(URL 흐름에서 로컬 파일 없는 경우 스킵) - .gitignore/.gitattributes 초기 설정 Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
Binary file not shown.
@@ -0,0 +1,14 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 9642a8d0930e4f140b13bb9705f2bc76
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
AssetOrigin:
|
||||
serializedVersion: 1
|
||||
productId: 168243
|
||||
packageName: VR Beats Kit
|
||||
packageVersion: 2.0
|
||||
assetPath: Assets/VRBeatsKit/Scripts/PlatinioTween/Readme.pdf
|
||||
uploadId: 546658
|
||||
@@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 22eb50780891341419ee16f6d7f1921d
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 11a8feff4891a5947814f2d5d3f859be
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,18 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 85f2f6e2c293ab346b39f2dfac0cd472
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
AssetOrigin:
|
||||
serializedVersion: 1
|
||||
productId: 168243
|
||||
packageName: VR Beats Kit
|
||||
packageVersion: 2.0
|
||||
assetPath: Assets/VRBeatsKit/Scripts/PlatinioTween/Scripts/Core/EasingFunctions.cs
|
||||
uploadId: 546658
|
||||
@@ -0,0 +1,366 @@
|
||||
using UnityEngine;
|
||||
using UnityEngine.UI;
|
||||
using Platinio.TweenEngine;
|
||||
using Platinio.UI;
|
||||
|
||||
public static class PlatinioTweenExtension
|
||||
{
|
||||
public static BaseTween ScaleTween(this Transform t , Vector3 to , float time)
|
||||
{
|
||||
return PlatinioTween.instance.ScaleTween(t , to , time);
|
||||
}
|
||||
|
||||
public static BaseTween ScaleTween(this GameObject go, Vector3 to, float time)
|
||||
{
|
||||
return PlatinioTween.instance.ScaleTween( go.transform, to, time );
|
||||
}
|
||||
|
||||
public static BaseTween ScaleTween(this RectTransform rect, Vector3 to, float time)
|
||||
{
|
||||
return PlatinioTween.instance.ScaleTween( rect, to, time );
|
||||
}
|
||||
|
||||
public static BaseTween ScaleAtSpeed(this Transform t, Vector3 to, float speed)
|
||||
{
|
||||
return PlatinioTween.instance.ScaleTweenAtSpeed(t , to , speed);
|
||||
}
|
||||
|
||||
public static BaseTween ScaleAtSpeed(this GameObject go, Vector3 to, float speed)
|
||||
{
|
||||
return PlatinioTween.instance.ScaleTweenAtSpeed(go , to , speed);
|
||||
}
|
||||
|
||||
public static BaseTween ScaleAtSpeed(this RectTransform rect, Vector3 to, float speed)
|
||||
{
|
||||
return PlatinioTween.instance.ScaleTweenAtSpeed(rect , to , speed);
|
||||
}
|
||||
|
||||
public static BaseTween ScaleX(this Transform obj, float value, float t)
|
||||
{
|
||||
return PlatinioTween.instance.ScaleX(obj , value , t);
|
||||
}
|
||||
|
||||
public static BaseTween ScaleX(this GameObject obj, float value, float t)
|
||||
{
|
||||
return PlatinioTween.instance.ScaleX(obj , value , t);
|
||||
}
|
||||
|
||||
public static BaseTween ScaleX(this RectTransform obj, float value, float t)
|
||||
{
|
||||
return PlatinioTween.instance.ScaleX(obj , value , t);
|
||||
}
|
||||
|
||||
public static BaseTween ScaleXAtSpeed(this Transform obj, float value, float speed)
|
||||
{
|
||||
return PlatinioTween.instance.ScaleXAtSpeed(obj , value , speed);
|
||||
}
|
||||
|
||||
public static BaseTween ScaleXAtSpeed(this GameObject obj, float value, float speed)
|
||||
{
|
||||
return PlatinioTween.instance.ScaleXAtSpeed(obj , value , speed);
|
||||
}
|
||||
|
||||
public static BaseTween ScaleXAtSpeed(this RectTransform obj, float value, float speed)
|
||||
{
|
||||
return PlatinioTween.instance.ScaleXAtSpeed(obj , value , speed);
|
||||
}
|
||||
|
||||
public static BaseTween ScaleY(this Transform obj, float value, float t)
|
||||
{
|
||||
return PlatinioTween.instance.ScaleY( obj, value, t );
|
||||
}
|
||||
|
||||
public static BaseTween ScaleY(this GameObject obj, float value, float t)
|
||||
{
|
||||
return PlatinioTween.instance.ScaleY( obj, value, t );
|
||||
}
|
||||
|
||||
public static BaseTween ScaleY(this RectTransform obj, float value, float t)
|
||||
{
|
||||
return PlatinioTween.instance.ScaleY( obj, value, t );
|
||||
}
|
||||
|
||||
public static BaseTween ScaleYAtSpeed(this Transform obj, float value, float speed)
|
||||
{
|
||||
return PlatinioTween.instance.ScaleYAtSpeed( obj, value, speed );
|
||||
}
|
||||
|
||||
public static BaseTween ScaleYAtSpeed(this GameObject obj, float value, float speed)
|
||||
{
|
||||
return PlatinioTween.instance.ScaleYAtSpeed( obj, value, speed );
|
||||
}
|
||||
|
||||
public static BaseTween ScaleYAtSpeed(this RectTransform obj, float value, float speed)
|
||||
{
|
||||
return PlatinioTween.instance.ScaleYAtSpeed( obj, value, speed );
|
||||
}
|
||||
|
||||
public static BaseTween ScaleZ(this Transform obj, float value, float t)
|
||||
{
|
||||
return PlatinioTween.instance.ScaleX( obj, value, t );
|
||||
}
|
||||
|
||||
public static BaseTween ScaleZ(this GameObject obj, float value, float t)
|
||||
{
|
||||
return PlatinioTween.instance.ScaleX( obj, value, t );
|
||||
}
|
||||
|
||||
public static BaseTween ScaleZ(this RectTransform obj, float value, float t)
|
||||
{
|
||||
return PlatinioTween.instance.ScaleX( obj, value, t );
|
||||
}
|
||||
|
||||
public static BaseTween ScaleZAtSpeed(this Transform obj, float value, float speed)
|
||||
{
|
||||
return PlatinioTween.instance.ScaleXAtSpeed( obj, value, speed );
|
||||
}
|
||||
|
||||
public static BaseTween ScaleZAtSpeed(this GameObject obj, float value, float speed)
|
||||
{
|
||||
return PlatinioTween.instance.ScaleXAtSpeed( obj, value, speed );
|
||||
}
|
||||
|
||||
public static BaseTween ScaleZAtSpeed(this RectTransform obj, float value, float speed)
|
||||
{
|
||||
return PlatinioTween.instance.ScaleXAtSpeed( obj, value, speed );
|
||||
}
|
||||
|
||||
public static BaseTween RotateTween(this Transform t, Vector3 axis, float to, float time)
|
||||
{
|
||||
return PlatinioTween.instance.RotateTween(t , axis , to , time);
|
||||
}
|
||||
|
||||
public static BaseTween RotateTween(this GameObject go, Vector3 axis, float to, float time)
|
||||
{
|
||||
return PlatinioTween.instance.RotateTween(go , axis , to , time);
|
||||
}
|
||||
|
||||
public static BaseTween RotateTween(this RectTransform rect, Vector3 axis, float to, float time)
|
||||
{
|
||||
return PlatinioTween.instance.RotateTween(rect , axis , to , time);
|
||||
}
|
||||
|
||||
public static BaseTween FadeOutAtSpeed(this CanvasGroup cg, float speed)
|
||||
{
|
||||
return PlatinioTween.instance.FadeOutAtSpeed(cg , speed);
|
||||
}
|
||||
|
||||
public static BaseTween FadeIn(this CanvasGroup cg, float t)
|
||||
{
|
||||
return PlatinioTween.instance.FadeIn(cg , t);
|
||||
}
|
||||
|
||||
public static BaseTween FadeInAtSpeed(this CanvasGroup cg, float speed)
|
||||
{
|
||||
return PlatinioTween.instance.FadeInAtSpeed(cg , speed);
|
||||
}
|
||||
|
||||
public static BaseTween Fade(this CanvasGroup cg, float to, float t)
|
||||
{
|
||||
return PlatinioTween.instance.Fade(cg , to , t);
|
||||
}
|
||||
|
||||
public static BaseTween FadeAtSpeed(this CanvasGroup cg, float to, float speed)
|
||||
{
|
||||
return PlatinioTween.instance.FadeAtSpeed(cg , to , speed);
|
||||
}
|
||||
|
||||
public static BaseTween Fade(Image image, float to, float t)
|
||||
{
|
||||
return PlatinioTween.instance.Fade(image , to , t);
|
||||
}
|
||||
|
||||
public static BaseTween FadeAtSpeed(this Image img, float to, float speed)
|
||||
{
|
||||
return PlatinioTween.instance.FadeAtSpeed(img , to , speed);
|
||||
}
|
||||
|
||||
public static BaseTween FadeOut(this Image image, float t)
|
||||
{
|
||||
return PlatinioTween.instance.FadeOut(image , t);
|
||||
}
|
||||
|
||||
public static BaseTween FadeOutAtSpeed(this Image img, float speed)
|
||||
{
|
||||
return PlatinioTween.instance.FadeOutAtSpeed(img , speed);
|
||||
}
|
||||
|
||||
public static BaseTween FadeIn(this Image image, float t)
|
||||
{
|
||||
return PlatinioTween.instance.FadeIn(image , t);
|
||||
}
|
||||
|
||||
public static BaseTween FadeInAtSpeed(this Image img, float speed)
|
||||
{
|
||||
return PlatinioTween.instance.FadeInAtSpeed(img , speed);
|
||||
}
|
||||
|
||||
public static BaseTween Fade(this SpriteRenderer sprite, float to, float t)
|
||||
{
|
||||
return PlatinioTween.instance.Fade(sprite , to , t);
|
||||
}
|
||||
|
||||
public static BaseTween FadeAtSpeed(this SpriteRenderer sprite, float to, float speed)
|
||||
{
|
||||
return PlatinioTween.instance.FadeAtSpeed(sprite , to , speed);
|
||||
}
|
||||
|
||||
public static BaseTween FadeOut(this CanvasGroup cg , float t)
|
||||
{
|
||||
return PlatinioTween.instance.FadeOut(cg, t);
|
||||
}
|
||||
|
||||
public static BaseTween FadeOut(this SpriteRenderer sprite, float t)
|
||||
{
|
||||
return PlatinioTween.instance.FadeOut(sprite , t);
|
||||
}
|
||||
|
||||
public static BaseTween FadeOutAtSpeed(this SpriteRenderer sprite, float speed)
|
||||
{
|
||||
return PlatinioTween.instance.FadeOutAtSpeed(sprite , speed);
|
||||
}
|
||||
|
||||
public static BaseTween FadeIn(this SpriteRenderer sprite, float t)
|
||||
{
|
||||
return PlatinioTween.instance.FadeIn(sprite , t);
|
||||
}
|
||||
|
||||
public static BaseTween FadeInAtSpeed(this SpriteRenderer sprite, float speed)
|
||||
{
|
||||
return PlatinioTween.instance.FadeInAtSpeed(sprite , speed);
|
||||
}
|
||||
|
||||
public static BaseTween ColorTween(this SpriteRenderer sprite, Color to, float t)
|
||||
{
|
||||
return PlatinioTween.instance.ColorTween(sprite , to , t);
|
||||
}
|
||||
|
||||
public static BaseTween ColorTweenAtSpeed(this SpriteRenderer sprite, Color to, float speed)
|
||||
{
|
||||
return PlatinioTween.instance.ColorTweenAtSpeed(sprite , to , speed);
|
||||
}
|
||||
|
||||
public static BaseTween ColorTween(this Image image, Color to, float t)
|
||||
{
|
||||
return PlatinioTween.instance.ColorTween(image , to , t);
|
||||
}
|
||||
|
||||
public static BaseTween ColorTweenAtSpeed(this Image img, Color to, float speed)
|
||||
{
|
||||
return PlatinioTween.instance.ColorTweenAtSpeed(img , to , speed);
|
||||
}
|
||||
|
||||
public static BaseTween FillAmountTween(this Image img , float to , float t)
|
||||
{
|
||||
return PlatinioTween.instance.FillAmountTween(img , to , t);
|
||||
}
|
||||
|
||||
public static BaseTween FillAmountTweenAtSpeed(this Image img, float to, float speed)
|
||||
{
|
||||
return PlatinioTween.instance.FillAmountTween(img, to, speed);
|
||||
}
|
||||
|
||||
public static BaseTween Move(this Transform obj, Transform to, float t)
|
||||
{
|
||||
return PlatinioTween.instance.Move(obj , to , t);
|
||||
}
|
||||
|
||||
public static BaseTween MoveAtSpeed(this Transform obj, Transform to, float speed)
|
||||
{
|
||||
return PlatinioTween.instance.MoveAtSpeed(obj , to , speed);
|
||||
}
|
||||
|
||||
public static BaseTween Move(this Transform obj, Vector3 to, float t)
|
||||
{
|
||||
return PlatinioTween.instance.Move(obj , to , t);
|
||||
}
|
||||
|
||||
public static BaseTween MoveAtSpeed(this Transform obj, Vector3 to, float speed)
|
||||
{
|
||||
return PlatinioTween.instance.MoveAtSpeed(obj , to , speed);
|
||||
}
|
||||
|
||||
|
||||
public static BaseTween Move(this GameObject obj, Transform to, float t)
|
||||
{
|
||||
return PlatinioTween.instance.Move(obj , to , t);
|
||||
}
|
||||
|
||||
public static BaseTween MoveAtSpeed(this GameObject obj, Transform to, float speed)
|
||||
{
|
||||
return PlatinioTween.instance.MoveAtSpeed(obj , to , speed);
|
||||
}
|
||||
|
||||
public static BaseTween Move(this GameObject obj, Vector3 to, float t)
|
||||
{
|
||||
return PlatinioTween.instance.Move(obj , to , t);
|
||||
}
|
||||
|
||||
public static BaseTween MoveAtSpeed(this GameObject obj, Vector3 to, float speed)
|
||||
{
|
||||
return PlatinioTween.instance.MoveAtSpeed(obj , to , speed);
|
||||
}
|
||||
|
||||
public static BaseTween Move(this GameObject obj, GameObject to, float t)
|
||||
{
|
||||
return PlatinioTween.instance.Move(obj , to , t);
|
||||
}
|
||||
|
||||
public static BaseTween MoveAtSpeed(this GameObject obj, GameObject to, float speed)
|
||||
{
|
||||
return PlatinioTween.instance.MoveAtSpeed(obj , to , speed);
|
||||
}
|
||||
|
||||
public static BaseTween Move(this Transform obj, GameObject to, float t)
|
||||
{
|
||||
return PlatinioTween.instance.Move(obj , to , t);
|
||||
}
|
||||
|
||||
public static BaseTween MoveAtSpeed(this Transform obj, GameObject to, float speed)
|
||||
{
|
||||
return PlatinioTween.instance.MoveAtSpeed(obj , to , speed);
|
||||
}
|
||||
|
||||
public static BaseTween Move(this RectTransform rect, Vector2 pos, float t)
|
||||
{
|
||||
return PlatinioTween.instance.Move(rect , pos , t);
|
||||
}
|
||||
|
||||
public static BaseTween MoveAtSpeed(this RectTransform rect, Vector2 pos, float speed)
|
||||
{
|
||||
return PlatinioTween.instance.MoveAtSpeed(rect , pos , speed);
|
||||
}
|
||||
|
||||
public static BaseTween MoveUI(this RectTransform rect, Vector2 absolutePosition, RectTransform canvas, float t, PivotPreset pivotPreset = PivotPreset.MiddleCenter)
|
||||
{
|
||||
return PlatinioTween.instance.MoveUI(rect , absolutePosition , canvas, t , pivotPreset);
|
||||
}
|
||||
|
||||
|
||||
public static BaseTween MoveUIAtSpeed(this RectTransform rect, Vector2 absolutePosition, RectTransform canvas, float speed , PivotPreset pivotPreset = PivotPreset.MiddleCenter)
|
||||
{
|
||||
return PlatinioTween.instance.MoveUIAtSpeed(rect , absolutePosition , canvas , speed , pivotPreset);
|
||||
}
|
||||
|
||||
public static BaseTween TranslateUI(this RectTransform rect, Vector2 translation, RectTransform canvas, float t, PivotPreset pivotPreset = PivotPreset.MiddleCenter)
|
||||
{
|
||||
return PlatinioTween.instance.TranslateUI(rect , translation , canvas , t , pivotPreset);
|
||||
}
|
||||
|
||||
public static BaseTween TranslateUIAtSpeed(this RectTransform rect, Vector2 translation, RectTransform canvas, float speed, PivotPreset pivotPreset = PivotPreset.MiddleCenter)
|
||||
{
|
||||
return PlatinioTween.instance.TranslateUIAtSpeed( rect, translation, canvas, speed, pivotPreset );
|
||||
}
|
||||
|
||||
public static void CancelAllTweens(this GameObject go)
|
||||
{
|
||||
if(!PlatinioTween.ApplicationIsQuitting)
|
||||
PlatinioTween.instance.CancelTween(go);
|
||||
}
|
||||
|
||||
public static void CancelTween(this GameObject go , int id)
|
||||
{
|
||||
PlatinioTween.instance.CancelTween(id);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,18 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 4f7c0c68aa0f56c4e9d9fef256687ba9
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
AssetOrigin:
|
||||
serializedVersion: 1
|
||||
productId: 168243
|
||||
packageName: VR Beats Kit
|
||||
packageVersion: 2.0
|
||||
assetPath: Assets/VRBeatsKit/Scripts/PlatinioTween/Scripts/Core/PlatinioTweenExtension.cs
|
||||
uploadId: 546658
|
||||
@@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: faa5ea63234c43a49a35a76eb78259a8
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,203 @@
|
||||
using UnityEngine;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
|
||||
namespace Platinio.TweenEngine
|
||||
{
|
||||
public enum UpdateMode
|
||||
{
|
||||
Update,
|
||||
LateUpdate,
|
||||
FixedUpdate
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Base tween class
|
||||
/// </summary>
|
||||
|
||||
public abstract class BaseTween
|
||||
{
|
||||
#region PROTECTED
|
||||
protected int id = 0;
|
||||
protected float delay = 0.0f;
|
||||
protected float startTime = 0.0f;
|
||||
protected float duration = 0.0f;
|
||||
protected float currentTime = 0.0f;
|
||||
protected Ease ease = Ease.Linear;
|
||||
protected UpdateMode updateMode = UpdateMode.Update;
|
||||
protected GameObject owner = null;
|
||||
private float timeSinceStart = 0.0f;
|
||||
#endregion
|
||||
|
||||
public int ID { get { return id; } }
|
||||
|
||||
#region EVENTS
|
||||
protected Action onComplete = null;
|
||||
protected Action onUpdate = null;
|
||||
protected Action<Vector3> onUpdateVector3 = null;
|
||||
protected Action<float> onUpdateFloat = null;
|
||||
protected Action<Color> onUpdateColor = null;
|
||||
protected Action<Vector2> onUpdateVector2 = null;
|
||||
protected List<TimeEvent> events = new List<TimeEvent>();
|
||||
#endregion
|
||||
|
||||
public GameObject Owner { get { return owner; } }
|
||||
public UpdateMode UpdateMode { get { return updateMode; } }
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Called to update this tween
|
||||
/// </summary>
|
||||
public virtual void Update(float deltaTime)
|
||||
{
|
||||
timeSinceStart += deltaTime;
|
||||
|
||||
if (events.Count > 0 && timeSinceStart >= events[0].Time)
|
||||
{
|
||||
events[0].Action();
|
||||
events.RemoveAt(0);
|
||||
}
|
||||
|
||||
if(onUpdate != null)
|
||||
onUpdate();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Set ease type
|
||||
/// </summary>
|
||||
/// <param name="ease"></param>
|
||||
public virtual BaseTween SetEase(Ease ease)
|
||||
{
|
||||
this.ease = ease;
|
||||
return this;
|
||||
}
|
||||
|
||||
public BaseTween SetEvent(Action action, float t)
|
||||
{
|
||||
events.Add(new TimeEvent(action, t));
|
||||
|
||||
//sort this list
|
||||
if (events.Count > 1)
|
||||
events = events.OrderBy(o => o.Time).ToList();
|
||||
|
||||
|
||||
return this;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Set callback for onComplete
|
||||
/// </summary>
|
||||
/// <param name="action"></param>
|
||||
/// <returns></returns>
|
||||
public virtual BaseTween SetOnComplete(Action action)
|
||||
{
|
||||
onComplete += action;
|
||||
return this;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// set a delay
|
||||
/// </summary>
|
||||
/// <param name="t">delay in seconds </param>
|
||||
/// <returns></returns>
|
||||
public virtual BaseTween SetDelay(float t)
|
||||
{
|
||||
delay = t;
|
||||
|
||||
return this;
|
||||
}
|
||||
|
||||
public virtual BaseTween SetOnUpdate(Action action)
|
||||
{
|
||||
onUpdate += action;
|
||||
return this;
|
||||
}
|
||||
|
||||
public virtual BaseTween SetOnUpdateVector2(Action<Vector2> action)
|
||||
{
|
||||
onUpdateVector2 += action;
|
||||
return this;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Set Callback for OnUpdate
|
||||
/// </summary>
|
||||
/// <param name="action"></param>
|
||||
/// <returns></returns>
|
||||
public virtual BaseTween SetOnUpdateVector3(Action<Vector3> action)
|
||||
{
|
||||
onUpdateVector3 += action;
|
||||
return this;
|
||||
}
|
||||
|
||||
public virtual BaseTween SetOnUpdateColor(Action<Color> action)
|
||||
{
|
||||
onUpdateColor += action;
|
||||
return this;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Set Callback for OnUpdate
|
||||
/// </summary>
|
||||
/// <param name="action"></param>
|
||||
/// <returns></returns>
|
||||
public virtual BaseTween SetOnUpdateFloat(Action<float> action)
|
||||
{
|
||||
onUpdateFloat += action;
|
||||
return this;
|
||||
}
|
||||
|
||||
public virtual BaseTween SetOwner(GameObject owner)
|
||||
{
|
||||
this.owner = owner;
|
||||
PlatinioTween.instance.ProcessConnection(this);
|
||||
return this;
|
||||
}
|
||||
|
||||
public virtual BaseTween SetUpdateMode(UpdateMode updateMode)
|
||||
{
|
||||
this.updateMode = updateMode;
|
||||
return this;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Restore all fields to default
|
||||
/// </summary>
|
||||
public virtual void Reset()
|
||||
{
|
||||
id = 0;
|
||||
delay = 0.0f;
|
||||
startTime = 0.0f;
|
||||
duration = 0.0f;
|
||||
currentTime = 0.0f;
|
||||
ease = Ease.Linear;
|
||||
updateMode = UpdateMode.Update;
|
||||
owner = null;
|
||||
timeSinceStart = 0.0f;
|
||||
|
||||
onComplete = null;
|
||||
onUpdate = null;
|
||||
onUpdateVector3 = null;
|
||||
onUpdateFloat = null;
|
||||
onUpdateColor = null;
|
||||
onUpdateVector2 = null;
|
||||
events.Clear();
|
||||
}
|
||||
}
|
||||
|
||||
public class TimeEvent
|
||||
{
|
||||
public Action Action;
|
||||
public float Time;
|
||||
|
||||
public TimeEvent(Action action, float t)
|
||||
{
|
||||
Action = action;
|
||||
Time = t;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -0,0 +1,18 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 461fc3ea6bb961242b83b6ab52c1d7e7
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
AssetOrigin:
|
||||
serializedVersion: 1
|
||||
productId: 168243
|
||||
packageName: VR Beats Kit
|
||||
packageVersion: 2.0
|
||||
assetPath: Assets/VRBeatsKit/Scripts/PlatinioTween/Scripts/Core/Tweens/BaseTween.cs
|
||||
uploadId: 546658
|
||||
@@ -0,0 +1,71 @@
|
||||
using UnityEngine;
|
||||
|
||||
namespace Platinio.TweenEngine
|
||||
{
|
||||
public class ColorTween : BaseTween
|
||||
{
|
||||
private Color from = Color.white;
|
||||
private Color to = Color.white;
|
||||
|
||||
public ColorTween(Color from, Color to, float t, int id)
|
||||
{
|
||||
this.from = from;
|
||||
this.to = to;
|
||||
this.duration = t;
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
public override void Update(float deltaTime)
|
||||
{
|
||||
|
||||
//wait a delay
|
||||
if (delay > 0.0f)
|
||||
{
|
||||
delay -= deltaTime;
|
||||
return;
|
||||
}
|
||||
|
||||
base.Update(deltaTime);
|
||||
|
||||
//start counting time
|
||||
currentTime += deltaTime;
|
||||
|
||||
//if time ends
|
||||
if (currentTime >= duration)
|
||||
{
|
||||
if (onUpdateColor != null)
|
||||
onUpdateColor(this.to);
|
||||
|
||||
onComplete();
|
||||
return;
|
||||
}
|
||||
|
||||
/*
|
||||
Vector3 to = new Vector3( this.to.r, this.to.g, this.to.b );
|
||||
Vector3 from = new Vector3( this.from.r, this.from.g, this.from.b );
|
||||
|
||||
//get new value
|
||||
Vector3 change = to - from;
|
||||
Vector3 value = Equations.ChangeVector( currentTime, from, change, duration, ease );
|
||||
|
||||
//get new value
|
||||
float alphaChange = this.to.a - this.from.a;
|
||||
float alphaValue = Equations.ChangeFloat( currentTime, this.from.a, alphaChange, duration, ease );
|
||||
*/
|
||||
Color color = Color.LerpUnclamped(from, to, EasingFunctions.ChangeFloat(0.0f, 1.0f, currentTime / duration, ease));
|
||||
|
||||
//call update if we have it
|
||||
if (onUpdateColor != null)
|
||||
onUpdateColor(color);
|
||||
}
|
||||
|
||||
internal void Init(Color from, Color to, float t)
|
||||
{
|
||||
this.from = from;
|
||||
this.to = to;
|
||||
this.duration = t;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -0,0 +1,18 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 33a7fcc0876e8054f802c0bc073ee830
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
AssetOrigin:
|
||||
serializedVersion: 1
|
||||
productId: 168243
|
||||
packageName: VR Beats Kit
|
||||
packageVersion: 2.0
|
||||
assetPath: Assets/VRBeatsKit/Scripts/PlatinioTween/Scripts/Core/Tweens/ColorTween.cs
|
||||
uploadId: 546658
|
||||
@@ -0,0 +1,87 @@
|
||||
using UnityEngine;
|
||||
|
||||
|
||||
namespace Platinio.TweenEngine
|
||||
{
|
||||
public class MoveTween : BaseTween
|
||||
{
|
||||
#region PRIVATE
|
||||
private Transform obj = null;
|
||||
private Transform to = null;
|
||||
private Vector3 initialPos = Vector3.zero;
|
||||
#endregion
|
||||
|
||||
#region PUBLIC
|
||||
public MoveTween(Transform obj, Transform to, float t, int id)
|
||||
{
|
||||
Init(obj, to, t);
|
||||
}
|
||||
|
||||
public void Init(Transform obj, Transform to, float t)
|
||||
{
|
||||
this.obj = obj;
|
||||
this.to = to;
|
||||
this.duration = t;
|
||||
this.initialPos = obj.position;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// called every frame
|
||||
/// </summary>
|
||||
public override void Update(float deltaTime)
|
||||
{
|
||||
|
||||
//wait a delay
|
||||
if (delay > 0.0f)
|
||||
{
|
||||
delay -= deltaTime;
|
||||
return;
|
||||
}
|
||||
|
||||
base.Update(deltaTime);
|
||||
|
||||
//start counting time
|
||||
currentTime += deltaTime;
|
||||
|
||||
//if time ends
|
||||
if (currentTime >= duration)
|
||||
{
|
||||
obj.position = to.position;
|
||||
|
||||
CallOnUpdate();
|
||||
|
||||
onComplete();
|
||||
return;
|
||||
}
|
||||
|
||||
//get new value
|
||||
//Vector3 change = to.position - initialPos;
|
||||
//obj.position = Equations.ChangeVector( currentTime, initialPos, change, duration, ease );
|
||||
|
||||
obj.position = EasingFunctions.ChangeVector(initialPos, to.position, currentTime / duration, ease);
|
||||
|
||||
CallOnUpdate();
|
||||
|
||||
}
|
||||
#endregion
|
||||
|
||||
private void CallOnUpdate()
|
||||
{
|
||||
if(onUpdateVector3 != null)
|
||||
onUpdateVector3(obj.position);
|
||||
|
||||
if(onUpdateVector2 != null)
|
||||
onUpdateVector2(obj.position);
|
||||
}
|
||||
|
||||
public override void Reset()
|
||||
{
|
||||
base.Reset();
|
||||
obj = null;
|
||||
to = null;
|
||||
initialPos = Vector3.zero;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -0,0 +1,20 @@
|
||||
fileFormatVersion: 2
|
||||
guid: fd3d1af25b95db3408e5a98866cd9c4b
|
||||
timeCreated: 1525053541
|
||||
licenseType: Store
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
AssetOrigin:
|
||||
serializedVersion: 1
|
||||
productId: 168243
|
||||
packageName: VR Beats Kit
|
||||
packageVersion: 2.0
|
||||
assetPath: Assets/VRBeatsKit/Scripts/PlatinioTween/Scripts/Core/Tweens/MoveTween.cs
|
||||
uploadId: 546658
|
||||
@@ -0,0 +1,72 @@
|
||||
|
||||
namespace Platinio.TweenEngine
|
||||
{
|
||||
public class ValueTween : BaseTween
|
||||
{
|
||||
#region PRIVATE
|
||||
private float from = 0.0f;
|
||||
private float to = 0.0f;
|
||||
#endregion
|
||||
|
||||
#region PUBLIC
|
||||
public ValueTween(float from, float to, float t, int id)
|
||||
{
|
||||
this.id = id;
|
||||
Init(from, to, t);
|
||||
}
|
||||
|
||||
public void Init(float from, float to, float t)
|
||||
{
|
||||
this.from = from;
|
||||
this.to = to;
|
||||
this.duration = t;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// called every frame
|
||||
/// </summary>
|
||||
public override void Update(float deltaTime)
|
||||
{
|
||||
|
||||
//wait a delay
|
||||
if (delay > 0.0f)
|
||||
{
|
||||
delay -= deltaTime;
|
||||
return;
|
||||
}
|
||||
|
||||
base.Update(deltaTime);
|
||||
|
||||
//start counting time
|
||||
currentTime += deltaTime;
|
||||
|
||||
//if time ends
|
||||
if (currentTime >= duration)
|
||||
{
|
||||
|
||||
if (onUpdateFloat != null)
|
||||
onUpdateFloat(to);
|
||||
if(onComplete != null)
|
||||
onComplete();
|
||||
return;
|
||||
}
|
||||
|
||||
//get new value
|
||||
float value = EasingFunctions.ChangeFloat(from, to, currentTime / duration, ease);
|
||||
|
||||
//call update if we have it
|
||||
if (onUpdateFloat != null)
|
||||
onUpdateFloat(value);
|
||||
}
|
||||
#endregion
|
||||
|
||||
public override void Reset()
|
||||
{
|
||||
base.Reset();
|
||||
from = 0;
|
||||
to = 0;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -0,0 +1,20 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 73babbdceb2becb47b129555d3cceb4d
|
||||
timeCreated: 1525052784
|
||||
licenseType: Store
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
AssetOrigin:
|
||||
serializedVersion: 1
|
||||
productId: 168243
|
||||
packageName: VR Beats Kit
|
||||
packageVersion: 2.0
|
||||
assetPath: Assets/VRBeatsKit/Scripts/PlatinioTween/Scripts/Core/Tweens/ValueTween.cs
|
||||
uploadId: 546658
|
||||
@@ -0,0 +1,69 @@
|
||||
using System;
|
||||
using UnityEngine;
|
||||
|
||||
namespace Platinio.TweenEngine
|
||||
{
|
||||
|
||||
public class Vector2Tween : BaseTween
|
||||
{
|
||||
#region PRIVATE
|
||||
private Vector2 from = Vector3.zero;
|
||||
private Vector2 to = Vector3.zero;
|
||||
#endregion
|
||||
|
||||
#region PUBLIC
|
||||
public Vector2Tween(Vector2 from, Vector2 to, float t, int id)
|
||||
{
|
||||
Init(from, to, t);
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// called every frame
|
||||
/// </summary>
|
||||
public override void Update(float deltaTime)
|
||||
{
|
||||
|
||||
//wait a delay
|
||||
if (delay > 0.0f)
|
||||
{
|
||||
delay -= deltaTime;
|
||||
return;
|
||||
}
|
||||
|
||||
base.Update(deltaTime);
|
||||
|
||||
//start counting time
|
||||
currentTime += deltaTime;
|
||||
|
||||
//if time ends
|
||||
if (currentTime >= duration)
|
||||
{
|
||||
|
||||
if(onUpdateVector2 != null)
|
||||
onUpdateVector2(to);
|
||||
|
||||
onComplete();
|
||||
return;
|
||||
}
|
||||
|
||||
//get the new value
|
||||
Vector2 value = EasingFunctions.ChangeVector(from, to, currentTime / duration, ease);
|
||||
|
||||
//Vector2 vector2Value = new Vector2(value.x , value.y);
|
||||
|
||||
//call update if we have it
|
||||
if(onUpdateVector2 != null)
|
||||
onUpdateVector2(value);
|
||||
}
|
||||
|
||||
internal void Init(Vector2 from, Vector2 to, float t)
|
||||
{
|
||||
this.from = from;
|
||||
this.to = to;
|
||||
this.duration = t;
|
||||
}
|
||||
#endregion
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,18 @@
|
||||
fileFormatVersion: 2
|
||||
guid: f0126ef4430eb3d41b63fd6050890dfb
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
AssetOrigin:
|
||||
serializedVersion: 1
|
||||
productId: 168243
|
||||
packageName: VR Beats Kit
|
||||
packageVersion: 2.0
|
||||
assetPath: Assets/VRBeatsKit/Scripts/PlatinioTween/Scripts/Core/Tweens/Vector2Tween.cs
|
||||
uploadId: 546658
|
||||
@@ -0,0 +1,73 @@
|
||||
using System;
|
||||
using UnityEngine;
|
||||
|
||||
namespace Platinio.TweenEngine
|
||||
{
|
||||
|
||||
public class Vector3Tween : BaseTween
|
||||
{
|
||||
#region PRIVATE
|
||||
private Vector3 from = Vector3.zero;
|
||||
private Vector3 to = Vector3.zero;
|
||||
#endregion
|
||||
|
||||
#region PUBLIC
|
||||
public Vector3Tween(Vector3 from, Vector3 to, float t, int id)
|
||||
{
|
||||
Init(from, to, t);
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// called every frame
|
||||
/// </summary>
|
||||
public override void Update(float deltaTime)
|
||||
{
|
||||
|
||||
//wait a delay
|
||||
if (delay > 0.0f)
|
||||
{
|
||||
delay -= deltaTime;
|
||||
return;
|
||||
}
|
||||
|
||||
base.Update(deltaTime);
|
||||
|
||||
//start counting time
|
||||
currentTime += deltaTime;
|
||||
|
||||
//if time ends
|
||||
if (currentTime >= duration)
|
||||
{
|
||||
|
||||
if (onUpdateVector3 != null)
|
||||
onUpdateVector3(to);
|
||||
|
||||
if (onUpdateVector2 != null)
|
||||
onUpdateVector2(to);
|
||||
|
||||
onComplete();
|
||||
return;
|
||||
}
|
||||
|
||||
//get new value
|
||||
Vector3 value = EasingFunctions.ChangeVector(from, to, currentTime / duration, ease);
|
||||
|
||||
//call update if we have it
|
||||
if (onUpdateVector3 != null)
|
||||
onUpdateVector3(value);
|
||||
|
||||
if (onUpdateVector2 != null)
|
||||
onUpdateVector2(value);
|
||||
}
|
||||
|
||||
internal void Init(Vector3 from, Vector3 to, float time)
|
||||
{
|
||||
this.from = from;
|
||||
this.to = to;
|
||||
this.duration = time;
|
||||
}
|
||||
#endregion
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,19 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 88064f469581a544b86875cc7018ee69
|
||||
timeCreated: 1525022226
|
||||
licenseType: Store
|
||||
MonoImporter:
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
AssetOrigin:
|
||||
serializedVersion: 1
|
||||
productId: 168243
|
||||
packageName: VR Beats Kit
|
||||
packageVersion: 2.0
|
||||
assetPath: Assets/VRBeatsKit/Scripts/PlatinioTween/Scripts/Core/Tweens/Vector3Tween.cs
|
||||
uploadId: 546658
|
||||
@@ -0,0 +1,802 @@
|
||||
using UnityEngine;
|
||||
using UnityEngine.UI;
|
||||
using System.Collections.Generic;
|
||||
using System;
|
||||
using Platinio.UI;
|
||||
|
||||
namespace Platinio.TweenEngine
|
||||
{
|
||||
|
||||
/// <summary>
|
||||
/// Tween engine
|
||||
/// </summary>
|
||||
public class PlatinioTween : Singleton<PlatinioTween>
|
||||
{
|
||||
#region PRIVATE
|
||||
private List<BaseTween> tweens = TweenPool.activeTweens;
|
||||
private Dictionary<GameObject, List<int>> tweenConnections = new Dictionary<GameObject, List<int>>();
|
||||
#endregion
|
||||
|
||||
#region UNITY_EVENTS
|
||||
protected override void Awake()
|
||||
{
|
||||
base.Awake();
|
||||
}
|
||||
|
||||
private void Update()
|
||||
{
|
||||
|
||||
for(int n = 0; n < tweens.Count; n++)
|
||||
{
|
||||
int lastTweenSize = tweens.Count;
|
||||
|
||||
if (tweens[n].UpdateMode == UpdateMode.Update)
|
||||
tweens[n].Update(Time.deltaTime);
|
||||
|
||||
//was any tween remove in this update?
|
||||
if (lastTweenSize != tweens.Count)
|
||||
{
|
||||
n--;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
private void LateUpdate()
|
||||
{
|
||||
for (int n = 0; n < tweens.Count; n++)
|
||||
{
|
||||
int lastTweenSize = tweens.Count;
|
||||
|
||||
if (tweens[n].UpdateMode == UpdateMode.LateUpdate)
|
||||
tweens[n].Update(Time.deltaTime);
|
||||
|
||||
//was any tween remove in this update?
|
||||
if (lastTweenSize != tweens.Count)
|
||||
{
|
||||
n--;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private void FixedUpdate()
|
||||
{
|
||||
for (int n = 0; n < tweens.Count; n++)
|
||||
{
|
||||
int lastTweenSize = tweens.Count;
|
||||
|
||||
if (tweens[n].UpdateMode == UpdateMode.FixedUpdate)
|
||||
tweens[n].Update(Time.deltaTime);
|
||||
|
||||
//was any tween remove in this update?
|
||||
if (lastTweenSize != tweens.Count)
|
||||
{
|
||||
n--;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
|
||||
|
||||
private BaseTween ProcessTween(BaseTween tween)
|
||||
{
|
||||
tween.SetOnComplete(() => CancelTween(tween));
|
||||
return tween;
|
||||
}
|
||||
|
||||
public void ProcessConnection(BaseTween tween)
|
||||
{
|
||||
List<int> idList;
|
||||
if (tweenConnections.TryGetValue(tween.Owner, out idList))
|
||||
{
|
||||
if (idList == null)
|
||||
{
|
||||
idList = new List<int>();
|
||||
}
|
||||
|
||||
idList.Add(tween.ID);
|
||||
}
|
||||
|
||||
else
|
||||
{
|
||||
tweenConnections[tween.Owner] = new List<int>() { tween.ID };
|
||||
}
|
||||
}
|
||||
|
||||
public void CancelTween(int id)
|
||||
{
|
||||
|
||||
for (int n = 0; n < tweens.Count; n++)
|
||||
{
|
||||
if (tweens[n].ID == id)
|
||||
{
|
||||
tweens.Remove(tweens[n]);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public void CancelTween(BaseTween tween)
|
||||
{
|
||||
if (tween != null)
|
||||
CancelTween(tween.ID);
|
||||
}
|
||||
|
||||
|
||||
public void CancelTween(GameObject owner)
|
||||
{
|
||||
List<int> idList = null;
|
||||
|
||||
if (tweenConnections.TryGetValue(owner, out idList))
|
||||
{
|
||||
if (idList == null)
|
||||
return;
|
||||
|
||||
for (int n = 0; n < idList.Count; n++)
|
||||
{
|
||||
CancelTween(idList[n]);
|
||||
}
|
||||
|
||||
tweenConnections.Remove(owner);
|
||||
}
|
||||
}
|
||||
|
||||
#region SCALE_TWEENS
|
||||
public BaseTween ScaleTween(Transform t, Vector3 to, float time)
|
||||
{
|
||||
Vector3Tween tween = TweenPool.GetVector3Tween(t.localScale, to, time);
|
||||
tween.SetOnUpdateVector3(delegate (Vector3 v)
|
||||
{
|
||||
if (t == null)
|
||||
{
|
||||
CancelTween(tween);
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
t.localScale = v;
|
||||
});
|
||||
return ProcessTween(tween);
|
||||
}
|
||||
|
||||
public BaseTween ScaleTween(GameObject go, Vector3 to, float time)
|
||||
{
|
||||
return ScaleTween(go.transform, to, time);
|
||||
}
|
||||
|
||||
public BaseTween ScaleTween(RectTransform rect, Vector3 to, float time)
|
||||
{
|
||||
return ScaleTween(rect.transform, to, time);
|
||||
}
|
||||
|
||||
public BaseTween ScaleTweenAtSpeed(Transform t, Vector3 to, float speed)
|
||||
{
|
||||
float time = Vector3.Distance(t.position, to) / speed;
|
||||
|
||||
return ScaleTween(t, to, time);
|
||||
}
|
||||
|
||||
public BaseTween ScaleTweenAtSpeed(GameObject go, Vector3 to, float speed)
|
||||
{
|
||||
float time = Vector3.Distance(go.transform.position, to) / speed;
|
||||
|
||||
return ScaleTween(go, to, time);
|
||||
}
|
||||
|
||||
public BaseTween ScaleTweenAtSpeed(RectTransform rect, Vector3 to, float speed)
|
||||
{
|
||||
float time = Vector3.Distance(rect.transform.position, to) / speed;
|
||||
|
||||
return ScaleTween(rect.transform, to, time);
|
||||
}
|
||||
public BaseTween ScaleX(Transform obj, float value, float t)
|
||||
{
|
||||
return ValueTween(obj.localScale.x, value, t).SetOnUpdateFloat((float v) =>
|
||||
{
|
||||
if (obj == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
Vector3 currentScale = obj.localScale;
|
||||
currentScale.x = v;
|
||||
obj.localScale = currentScale;
|
||||
});
|
||||
}
|
||||
|
||||
public BaseTween ScaleX(GameObject obj, float value, float t)
|
||||
{
|
||||
return ScaleX(obj.transform, value, t);
|
||||
}
|
||||
|
||||
public BaseTween ScaleX(RectTransform obj, float value, float t)
|
||||
{
|
||||
return ScaleX(obj.transform, value, t);
|
||||
}
|
||||
|
||||
public BaseTween ScaleXAtSpeed(Transform obj, float value, float speed)
|
||||
{
|
||||
float time = Math.Abs(obj.localScale.x - value) / speed;
|
||||
return ScaleX(obj, value, time);
|
||||
}
|
||||
|
||||
public BaseTween ScaleXAtSpeed(GameObject obj, float value, float speed)
|
||||
{
|
||||
float time = Math.Abs(obj.transform.localScale.x - value) / speed;
|
||||
return ScaleX(obj, value, time);
|
||||
}
|
||||
|
||||
public BaseTween ScaleXAtSpeed(RectTransform obj, float value, float speed)
|
||||
{
|
||||
float time = Math.Abs(obj.transform.localScale.x - value) / speed;
|
||||
return ScaleX(obj, value, time);
|
||||
}
|
||||
|
||||
|
||||
public BaseTween ScaleY(Transform obj, float value, float t)
|
||||
{
|
||||
return ValueTween(obj.localScale.y, value, t).SetOnUpdateFloat((float v) =>
|
||||
{
|
||||
if (obj == null)
|
||||
return;
|
||||
|
||||
Vector3 currentScale = obj.localScale;
|
||||
currentScale.y = v;
|
||||
obj.localScale = currentScale;
|
||||
});
|
||||
}
|
||||
|
||||
public BaseTween ScaleY(GameObject obj, float value, float t)
|
||||
{
|
||||
return ScaleY(obj.transform, value, t);
|
||||
}
|
||||
|
||||
|
||||
public BaseTween ScaleY(RectTransform obj, float value, float t)
|
||||
{
|
||||
return ScaleY(obj.transform, value, t);
|
||||
}
|
||||
|
||||
public BaseTween ScaleYAtSpeed(Transform obj, float value, float speed)
|
||||
{
|
||||
float time = Math.Abs(obj.localScale.y - value) / speed;
|
||||
return ScaleY(obj, value, time);
|
||||
}
|
||||
|
||||
public BaseTween ScaleYAtSpeed(GameObject obj, float value, float speed)
|
||||
{
|
||||
float time = Math.Abs(obj.transform.localScale.y - value) / speed;
|
||||
return ScaleY(obj, value, time);
|
||||
}
|
||||
|
||||
public BaseTween ScaleYAtSpeed(RectTransform obj, float value, float speed)
|
||||
{
|
||||
float time = Math.Abs(obj.transform.localScale.y - value) / speed;
|
||||
return ScaleY(obj, value, time);
|
||||
}
|
||||
|
||||
|
||||
public BaseTween ScaleZ(Transform obj, float value, float t)
|
||||
{
|
||||
return ValueTween(obj.localScale.z, value, t).SetOnUpdateFloat((float v) =>
|
||||
{
|
||||
if (obj == null)
|
||||
return;
|
||||
|
||||
Vector3 currentScale = obj.localScale;
|
||||
currentScale.z = v;
|
||||
obj.localScale = currentScale;
|
||||
});
|
||||
}
|
||||
|
||||
public BaseTween ScaleZ(GameObject obj, float value, float t)
|
||||
{
|
||||
return ScaleZ(obj.transform, value, t);
|
||||
}
|
||||
|
||||
public BaseTween ScaleZ(RectTransform obj, float value, float t)
|
||||
{
|
||||
return ScaleZ(obj.transform, value, t);
|
||||
}
|
||||
|
||||
public BaseTween ScaleZAtSpeed(Transform obj, float value, float speed)
|
||||
{
|
||||
float time = Math.Abs(obj.localScale.z - value) / speed;
|
||||
return ScaleZ(obj, value, time);
|
||||
}
|
||||
|
||||
public BaseTween ScaleZAtSpeed(GameObject obj, float value, float speed)
|
||||
{
|
||||
float time = Math.Abs(obj.transform.localScale.z - value) / speed;
|
||||
return ScaleZ(obj, value, time);
|
||||
}
|
||||
|
||||
public BaseTween ScaleZAtSpeed(RectTransform obj, float value, float speed)
|
||||
{
|
||||
float time = Math.Abs(obj.transform.localScale.z - value) / speed;
|
||||
return ScaleZ(obj, value, time);
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region ROTATE_TWEENS
|
||||
|
||||
public BaseTween RotateTween(Transform t, Vector3 axis, float to, float time)
|
||||
{
|
||||
Vector3Tween tween = TweenPool.GetVector3Tween(t.rotation.eulerAngles, axis * to, time);
|
||||
tween.SetOnUpdateVector3(delegate (Vector3 v)
|
||||
{
|
||||
if (t == null)
|
||||
{
|
||||
CancelTween(tween);
|
||||
return;
|
||||
}
|
||||
|
||||
t.rotation = Quaternion.Euler(v);
|
||||
});
|
||||
return ProcessTween(tween);
|
||||
}
|
||||
|
||||
public BaseTween RotateTween(GameObject go, Vector3 axis, float to, float time)
|
||||
{
|
||||
return RotateTween(go.transform, axis, to, time);
|
||||
}
|
||||
|
||||
public BaseTween RotateTween(RectTransform rect, Vector3 axis, float to, float time)
|
||||
{
|
||||
return RotateTween(rect.transform, axis, to, time);
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region FADE_TWEENS
|
||||
|
||||
public BaseTween FadeOut(CanvasGroup cg, float t)
|
||||
{
|
||||
return Fade(cg, 0.0f, t);
|
||||
}
|
||||
|
||||
public BaseTween FadeOutAtSpeed(CanvasGroup cg, float speed)
|
||||
{
|
||||
float t = cg.alpha / speed;
|
||||
return Fade(cg, 0.0f, t);
|
||||
}
|
||||
|
||||
public BaseTween FadeIn(CanvasGroup cg, float t)
|
||||
{
|
||||
return Fade(cg, 1.0f, t);
|
||||
}
|
||||
|
||||
public BaseTween FadeInAtSpeed(CanvasGroup cg, float speed)
|
||||
{
|
||||
float t = Mathf.Abs(cg.alpha - 1.0f) / speed;
|
||||
return Fade(cg, 1.0f, t);
|
||||
}
|
||||
|
||||
public BaseTween Fade(CanvasGroup cg, float to, float t)
|
||||
{
|
||||
ValueTween tween = TweenPool.GetValueTween(cg.alpha, to, t);
|
||||
tween.SetOnUpdateFloat(delegate (float v)
|
||||
{
|
||||
if (cg == null)
|
||||
{
|
||||
CancelTween(tween);
|
||||
return;
|
||||
}
|
||||
|
||||
cg.alpha = v;
|
||||
});
|
||||
return ProcessTween(tween);
|
||||
}
|
||||
|
||||
public BaseTween FadeAtSpeed(CanvasGroup cg, float to, float speed)
|
||||
{
|
||||
float t = Math.Abs(cg.alpha - to) / speed;
|
||||
return Fade(cg, to, t);
|
||||
}
|
||||
|
||||
public BaseTween Fade(Image image, float to, float t)
|
||||
{
|
||||
ValueTween tween = TweenPool.GetValueTween(image.color.a, to, t);
|
||||
tween.SetOnUpdateFloat(v =>
|
||||
{
|
||||
if (image == null)
|
||||
{
|
||||
CancelTween(tween);
|
||||
return;
|
||||
}
|
||||
|
||||
Color c = image.color;
|
||||
c.a = v;
|
||||
image.color = c;
|
||||
});
|
||||
return ProcessTween(tween);
|
||||
}
|
||||
|
||||
internal BaseTween SetFloatProperty(Material material, int propertyHash, float value, float t)
|
||||
{
|
||||
ValueTween tween = TweenPool.GetValueTween(material.GetFloat(propertyHash), value, t);
|
||||
tween.SetOnUpdateFloat(v => material.SetFloat(propertyHash, v));
|
||||
return ProcessTween(tween);
|
||||
}
|
||||
|
||||
public BaseTween FadeAtSpeed(Image img, float to, float speed)
|
||||
{
|
||||
float t = Math.Abs(img.color.a - to) / speed;
|
||||
return Fade(img, to, t);
|
||||
}
|
||||
|
||||
public BaseTween FadeOut(Image image, float t)
|
||||
{
|
||||
return Fade(image, 0.0f, t);
|
||||
}
|
||||
|
||||
public BaseTween FadeOutAtSpeed(Image img, float speed)
|
||||
{
|
||||
float t = img.color.a / speed;
|
||||
return Fade(img, 0.0f, t);
|
||||
}
|
||||
|
||||
public BaseTween FadeIn(Image image, float t)
|
||||
{
|
||||
return Fade(image, 1.0f, t);
|
||||
}
|
||||
|
||||
public BaseTween FadeInAtSpeed(Image img, float speed)
|
||||
{
|
||||
float t = Mathf.Abs(img.color.a - 1.0f) / speed;
|
||||
return Fade(img, 1.0f, t);
|
||||
}
|
||||
|
||||
public BaseTween Fade(SpriteRenderer sprite, float to, float t)
|
||||
{
|
||||
ValueTween tween = TweenPool.GetValueTween(sprite.color.a, to, t);
|
||||
tween.SetOnUpdateFloat(delegate (float v)
|
||||
{
|
||||
if (sprite == null)
|
||||
{
|
||||
CancelTween(tween);
|
||||
return;
|
||||
}
|
||||
|
||||
Color c = sprite.color;
|
||||
c.a = v;
|
||||
sprite.color = c;
|
||||
});
|
||||
return ProcessTween(tween);
|
||||
}
|
||||
|
||||
public BaseTween FadeAtSpeed(SpriteRenderer sprite, float to, float speed)
|
||||
{
|
||||
float t = Math.Abs(sprite.color.a - to) / speed;
|
||||
return Fade(sprite, to, t);
|
||||
}
|
||||
|
||||
public BaseTween FadeOut(SpriteRenderer sprite, float t)
|
||||
{
|
||||
return Fade(sprite, 0.0f, t);
|
||||
}
|
||||
|
||||
public BaseTween FadeOutAtSpeed(SpriteRenderer sprite, float speed)
|
||||
{
|
||||
float t = sprite.color.a / speed;
|
||||
return Fade(sprite, 0.0f, t);
|
||||
}
|
||||
|
||||
public BaseTween FadeIn(SpriteRenderer sprite, float t)
|
||||
{
|
||||
return Fade(sprite, 1.0f, t);
|
||||
}
|
||||
|
||||
public BaseTween FadeInAtSpeed(SpriteRenderer sprite, float speed)
|
||||
{
|
||||
float t = Mathf.Abs(sprite.color.a - 1.0f) / speed;
|
||||
return Fade(sprite, 1.0f, t);
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region COLOR_TWEEN
|
||||
|
||||
private Vector3 ColorToVector3(Color c)
|
||||
{
|
||||
return new Vector3(c.r, c.g, c.b);
|
||||
}
|
||||
|
||||
private float CalculateColorDistance(Color a, Color b)
|
||||
{
|
||||
return Vector3.Distance(ColorToVector3(a), ColorToVector3(b));
|
||||
}
|
||||
|
||||
public BaseTween ColorTween(SpriteRenderer sprite, Color to, float t)
|
||||
{
|
||||
ColorTween tween = TweenPool.GetColorTween(sprite.color, to, t);
|
||||
tween.SetOnUpdateColor(delegate (Color c)
|
||||
{
|
||||
if (sprite == null)
|
||||
{
|
||||
TweenPool.FinishTween(tween);
|
||||
return;
|
||||
}
|
||||
|
||||
sprite.color = c;
|
||||
});
|
||||
return ProcessTween(tween);
|
||||
}
|
||||
|
||||
public BaseTween ColorTweenAtSpeed(SpriteRenderer sprite, Color to, float speed)
|
||||
{
|
||||
float t = CalculateColorDistance(sprite.color, to) / speed;
|
||||
return ColorTween(sprite, to, t);
|
||||
}
|
||||
|
||||
public BaseTween ColorTween(Image image, Color to, float t)
|
||||
{
|
||||
ColorTween tween = TweenPool.GetColorTween(image.color, to, t);
|
||||
tween.SetOnUpdateColor(delegate (Color c)
|
||||
{
|
||||
if (image == null)
|
||||
{
|
||||
CancelTween(tween);
|
||||
return;
|
||||
}
|
||||
|
||||
image.color = c;
|
||||
});
|
||||
return ProcessTween(tween);
|
||||
}
|
||||
|
||||
public BaseTween ColorTweenAtSpeed(Image img, Color to, float speed)
|
||||
{
|
||||
float t = CalculateColorDistance(img.color, to) / speed;
|
||||
return ColorTween(img, to, t);
|
||||
}
|
||||
|
||||
public BaseTween ColorTween(Color from, Color to, float t)
|
||||
{
|
||||
ColorTween tween = TweenPool.GetColorTween(from, to, t);
|
||||
return ProcessTween(tween);
|
||||
}
|
||||
|
||||
public BaseTween ColorTweenAtSpeed(Color from, Color to, float speed)
|
||||
{
|
||||
float t = CalculateColorDistance(from, to) / speed;
|
||||
return ColorTween(from, to, t);
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region FILL_AMOUNT_TWEEN
|
||||
public BaseTween FillAmountTween(Image img, float to, float t)
|
||||
{
|
||||
BaseTween tween = ValueTween(img.fillAmount, to, t);
|
||||
tween.SetOnUpdateFloat( delegate (float v)
|
||||
{
|
||||
if (img != null)
|
||||
img.fillAmount = v;
|
||||
else
|
||||
CancelTween(tween);
|
||||
|
||||
} );
|
||||
return tween;
|
||||
}
|
||||
|
||||
public BaseTween FillAmountTweenAtSpeed(Image img, float to, float speed)
|
||||
{
|
||||
BaseTween tween = ValueTweenAtSpeed(img.fillAmount, to, speed);
|
||||
tween.SetOnUpdateFloat(delegate (float v)
|
||||
{
|
||||
if (img != null)
|
||||
img.fillAmount = v;
|
||||
else
|
||||
CancelTween(tween);
|
||||
});
|
||||
return tween;
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region VECTOR_TWEEN
|
||||
public BaseTween VectorTween(Vector2 from, Vector2 to, float t)
|
||||
{
|
||||
Vector2Tween tween = TweenPool.GetVector2Tween(from, to, t);
|
||||
return ProcessTween(tween);
|
||||
}
|
||||
|
||||
public BaseTween VectorTweenAtSpeed(Vector2 from, Vector2 to, float speed)
|
||||
{
|
||||
float t = Vector2.Distance(from, to) / speed;
|
||||
return VectorTween(from, to, t);
|
||||
}
|
||||
|
||||
public BaseTween VectorTween(Vector3 from, Vector3 to, float t)
|
||||
{
|
||||
Vector3Tween tween = TweenPool.GetVector3Tween(from, to, t);
|
||||
return ProcessTween(tween);
|
||||
}
|
||||
|
||||
public BaseTween VectorTweenAtSpeed(Vector3 from, Vector3 to, float speed)
|
||||
{
|
||||
float t = Vector3.Distance(from, to) / speed;
|
||||
return VectorTween(from, to, t);
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
|
||||
#region VALUE_TWEEN
|
||||
public BaseTween ValueTween(float from, float to, float t)
|
||||
{
|
||||
var tween = TweenPool.GetValueTween(from, to, t);
|
||||
return ProcessTween(tween);
|
||||
}
|
||||
|
||||
public BaseTween ValueTweenAtSpeed(float from, float to, float speed)
|
||||
{
|
||||
float t = Math.Abs(from - to) / speed;
|
||||
return ValueTween(from, to, t);
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region MOVE_TWEEN
|
||||
public BaseTween Move(Transform obj, Transform to, float t)
|
||||
{
|
||||
MoveTween tween = TweenPool.GetMoveTween(obj, to, t);
|
||||
return ProcessTween(tween);
|
||||
}
|
||||
|
||||
public BaseTween MoveAtSpeed(Transform obj, Transform to, float speed)
|
||||
{
|
||||
float t = Vector3.Distance(obj.position, to.position) / speed;
|
||||
return Move(obj, to, t);
|
||||
}
|
||||
|
||||
public BaseTween Move(Transform obj, Vector3 to, float t)
|
||||
{
|
||||
Vector3Tween tween = TweenPool.GetVector3Tween(obj.position, to, t);
|
||||
tween.SetOnUpdateVector3((Vector3 pos) =>
|
||||
{
|
||||
if (obj == null)
|
||||
{
|
||||
CancelTween(tween);
|
||||
return;
|
||||
}
|
||||
|
||||
obj.position = pos;
|
||||
});
|
||||
return ProcessTween(tween);
|
||||
}
|
||||
|
||||
public BaseTween MoveAtSpeed(Transform obj, Vector3 to, float speed)
|
||||
{
|
||||
float t = Vector3.Distance(obj.position, to) / speed;
|
||||
return Move(obj, to, t);
|
||||
}
|
||||
|
||||
|
||||
public BaseTween Move(GameObject obj, Transform to, float t)
|
||||
{
|
||||
return Move(obj.transform, to, t);
|
||||
}
|
||||
|
||||
public BaseTween MoveAtSpeed(GameObject obj, Transform to, float speed)
|
||||
{
|
||||
float t = Vector3.Distance(obj.transform.position, to.position) / speed;
|
||||
return Move(obj, to, t);
|
||||
}
|
||||
|
||||
public BaseTween Move(GameObject obj, Vector3 to, float t)
|
||||
{
|
||||
return Move(obj.transform, to, t);
|
||||
}
|
||||
|
||||
public BaseTween MoveAtSpeed(GameObject obj, Vector3 to, float speed)
|
||||
{
|
||||
float t = Vector3.Distance(obj.transform.position, to) / speed;
|
||||
return Move(obj, to, t);
|
||||
}
|
||||
|
||||
public BaseTween Move(GameObject obj, GameObject to, float t)
|
||||
{
|
||||
return Move(obj.transform, to.transform, t);
|
||||
}
|
||||
|
||||
public BaseTween MoveAtSpeed(GameObject obj, GameObject to, float speed)
|
||||
{
|
||||
float t = Vector3.Distance(obj.transform.position, to.transform.position) / speed;
|
||||
return Move(obj, to, t);
|
||||
}
|
||||
|
||||
public BaseTween Move(Transform obj, GameObject to, float t)
|
||||
{
|
||||
return Move(obj, to.transform, t);
|
||||
}
|
||||
|
||||
public BaseTween MoveAtSpeed(Transform obj, GameObject to, float speed)
|
||||
{
|
||||
float t = Vector3.Distance(obj.position, to.transform.position) / speed;
|
||||
return Move(obj, to, t);
|
||||
}
|
||||
|
||||
public BaseTween Move(RectTransform rect, Vector2 pos, float t)
|
||||
{
|
||||
|
||||
return VectorTween(new Vector3(rect.anchoredPosition.x, rect.anchoredPosition.y, 0.0f), new Vector3(pos.x, pos.y, 0.0f), t).SetOnUpdateVector3((Vector3 value) =>
|
||||
{
|
||||
if (rect == null)
|
||||
return;
|
||||
|
||||
rect.anchoredPosition = new Vector2(value.x, value.y);
|
||||
});
|
||||
}
|
||||
|
||||
public BaseTween MoveAtSpeed(RectTransform rect, Vector2 pos, float speed)
|
||||
{
|
||||
float t = Vector2.Distance(new Vector2(rect.anchoredPosition.x, rect.anchoredPosition.y), new Vector2(rect.anchoredPosition.x, rect.anchoredPosition.y)) / speed;
|
||||
return Move(rect, pos, t);
|
||||
}
|
||||
|
||||
//use this to position UI in absolute coordenates
|
||||
//0.0 , 1.0 _______________________1.0 , 1.0
|
||||
// | |
|
||||
// | |
|
||||
// | |
|
||||
// | |
|
||||
//0.0 , 0.0 |______________________| 1.0 , 0.0
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Move a UI element using absolute position
|
||||
/// Note: dont use this on Awake
|
||||
/// </summary>
|
||||
/// <param name="rect"></param>
|
||||
/// <param name="absolutePosition"></param>
|
||||
/// <param name="canvas"></param>
|
||||
/// <param name="t"></param>
|
||||
/// <returns></returns>
|
||||
|
||||
public BaseTween MoveUI(RectTransform rect, Vector2 absolutePosition, RectTransform canvas, float t, PivotPreset pivotPreset = PivotPreset.MiddleCenter)
|
||||
{
|
||||
Vector2 pos = rect.FromAbsolutePositionToAnchoredPosition(absolutePosition, canvas, pivotPreset);
|
||||
|
||||
return Move(rect, pos, t);
|
||||
}
|
||||
|
||||
public BaseTween MoveUIAtSpeed(RectTransform rect, Vector2 absolutePosition, RectTransform canvas, float speed, PivotPreset pivotPreset = PivotPreset.MiddleCenter)
|
||||
{
|
||||
|
||||
Vector2 pos = rect.FromAbsolutePositionToAnchoredPosition(absolutePosition, canvas, pivotPreset);
|
||||
|
||||
float time = Vector3.Distance(rect.anchoredPosition, pos) / speed;
|
||||
|
||||
return MoveUI(rect, absolutePosition, canvas, time, pivotPreset);
|
||||
}
|
||||
|
||||
public BaseTween TranslateUI(RectTransform rect, Vector2 translation, RectTransform canvas, float t, PivotPreset pivotPreset = PivotPreset.MiddleCenter)
|
||||
{
|
||||
Vector2 pos = rect.FromAnchoredPositionToAbsolutePosition(canvas, pivotPreset);
|
||||
Vector2 finalPos = pos + translation;
|
||||
|
||||
return MoveUI(rect, finalPos, canvas, t, pivotPreset);
|
||||
}
|
||||
|
||||
public BaseTween TranslateUIAtSpeed(RectTransform rect, Vector2 translation, RectTransform canvas, float speed, PivotPreset pivotPreset = PivotPreset.MiddleCenter)
|
||||
{
|
||||
Vector2 pos = rect.FromAnchoredPositionToAbsolutePosition(canvas, pivotPreset);
|
||||
Vector2 finalPos = pos + translation;
|
||||
|
||||
return MoveUIAtSpeed(rect, finalPos, canvas, speed, pivotPreset);
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -0,0 +1,19 @@
|
||||
fileFormatVersion: 2
|
||||
guid: e3a9ca174fc52464e802851465a793ee
|
||||
timeCreated: 1525013219
|
||||
licenseType: Store
|
||||
MonoImporter:
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
AssetOrigin:
|
||||
serializedVersion: 1
|
||||
productId: 168243
|
||||
packageName: VR Beats Kit
|
||||
packageVersion: 2.0
|
||||
assetPath: Assets/VRBeatsKit/Scripts/PlatinioTween/Scripts/PlatinioTween.cs
|
||||
uploadId: 546658
|
||||
@@ -0,0 +1,170 @@
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
using System;
|
||||
|
||||
namespace Platinio.TweenEngine
|
||||
{
|
||||
public static class TweenPool
|
||||
{
|
||||
static List<ValueTween> valueTweens = new List<ValueTween>();
|
||||
static List<Vector2Tween> vector2Tweens = new List<Vector2Tween>();
|
||||
static List<Vector3Tween> vector3Tweens = new List<Vector3Tween>();
|
||||
static List<MoveTween> moveTweens = new List<MoveTween>();
|
||||
static List<ColorTween> colorTweens = new List<ColorTween>();
|
||||
|
||||
static int counter = 0;
|
||||
|
||||
static List<BaseTween> _activeTweens = new List<BaseTween>();
|
||||
public static List<BaseTween> activeTweens;
|
||||
|
||||
static TweenPool()
|
||||
{
|
||||
activeTweens = _activeTweens;
|
||||
}
|
||||
|
||||
private static int GenerateId()
|
||||
{
|
||||
try
|
||||
{
|
||||
counter++;
|
||||
}
|
||||
catch (OverflowException)
|
||||
{
|
||||
counter = 0;
|
||||
}
|
||||
|
||||
return counter;
|
||||
}
|
||||
public static void FinishTween(BaseTween tween)
|
||||
{
|
||||
_activeTweens.Remove(tween);
|
||||
AddTweenToPool(tween);
|
||||
}
|
||||
|
||||
private static void AddTweenToPool(BaseTween tween)
|
||||
{
|
||||
if (tween is ValueTween)
|
||||
{
|
||||
valueTweens.Add( tween as ValueTween );
|
||||
}
|
||||
else if (tween is MoveTween)
|
||||
{
|
||||
moveTweens.Add( tween as MoveTween );
|
||||
}
|
||||
else if (tween is Vector2Tween)
|
||||
{
|
||||
vector2Tweens.Add( tween as Vector2Tween );
|
||||
}
|
||||
else if (tween is Vector3Tween)
|
||||
{
|
||||
vector3Tweens.Add( tween as Vector3Tween );
|
||||
}
|
||||
else if (tween is ColorTween)
|
||||
{
|
||||
colorTweens.Add(tween as ColorTween);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private static bool TryGetTween<T>(List<T> list, out T tween) where T : BaseTween
|
||||
{
|
||||
if (list.Count > 0)
|
||||
{
|
||||
int last = list.Count - 1;
|
||||
tween = list[last];
|
||||
list.RemoveAt(last);
|
||||
tween.Reset();
|
||||
return true;
|
||||
}
|
||||
else
|
||||
{
|
||||
tween = null;
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
public static ValueTween GetValueTween(float start, float end, float t)
|
||||
{
|
||||
ValueTween tween;
|
||||
if (TryGetTween(valueTweens, out tween))
|
||||
{
|
||||
tween.Reset();
|
||||
tween.Init(start, end, t);
|
||||
}
|
||||
else
|
||||
{
|
||||
tween = new ValueTween(start, end, t, GenerateId());
|
||||
}
|
||||
|
||||
_activeTweens.Add(tween);
|
||||
return tween;
|
||||
}
|
||||
|
||||
internal static MoveTween GetMoveTween(Transform obj, Transform to, float t)
|
||||
{
|
||||
MoveTween tween;
|
||||
if (TryGetTween(moveTweens, out tween))
|
||||
{
|
||||
tween.Init(obj, to, t);
|
||||
}
|
||||
else
|
||||
{
|
||||
tween = new MoveTween(obj, to, t, GenerateId());
|
||||
}
|
||||
|
||||
_activeTweens.Add(tween);
|
||||
return tween;
|
||||
}
|
||||
|
||||
internal static Vector3Tween GetVector3Tween(Vector3 from, Vector3 to, float time)
|
||||
{
|
||||
Vector3Tween tween;
|
||||
if (TryGetTween(vector3Tweens, out tween))
|
||||
{
|
||||
tween.Init(from, to, time);
|
||||
}
|
||||
else
|
||||
{
|
||||
tween = new Vector3Tween(from, to, time, GenerateId());
|
||||
}
|
||||
_activeTweens.Add(tween);
|
||||
return tween;
|
||||
}
|
||||
|
||||
internal static Vector2Tween GetVector2Tween(Vector2 from, Vector2 to, float t)
|
||||
{
|
||||
Vector2Tween tween;
|
||||
if (TryGetTween(vector2Tweens, out tween))
|
||||
{
|
||||
tween.Init(from, to, t);
|
||||
}
|
||||
else
|
||||
{
|
||||
tween = new Vector2Tween(from, to, t, GenerateId());
|
||||
}
|
||||
|
||||
_activeTweens.Add(tween);
|
||||
return tween;
|
||||
}
|
||||
|
||||
internal static ColorTween GetColorTween(Color from, Color to, float t)
|
||||
{
|
||||
ColorTween tween;
|
||||
if (TryGetTween(colorTweens, out tween))
|
||||
{
|
||||
tween.Init(from, to, t);
|
||||
}
|
||||
else
|
||||
{
|
||||
tween = new ColorTween(from, to, t, GenerateId());
|
||||
}
|
||||
_activeTweens.Add(tween);
|
||||
return tween;
|
||||
}
|
||||
|
||||
public static void RemoveTween(BaseTween tween)
|
||||
{
|
||||
_activeTweens.Remove(tween);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,18 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 0dd55f44d0f254c43821c5d6af3970e1
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
AssetOrigin:
|
||||
serializedVersion: 1
|
||||
productId: 168243
|
||||
packageName: VR Beats Kit
|
||||
packageVersion: 2.0
|
||||
assetPath: Assets/VRBeatsKit/Scripts/PlatinioTween/Scripts/TweenPool.cs
|
||||
uploadId: 546658
|
||||
@@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 21f1429ddb26eec4a94fdfd626628ee1
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,147 @@
|
||||
using UnityEngine;
|
||||
|
||||
namespace Platinio.UI
|
||||
{
|
||||
public enum PivotPreset
|
||||
{
|
||||
UpperLeft,
|
||||
UpperCenter,
|
||||
UpperRight,
|
||||
MiddleLeft,
|
||||
MiddleCenter,
|
||||
MiddleRight,
|
||||
LowerLeft,
|
||||
LowerCenter,
|
||||
LowerRight
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// This script help you convert anchored positions to absolute positions, so you can animate and position exactly ui elements witouh messing around with anchors
|
||||
/// </summary>
|
||||
|
||||
|
||||
//use this to position UI in absolute coordenates
|
||||
//0.0 , 1.0 _______________________1.0 , 1.0
|
||||
// | |
|
||||
// | |
|
||||
// | |
|
||||
// | |
|
||||
//0.0 , 0.0 |______________________| 1.0 , 0.0
|
||||
|
||||
public static class RectTransformHelper
|
||||
{
|
||||
private static RectTransform targetCanvas = null;
|
||||
|
||||
public static Vector2 FromAbsolutePositionToAnchoredPosition(this RectTransform rect, Vector2 point, RectTransform canvas, PivotPreset anchor = PivotPreset.MiddleCenter)
|
||||
{
|
||||
Vector2 centerAnchor = ( rect.anchorMax + rect.anchorMin ) * 0.5f;
|
||||
return Vector2.Scale( point - centerAnchor, canvas.rect.size ) + Vector2.Scale( rect.rect.size, GetAnchorOffSet( anchor ) );
|
||||
}
|
||||
|
||||
public static Vector2 FromAbsolutePositionToAnchoredPosition(this RectTransform rect, Vector2 point, PivotPreset anchor = PivotPreset.MiddleCenter)
|
||||
{
|
||||
Vector2 centerAnchor = ( rect.anchorMax + rect.anchorMin ) * 0.5f;
|
||||
return Vector2.Scale( point - centerAnchor, RequestCanvas().rect.size ) + Vector2.Scale( rect.rect.size, GetAnchorOffSet( anchor ) );
|
||||
}
|
||||
|
||||
public static Vector2 FromAbsolutePositionToAnchoredPosition(this RectTransform rect, Vector2 point, RectTransform canvas, Vector2 pivot)
|
||||
{
|
||||
Vector2 centerAnchor = ( rect.anchorMax + rect.anchorMin ) * 0.5f;
|
||||
return Vector2.Scale( point - centerAnchor, canvas.rect.size ) + Vector2.Scale( rect.rect.size, pivot * 0.5f );
|
||||
}
|
||||
|
||||
public static Vector2 FromAnchoredPositionToAbsolutePosition(this RectTransform rect, RectTransform canvas , PivotPreset anchor = PivotPreset.MiddleCenter)
|
||||
{
|
||||
Vector2 centerAnchor = ( rect.anchorMax + rect.anchorMin ) * 0.5f;
|
||||
Vector2 anchoredPosition = rect.anchoredPosition;
|
||||
anchoredPosition -= Vector2.Scale( rect.rect.size, GetAnchorOffSet( anchor ) );
|
||||
return new Vector2( anchoredPosition.x/ canvas.sizeDelta.x, anchoredPosition.y / canvas.sizeDelta.y ) + centerAnchor ;
|
||||
}
|
||||
|
||||
public static Vector2 FromAnchoredPositionToAbsolutePosition(this RectTransform rect , PivotPreset anchor = PivotPreset.MiddleCenter)
|
||||
{
|
||||
Vector2 centerAnchor = ( rect.anchorMax + rect.anchorMin ) * 0.5f;
|
||||
Vector2 anchoredPosition = rect.anchoredPosition;
|
||||
anchoredPosition -= Vector2.Scale( rect.rect.size, GetAnchorOffSet( anchor ) );
|
||||
return new Vector2( anchoredPosition.x / RequestCanvas().sizeDelta.x, anchoredPosition.y / RequestCanvas().sizeDelta.y ) + centerAnchor;
|
||||
}
|
||||
|
||||
public static Vector2 FromAnchoredPositionToAbsolutePosition(this RectTransform rect, RectTransform canvas, Vector2 pivot)
|
||||
{
|
||||
Vector2 centerAnchor = ( rect.anchorMax + rect.anchorMin ) * 0.5f;
|
||||
Vector2 anchoredPosition = rect.anchoredPosition;
|
||||
anchoredPosition -= Vector2.Scale( rect.rect.size, pivot * 0.5f );
|
||||
return new Vector2( anchoredPosition.x / canvas.sizeDelta.x, anchoredPosition.y / canvas.sizeDelta.y ) + centerAnchor;
|
||||
}
|
||||
|
||||
public static Vector2 FromAnchoredPositionToAbsolutePosition(this RectTransform rect, Vector2 pivot)
|
||||
{
|
||||
Vector2 centerAnchor = ( rect.anchorMax + rect.anchorMin ) * 0.5f;
|
||||
Vector2 anchoredPosition = rect.anchoredPosition;
|
||||
anchoredPosition -= Vector2.Scale( rect.rect.size, pivot * 0.5f );
|
||||
return new Vector2( anchoredPosition.x / RequestCanvas().sizeDelta.x, anchoredPosition.y / RequestCanvas().sizeDelta.y ) + centerAnchor;
|
||||
}
|
||||
|
||||
public static Vector2 FromRectSizeToAbsoluteSize(this RectTransform rect , RectTransform canvas)
|
||||
{
|
||||
return new Vector2( rect.rect.size.x / canvas.sizeDelta.x, rect.rect.size.y / canvas.sizeDelta.y );
|
||||
}
|
||||
|
||||
public static Vector2 FromRectSizeToAbsoluteSize(this RectTransform rect)
|
||||
{
|
||||
return new Vector2( rect.rect.size.x / RequestCanvas().sizeDelta.x, rect.rect.size.y / RequestCanvas().sizeDelta.y );
|
||||
}
|
||||
|
||||
private static RectTransform RequestCanvas()
|
||||
{
|
||||
//we have a canvas in cache?
|
||||
if (targetCanvas != null)
|
||||
return targetCanvas;
|
||||
|
||||
Canvas canvas = null;
|
||||
|
||||
//just return the first encounter canvas
|
||||
canvas = GameObject.FindObjectOfType<Canvas>();
|
||||
|
||||
if (canvas != null)
|
||||
{
|
||||
targetCanvas = canvas.GetComponent<RectTransform>();
|
||||
return targetCanvas;
|
||||
}
|
||||
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
private static Vector2 GetAnchorOffSet(PivotPreset anchor)
|
||||
{
|
||||
switch (anchor)
|
||||
{
|
||||
case PivotPreset.UpperLeft:
|
||||
return new Vector2( 0.5f, -0.5f );
|
||||
case PivotPreset.UpperCenter:
|
||||
return new Vector2( 0.0f, -0.5f );
|
||||
case PivotPreset.UpperRight:
|
||||
return new Vector2( -0.5f, -0.5f );
|
||||
case PivotPreset.MiddleLeft:
|
||||
return new Vector2( 0.5f, 0.0f );
|
||||
case PivotPreset.MiddleCenter:
|
||||
return new Vector2( 0.0f, 0.0f );
|
||||
case PivotPreset.MiddleRight:
|
||||
return new Vector2( -0.5f, 0.0f );
|
||||
case PivotPreset.LowerLeft:
|
||||
return new Vector2( 0.5f, 0.5f );
|
||||
case PivotPreset.LowerCenter:
|
||||
return new Vector2( 0.0f, 0.5f );
|
||||
case PivotPreset.LowerRight:
|
||||
return new Vector2( -0.5f, 0.5f );
|
||||
}
|
||||
|
||||
return Vector2.zero;
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,18 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 75a1157ee690f394f9daddf8b0d86d65
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
AssetOrigin:
|
||||
serializedVersion: 1
|
||||
productId: 168243
|
||||
packageName: VR Beats Kit
|
||||
packageVersion: 2.0
|
||||
assetPath: Assets/VRBeatsKit/Scripts/PlatinioTween/Scripts/UI/RectTransformHelper.cs
|
||||
uploadId: 546658
|
||||
Reference in New Issue
Block a user