mirror of
https://github.com/Cardidi/dotween-upm-fork.git
synced 2026-02-04 06:14:55 +08:00
[BUGFIX] Fixed Restart(changeDelayTo) blocking a Sequence from restarting, plus better intellisense
This commit is contained in:
parent
d1cb5fb073
commit
8c030d5b56
@ -1191,12 +1191,12 @@
|
||||
</member>
|
||||
<member name="M:DG.Tweening.TweenExtensions.Restart(DG.Tweening.Tween,System.Boolean,System.Single)">
|
||||
<summary>Restarts the tween from the beginning</summary>
|
||||
<param name="includeDelay">If TRUE includes the eventual tween delay, otherwise skips it</param>
|
||||
<param name="changeDelayTo">If >= 0 changes the startup delay to this value, otherwise doesn't touch it</param>
|
||||
<param name="includeDelay">Ignored in case of Sequences. If TRUE includes the eventual tween delay, otherwise skips it</param>
|
||||
<param name="changeDelayTo">Ignored in case of Sequences. If >= 0 changes the startup delay to this value, otherwise doesn't touch it</param>
|
||||
</member>
|
||||
<member name="M:DG.Tweening.TweenExtensions.Rewind(DG.Tweening.Tween,System.Boolean)">
|
||||
<summary>Rewinds and pauses the tween</summary>
|
||||
<param name="includeDelay">If TRUE includes the eventual tween delay, otherwise skips it</param>
|
||||
<param name="includeDelay">Ignored in case of Sequences. If TRUE includes the eventual tween delay, otherwise skips it</param>
|
||||
</member>
|
||||
<member name="M:DG.Tweening.TweenExtensions.SmoothRewind(DG.Tweening.Tween)">
|
||||
<summary>Smoothly rewinds the tween (delays excluded).
|
||||
@ -2457,8 +2457,10 @@
|
||||
<param name="setImmediately">If TRUE sets the target to from value immediately, otherwise waits for the tween to start</param>
|
||||
</member>
|
||||
<member name="M:DG.Tweening.TweenSettingsExtensions.SetDelay``1(``0,System.Single)">
|
||||
<summary>Sets a delayed startup for the tween.
|
||||
<para>Has no effect on Sequences or if the tween has already started</para></summary>
|
||||
<summary>Sets a delayed startup for the tween.<para/>
|
||||
In case of Sequences behaves the same as <see cref="M:DG.Tweening.TweenSettingsExtensions.PrependInterval(DG.Tweening.Sequence,System.Single)"/>,
|
||||
which means the delay will repeat in case of loops (while with tweens it's ignored after the first loop cycle).<para/>
|
||||
Has no effect on Sequences or if the tween has already started</summary>
|
||||
</member>
|
||||
<member name="M:DG.Tweening.TweenSettingsExtensions.SetRelative``1(``0)">
|
||||
<summary>Sets the tween as relative
|
||||
|
||||
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 708f58d16f4025a4483f7673bca8cfd6
|
||||
timeCreated: 1576846470
|
||||
licenseType: Pro
|
||||
DefaultImporter:
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
188
UnityTests.Unity5/Assets/_Tests/DORotateTests.cs
Normal file
188
UnityTests.Unity5/Assets/_Tests/DORotateTests.cs
Normal file
@ -0,0 +1,188 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using DG.Tweening;
|
||||
using DG.Tweening.Core;
|
||||
using DG.Tweening.Plugins.Options;
|
||||
using UnityEngine;
|
||||
|
||||
public class DORotateTests : BrainBase
|
||||
{
|
||||
public enum TweenType
|
||||
{
|
||||
Normal,
|
||||
FromCurrent,
|
||||
FromDirect
|
||||
}
|
||||
|
||||
[Header("Main")]
|
||||
public TweenType tweenType = TweenType.Normal;
|
||||
float tweenDuration = 2;
|
||||
public bool relative = false;
|
||||
public Vector2 offsetBetweenDices = new Vector2(7, 4);
|
||||
public int maxDicesPerRow = 4;
|
||||
[Header("Fast")]
|
||||
public Vector3[] fastStartValues = new[] {
|
||||
new Vector3(0, 0, 0),
|
||||
new Vector3(85, 0, 0),
|
||||
new Vector3(95, 0, 0),
|
||||
new Vector3(180, 0, 0),
|
||||
new Vector3(0, 85, 0),
|
||||
new Vector3(0, 95, 0),
|
||||
new Vector3(0, 0, 85),
|
||||
new Vector3(0, 0, 95),
|
||||
new Vector3(180, 0, 0),
|
||||
};
|
||||
public Vector3 fastEndValue = new Vector3(100, 0, 0);
|
||||
[Header("Beyond360")]
|
||||
public Vector3[] beyond360StartValues = new[] {
|
||||
new Vector3(0, 0, 0),
|
||||
new Vector3(85, 0, 0),
|
||||
new Vector3(95, 0, 0),
|
||||
new Vector3(180, 0, 0),
|
||||
new Vector3(0, 85, 0),
|
||||
new Vector3(0, 95, 0),
|
||||
new Vector3(0, 0, 85),
|
||||
new Vector3(0, 0, 95),
|
||||
new Vector3(180, 0, 0),
|
||||
};
|
||||
public Vector3 beyond360EndValue = new Vector3(100, 0, 0);
|
||||
|
||||
GameObject[] _dices;
|
||||
GameObject _diceGroupPrefab;
|
||||
RotateMode _currRotateMode;
|
||||
|
||||
#region Main Methods
|
||||
|
||||
void Start()
|
||||
{
|
||||
_diceGroupPrefab = GameObject.Find("n:DiceGroupPrefab");
|
||||
_diceGroupPrefab.SetActive(false);
|
||||
}
|
||||
|
||||
// Create and distribute dices, then set their rotation
|
||||
void SetupFor(RotateMode mode)
|
||||
{
|
||||
DOTween.KillAll();
|
||||
// Destroy previous
|
||||
if (_dices != null) {
|
||||
for (int i = 0; i < _dices.Length; ++i) Destroy(_dices[i]);
|
||||
_dices = null;
|
||||
}
|
||||
// Create and distribute
|
||||
_currRotateMode = mode;
|
||||
Vector3[] startVals;
|
||||
Vector3 endVal;
|
||||
switch (mode) {
|
||||
case RotateMode.FastBeyond360:
|
||||
startVals = beyond360StartValues;
|
||||
endVal = beyond360EndValue;
|
||||
break;
|
||||
default:
|
||||
startVals = fastStartValues;
|
||||
endVal = fastEndValue;
|
||||
break;
|
||||
}
|
||||
int totDices = startVals.Length;
|
||||
int totRows = Mathf.CeilToInt(totDices / (float)maxDicesPerRow);
|
||||
Vector3 startP = new Vector3(
|
||||
-(offsetBetweenDices.x * (Mathf.Min(totDices, maxDicesPerRow) - 1)) * 0.5f,
|
||||
(offsetBetweenDices.y * (totRows + 1)) * 0.5f,
|
||||
0
|
||||
);
|
||||
int xIndex = -1;
|
||||
_dices = new GameObject[totDices];
|
||||
for (int i = 0; i < totDices; ++i) {
|
||||
if (i % maxDicesPerRow == 0) {
|
||||
xIndex = -1;
|
||||
startP.y -= offsetBetweenDices.y;
|
||||
}
|
||||
xIndex++;
|
||||
_dices[i] = Instantiate(_diceGroupPrefab, _diceGroupPrefab.transform.parent);
|
||||
_dices[i].name = "Dice " + i;
|
||||
_dices[i].SetActive(true);
|
||||
_dices[i].transform.localPosition = startP + new Vector3(offsetBetweenDices.x, 0, 0) * xIndex;
|
||||
Transform dice = GetDiceFromGroup(_dices[i]);
|
||||
dice.localEulerAngles = startVals[i];
|
||||
TextMesh label = _dices[i].GetComponentInChildren<TextMesh>();
|
||||
label.text = startVals[i] + "\n" + endVal;
|
||||
}
|
||||
}
|
||||
|
||||
void StartTweening()
|
||||
{
|
||||
if (_dices == null) {
|
||||
Debug.Log("Nothing to tween, Setup something first");
|
||||
return;
|
||||
}
|
||||
|
||||
Vector3[] startVals;
|
||||
Vector3 endVal;
|
||||
switch (_currRotateMode) {
|
||||
case RotateMode.FastBeyond360:
|
||||
startVals = beyond360StartValues;
|
||||
endVal = beyond360EndValue;
|
||||
break;
|
||||
default:
|
||||
startVals = fastStartValues;
|
||||
endVal = fastEndValue;
|
||||
break;
|
||||
}
|
||||
for (int i = 0; i < _dices.Length; ++i) {
|
||||
Transform dice = GetDiceFromGroup(_dices[i]);
|
||||
TextMesh label = _dices[i].GetComponentInChildren<TextMesh>();
|
||||
Vector3 startVal = startVals[i];
|
||||
Vector3 actualEndVal = endVal;
|
||||
Tween t;
|
||||
switch (tweenType) {
|
||||
case TweenType.FromCurrent:
|
||||
actualEndVal = startVal;
|
||||
t = dice.DOLocalRotate(endVal, tweenDuration, _currRotateMode).From();
|
||||
break;
|
||||
case TweenType.FromDirect:
|
||||
actualEndVal = startVal;
|
||||
t = dice.DOLocalRotate(startVal, tweenDuration, _currRotateMode).From(endVal);
|
||||
break;
|
||||
default:
|
||||
t = dice.DOLocalRotate(endVal, tweenDuration, _currRotateMode);
|
||||
break;
|
||||
}
|
||||
t.OnUpdate(() => {
|
||||
label.text = dice.eulerAngles + "\n" + actualEndVal;
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Utils
|
||||
|
||||
Transform GetDiceFromGroup(GameObject diceGroup)
|
||||
{
|
||||
Transform[] ts = diceGroup.GetComponentsInChildren<Transform>();
|
||||
for (int i = 0; i < ts.Length; ++i) {
|
||||
if (ts[i].name == "Dice") return ts[i];
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region UI Buttons
|
||||
|
||||
public void SetupForFast()
|
||||
{
|
||||
SetupFor(RotateMode.Fast);
|
||||
}
|
||||
|
||||
public void SetupForBeyond360()
|
||||
{
|
||||
SetupFor(RotateMode.FastBeyond360);
|
||||
}
|
||||
|
||||
public void Tween()
|
||||
{
|
||||
StartTweening();
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
12
UnityTests.Unity5/Assets/_Tests/DORotateTests.cs.meta
Normal file
12
UnityTests.Unity5/Assets/_Tests/DORotateTests.cs.meta
Normal file
@ -0,0 +1,12 @@
|
||||
fileFormatVersion: 2
|
||||
guid: c19f4e9941ebe844b98c268951e3bf17
|
||||
timeCreated: 1576676432
|
||||
licenseType: Pro
|
||||
MonoImporter:
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
BIN
UnityTests.Unity5/Assets/_Tests/DORotateTests.unity
Normal file
BIN
UnityTests.Unity5/Assets/_Tests/DORotateTests.unity
Normal file
Binary file not shown.
8
UnityTests.Unity5/Assets/_Tests/DORotateTests.unity.meta
Normal file
8
UnityTests.Unity5/Assets/_Tests/DORotateTests.unity.meta
Normal file
@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 5a7add83e6f7b3a418466bce176fd5e1
|
||||
timeCreated: 1576676415
|
||||
licenseType: Pro
|
||||
DefaultImporter:
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@ -11,8 +11,13 @@ using UnityEngine.UI;
|
||||
|
||||
public class TempTests : BrainBase
|
||||
{
|
||||
public Transform target;
|
||||
|
||||
IEnumerator Start()
|
||||
{
|
||||
yield return new WaitForSeconds(1);
|
||||
Sequence s = DOTween.Sequence().Append(target.DOMoveX(2, 1)).SetLoops(-1);
|
||||
yield return new WaitForSeconds(1f);
|
||||
s.Restart(true, 1);
|
||||
}
|
||||
}
|
||||
Binary file not shown.
@ -769,7 +769,7 @@ namespace DG.Tweening.Core
|
||||
{
|
||||
bool wasPaused = !t.isPlaying;
|
||||
t.isBackwards = false;
|
||||
if (changeDelayTo >= 0) t.delay = changeDelayTo;
|
||||
if (changeDelayTo >= 0 && t.tweenType == TweenType.Tweener) t.delay = changeDelayTo;
|
||||
Rewind(t, includeDelay);
|
||||
t.isPlaying = true;
|
||||
if (wasPaused && t.playedOnce && t.delayComplete && t.onPlay != null) {
|
||||
|
||||
@ -34,7 +34,7 @@ namespace DG.Tweening
|
||||
public class DOTween
|
||||
{
|
||||
/// <summary>DOTween's version</summary>
|
||||
public static readonly string Version = "1.2.310"; // Last version before modules: 1.1.755
|
||||
public static readonly string Version = "1.2.315"; // Last version before modules: 1.1.755
|
||||
|
||||
///////////////////////////////////////////////
|
||||
// Options ////////////////////////////////////
|
||||
|
||||
@ -190,8 +190,8 @@ namespace DG.Tweening
|
||||
}
|
||||
|
||||
/// <summary>Restarts the tween from the beginning</summary>
|
||||
/// <param name="includeDelay">If TRUE includes the eventual tween delay, otherwise skips it</param>
|
||||
/// <param name="changeDelayTo">If >= 0 changes the startup delay to this value, otherwise doesn't touch it</param>
|
||||
/// <param name="includeDelay">Ignored in case of Sequences. If TRUE includes the eventual tween delay, otherwise skips it</param>
|
||||
/// <param name="changeDelayTo">Ignored in case of Sequences. If >= 0 changes the startup delay to this value, otherwise doesn't touch it</param>
|
||||
public static void Restart(this Tween t, bool includeDelay = true, float changeDelayTo = -1)
|
||||
{
|
||||
if (t == null) {
|
||||
@ -206,7 +206,7 @@ namespace DG.Tweening
|
||||
}
|
||||
|
||||
/// <summary>Rewinds and pauses the tween</summary>
|
||||
/// <param name="includeDelay">If TRUE includes the eventual tween delay, otherwise skips it</param>
|
||||
/// <param name="includeDelay">Ignored in case of Sequences. If TRUE includes the eventual tween delay, otherwise skips it</param>
|
||||
public static void Rewind(this Tween t, bool includeDelay = true)
|
||||
{
|
||||
if (t == null) {
|
||||
|
||||
@ -645,8 +645,10 @@ namespace DG.Tweening
|
||||
|
||||
#endregion
|
||||
|
||||
/// <summary>Sets a delayed startup for the tween.
|
||||
/// <para>Has no effect on Sequences or if the tween has already started</para></summary>
|
||||
/// <summary>Sets a delayed startup for the tween.<para/>
|
||||
/// In case of Sequences behaves the same as <see cref="PrependInterval"/>,
|
||||
/// which means the delay will repeat in case of loops (while with tweens it's ignored after the first loop cycle).<para/>
|
||||
/// Has no effect on Sequences or if the tween has already started</summary>
|
||||
public static T SetDelay<T>(this T t, float delay) where T : Tween
|
||||
{
|
||||
if (t == null || !t.active || t.creationLocked) return t;
|
||||
|
||||
@ -1191,12 +1191,12 @@
|
||||
</member>
|
||||
<member name="M:DG.Tweening.TweenExtensions.Restart(DG.Tweening.Tween,System.Boolean,System.Single)">
|
||||
<summary>Restarts the tween from the beginning</summary>
|
||||
<param name="includeDelay">If TRUE includes the eventual tween delay, otherwise skips it</param>
|
||||
<param name="changeDelayTo">If >= 0 changes the startup delay to this value, otherwise doesn't touch it</param>
|
||||
<param name="includeDelay">Ignored in case of Sequences. If TRUE includes the eventual tween delay, otherwise skips it</param>
|
||||
<param name="changeDelayTo">Ignored in case of Sequences. If >= 0 changes the startup delay to this value, otherwise doesn't touch it</param>
|
||||
</member>
|
||||
<member name="M:DG.Tweening.TweenExtensions.Rewind(DG.Tweening.Tween,System.Boolean)">
|
||||
<summary>Rewinds and pauses the tween</summary>
|
||||
<param name="includeDelay">If TRUE includes the eventual tween delay, otherwise skips it</param>
|
||||
<param name="includeDelay">Ignored in case of Sequences. If TRUE includes the eventual tween delay, otherwise skips it</param>
|
||||
</member>
|
||||
<member name="M:DG.Tweening.TweenExtensions.SmoothRewind(DG.Tweening.Tween)">
|
||||
<summary>Smoothly rewinds the tween (delays excluded).
|
||||
@ -2457,8 +2457,10 @@
|
||||
<param name="setImmediately">If TRUE sets the target to from value immediately, otherwise waits for the tween to start</param>
|
||||
</member>
|
||||
<member name="M:DG.Tweening.TweenSettingsExtensions.SetDelay``1(``0,System.Single)">
|
||||
<summary>Sets a delayed startup for the tween.
|
||||
<para>Has no effect on Sequences or if the tween has already started</para></summary>
|
||||
<summary>Sets a delayed startup for the tween.<para/>
|
||||
In case of Sequences behaves the same as <see cref="M:DG.Tweening.TweenSettingsExtensions.PrependInterval(DG.Tweening.Sequence,System.Single)"/>,
|
||||
which means the delay will repeat in case of loops (while with tweens it's ignored after the first loop cycle).<para/>
|
||||
Has no effect on Sequences or if the tween has already started</summary>
|
||||
</member>
|
||||
<member name="M:DG.Tweening.TweenSettingsExtensions.SetRelative``1(``0)">
|
||||
<summary>Sets the tween as relative
|
||||
|
||||
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Loading…
x
Reference in New Issue
Block a user