1
0
mirror of https://github.com/Cardidi/dotween-upm-fork.git synced 2025-12-20 09:16:02 +08:00

Added optional parameter to methods that return a List, so a reusable List can be passed

+ Added DOTweenExtras (only in test project) for Koby
This commit is contained in:
Demigiant 2017-10-28 20:46:20 +02:00
parent 6a0e92ce7e
commit b4e9eb9075
54 changed files with 220 additions and 42 deletions

View File

@ -734,34 +734,38 @@
A tween is considered as playing even if its delay is actually playing
</summary>
</member>
<member name="M:DG.Tweening.DOTween.PlayingTweens">
<member name="M:DG.Tweening.DOTween.PlayingTweens(System.Collections.Generic.List{DG.Tweening.Tween})">
<summary>
Returns a list of all active tweens in a playing state.
Returns NULL if there are no active playing tweens.
<para>Beware: each time you call this method a new list is generated, so use it for debug only</para>
</summary>
<param name="fillableList">If NULL creates a new list, otherwise fills this one (and thus saves allocations)</param>
</member>
<member name="M:DG.Tweening.DOTween.PausedTweens">
<member name="M:DG.Tweening.DOTween.PausedTweens(System.Collections.Generic.List{DG.Tweening.Tween})">
<summary>
Returns a list of all active tweens in a paused state.
Returns NULL if there are no active paused tweens.
<para>Beware: each time you call this method a new list is generated, so use it for debug only</para>
</summary>
<param name="fillableList">If NULL creates a new list, otherwise fills this one (and thus saves allocations)</param>
</member>
<member name="M:DG.Tweening.DOTween.TweensById(System.Object,System.Boolean)">
<member name="M:DG.Tweening.DOTween.TweensById(System.Object,System.Boolean,System.Collections.Generic.List{DG.Tweening.Tween})">
<summary>
Returns a list of all active tweens with the given id.
Returns NULL if there are no active tweens with the given id.
<para>Beware: each time you call this method a new list is generated</para>
<param name="playingOnly">If TRUE returns only the tweens with the given ID that are currently playing</param>
</summary>
<param name="playingOnly">If TRUE returns only the tweens with the given ID that are currently playing</param>
<param name="fillableList">If NULL creates a new list, otherwise fills this one (and thus saves allocations)</param>
</member>
<member name="M:DG.Tweening.DOTween.TweensByTarget(System.Object,System.Boolean)">
<member name="M:DG.Tweening.DOTween.TweensByTarget(System.Object,System.Boolean,System.Collections.Generic.List{DG.Tweening.Tween})">
<summary>
Returns a list of all active tweens with the given target.
Returns NULL if there are no active tweens with the given target.
<para>Beware: each time you call this method a new list is generated</para>
<param name="playingOnly">If TRUE returns only the tweens with the given target that are currently playing</param>
<param name="fillableList">If NULL creates a new list, otherwise fills this one (and thus saves allocations)</param>
</summary>
</member>
<member name="T:DG.Tweening.DOVirtual">

View File

@ -734,34 +734,38 @@
A tween is considered as playing even if its delay is actually playing
</summary>
</member>
<member name="M:DG.Tweening.DOTween.PlayingTweens">
<member name="M:DG.Tweening.DOTween.PlayingTweens(System.Collections.Generic.List{DG.Tweening.Tween})">
<summary>
Returns a list of all active tweens in a playing state.
Returns NULL if there are no active playing tweens.
<para>Beware: each time you call this method a new list is generated, so use it for debug only</para>
</summary>
<param name="fillableList">If NULL creates a new list, otherwise fills this one (and thus saves allocations)</param>
</member>
<member name="M:DG.Tweening.DOTween.PausedTweens">
<member name="M:DG.Tweening.DOTween.PausedTweens(System.Collections.Generic.List{DG.Tweening.Tween})">
<summary>
Returns a list of all active tweens in a paused state.
Returns NULL if there are no active paused tweens.
<para>Beware: each time you call this method a new list is generated, so use it for debug only</para>
</summary>
<param name="fillableList">If NULL creates a new list, otherwise fills this one (and thus saves allocations)</param>
</member>
<member name="M:DG.Tweening.DOTween.TweensById(System.Object,System.Boolean)">
<member name="M:DG.Tweening.DOTween.TweensById(System.Object,System.Boolean,System.Collections.Generic.List{DG.Tweening.Tween})">
<summary>
Returns a list of all active tweens with the given id.
Returns NULL if there are no active tweens with the given id.
<para>Beware: each time you call this method a new list is generated</para>
<param name="playingOnly">If TRUE returns only the tweens with the given ID that are currently playing</param>
</summary>
<param name="playingOnly">If TRUE returns only the tweens with the given ID that are currently playing</param>
<param name="fillableList">If NULL creates a new list, otherwise fills this one (and thus saves allocations)</param>
</member>
<member name="M:DG.Tweening.DOTween.TweensByTarget(System.Object,System.Boolean)">
<member name="M:DG.Tweening.DOTween.TweensByTarget(System.Object,System.Boolean,System.Collections.Generic.List{DG.Tweening.Tween})">
<summary>
Returns a list of all active tweens with the given target.
Returns NULL if there are no active tweens with the given target.
<para>Beware: each time you call this method a new list is generated</para>
<param name="playingOnly">If TRUE returns only the tweens with the given target that are currently playing</param>
<param name="fillableList">If NULL creates a new list, otherwise fills this one (and thus saves allocations)</param>
</summary>
</member>
<member name="T:DG.Tweening.DOVirtual">

View File

@ -0,0 +1,9 @@
fileFormatVersion: 2
guid: d032eb15eceb9a1408c8cbdbee442517
folderAsset: yes
timeCreated: 1509214341
licenseType: Pro
DefaultImporter:
userData:
assetBundleName:
assetBundleVariant:

View File

@ -0,0 +1,102 @@
// Author: Daniele Giardini - http://www.demigiant.com
// Created: 2017/10/28 20:13
// License Copyright (c) Daniele Giardini
using System.Collections.Generic;
namespace DG.Tweening
{
/// <summary>
/// Extra DOTween methods not included in public engine (for consistency reasons)
/// </summary>
public static class DOTweenExtras
{
static readonly List<Tween> _RecyclableList = new List<Tween>();
#region Public Methods
/// <summary>
/// Returns TRUE if there are tweens with the given id, and they're all currently playing forward
/// </summary>
public static bool IsPlayForwardById(object id)
{
List<Tween> tweens = DOTween.TweensById(id, false, _RecyclableList);
return AreAllPlayingForward(tweens);
}
/// <summary>
/// Returns TRUE if there are tweens with the given target, and they're all currently playing forward
/// </summary>
public static bool IsPlayForwardByTarget(object target)
{
List<Tween> tweens = DOTween.TweensByTarget(target, false, _RecyclableList);
return AreAllPlayingForward(tweens);
}
/// <summary>
/// Returns TRUE if there are tweens with the given id, and they're all currently playing backwards
/// </summary>
public static bool IsPlayBackwardsById(object id)
{
List<Tween> tweens = DOTween.TweensById(id, false, _RecyclableList);
return AreAllPlayingBackwards(tweens);
}
/// <summary>
/// Returns TRUE if there are tweens with the given target, and they're all currently playing backwards
/// </summary>
public static bool IsPlayBackwardsByTarget(object target)
{
List<Tween> tweens = DOTween.TweensByTarget(target, false, _RecyclableList);
return AreAllPlayingBackwards(tweens);
}
/// <summary>
/// Returns TRUE if there are tweens with the given id, and they're all currently paused
/// </summary>
public static bool IsPausedById(object id)
{
List<Tween> tweens = DOTween.TweensById(id, false, _RecyclableList);
return AreAllPaused(tweens);
}
/// <summary>
/// Returns TRUE if there are tweens with the given target, and they're all currently paused
/// </summary>
public static bool IsPausedByTarget(object target)
{
List<Tween> tweens = DOTween.TweensByTarget(target, false, _RecyclableList);
return AreAllPaused(tweens);
}
#endregion
#region Methods
static bool AreAllPlayingForward(List<Tween> tweens)
{
if (tweens == null) return false;
foreach (Tween t in tweens) {
if (!t.IsPlaying() || t.isBackwards) return false;
}
return true;
}
static bool AreAllPlayingBackwards(List<Tween> tweens)
{
if (tweens == null) return false;
foreach (Tween t in tweens) {
if (!t.IsPlaying() || !t.isBackwards) return false;
}
return true;
}
static bool AreAllPaused(List<Tween> tweens)
{
if (tweens == null) return false;
foreach (Tween t in tweens) {
if (t.IsPlaying()) return false;
}
return true;
}
#endregion
}
}

View File

@ -0,0 +1,3 @@
fileFormatVersion: 2
guid: 075e72a77e604361b462a0932ffae8ab
timeCreated: 1509214382

View File

@ -734,34 +734,38 @@
A tween is considered as playing even if its delay is actually playing
</summary>
</member>
<member name="M:DG.Tweening.DOTween.PlayingTweens">
<member name="M:DG.Tweening.DOTween.PlayingTweens(System.Collections.Generic.List{DG.Tweening.Tween})">
<summary>
Returns a list of all active tweens in a playing state.
Returns NULL if there are no active playing tweens.
<para>Beware: each time you call this method a new list is generated, so use it for debug only</para>
</summary>
<param name="fillableList">If NULL creates a new list, otherwise fills this one (and thus saves allocations)</param>
</member>
<member name="M:DG.Tweening.DOTween.PausedTweens">
<member name="M:DG.Tweening.DOTween.PausedTweens(System.Collections.Generic.List{DG.Tweening.Tween})">
<summary>
Returns a list of all active tweens in a paused state.
Returns NULL if there are no active paused tweens.
<para>Beware: each time you call this method a new list is generated, so use it for debug only</para>
</summary>
<param name="fillableList">If NULL creates a new list, otherwise fills this one (and thus saves allocations)</param>
</member>
<member name="M:DG.Tweening.DOTween.TweensById(System.Object,System.Boolean)">
<member name="M:DG.Tweening.DOTween.TweensById(System.Object,System.Boolean,System.Collections.Generic.List{DG.Tweening.Tween})">
<summary>
Returns a list of all active tweens with the given id.
Returns NULL if there are no active tweens with the given id.
<para>Beware: each time you call this method a new list is generated</para>
<param name="playingOnly">If TRUE returns only the tweens with the given ID that are currently playing</param>
</summary>
<param name="playingOnly">If TRUE returns only the tweens with the given ID that are currently playing</param>
<param name="fillableList">If NULL creates a new list, otherwise fills this one (and thus saves allocations)</param>
</member>
<member name="M:DG.Tweening.DOTween.TweensByTarget(System.Object,System.Boolean)">
<member name="M:DG.Tweening.DOTween.TweensByTarget(System.Object,System.Boolean,System.Collections.Generic.List{DG.Tweening.Tween})">
<summary>
Returns a list of all active tweens with the given target.
Returns NULL if there are no active tweens with the given target.
<para>Beware: each time you call this method a new list is generated</para>
<param name="playingOnly">If TRUE returns only the tweens with the given target that are currently playing</param>
<param name="fillableList">If NULL creates a new list, otherwise fills this one (and thus saves allocations)</param>
</summary>
</member>
<member name="T:DG.Tweening.DOVirtual">

View File

@ -0,0 +1,33 @@
// Author: Daniele Giardini - http://www.demigiant.com
// Created: 2017/10/28 20:39
// License Copyright (c) Daniele Giardini
using System.Collections;
using DG.Tweening;
using UnityEngine;
namespace _Tests
{
public class TempTests_Extras : MonoBehaviour
{
public Transform target;
IEnumerator Start()
{
target.DOMoveX(2, 2).SetAutoKill(false);
target.DOMoveY(2, 2).SetAutoKill(false);
yield return new WaitForSeconds(1);
Debug.Log("Are all playing forward: " + DOTweenExtras.IsPlayForwardByTarget(target));
Debug.Log("Are all playing backwards: " + DOTweenExtras.IsPlayBackwardsByTarget(target));
Debug.Log("Are all paused: " + DOTweenExtras.IsPausedByTarget(target));
yield return new WaitForSeconds(1.2f);
Debug.Log("Are all playing forward: " + DOTweenExtras.IsPlayForwardByTarget(target));
Debug.Log("Are all playing backwards: " + DOTweenExtras.IsPlayBackwardsByTarget(target));
Debug.Log("Are all paused: " + DOTweenExtras.IsPausedByTarget(target));
}
}
}

View File

@ -0,0 +1,3 @@
fileFormatVersion: 2
guid: 70b65d2ecae848f1b3baf04303b263f6
timeCreated: 1509215984

Binary file not shown.

View File

@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: bb5a9ea469a70c840ab02674a1b31c15
timeCreated: 1509215967
licenseType: Pro
DefaultImporter:
userData:
assetBundleName:
assetBundleVariant:

View File

@ -779,52 +779,52 @@ namespace DG.Tweening.Core
}
// If playing is FALSE returns active paused tweens, otherwise active playing tweens
internal static List<Tween> GetActiveTweens(bool playing)
internal static List<Tween> GetActiveTweens(bool playing, List<Tween> fillableList = null)
{
if (_requiresActiveReorganization) ReorganizeActiveTweens();
if (totActiveTweens <= 0) return null;
int len = totActiveTweens;
List<Tween> ts = new List<Tween>(len);
if (fillableList == null) fillableList = new List<Tween>(len);
for (int i = 0; i < len; ++i) {
Tween t = _activeTweens[i];
if (t.isPlaying == playing) ts.Add(t);
if (t.isPlaying == playing) fillableList.Add(t);
}
if (ts.Count > 0) return ts;
if (fillableList.Count > 0) return fillableList;
return null;
}
// Returns all active tweens with the given id
internal static List<Tween> GetTweensById(object id, bool playingOnly)
internal static List<Tween> GetTweensById(object id, bool playingOnly, List<Tween> fillableList = null)
{
if (_requiresActiveReorganization) ReorganizeActiveTweens();
if (totActiveTweens <= 0) return null;
int len = totActiveTweens;
List<Tween> ts = new List<Tween>(len);
if (fillableList == null) fillableList = new List<Tween>(len);
for (int i = 0; i < len; ++i) {
Tween t = _activeTweens[i];
if (t == null || !Equals(id, t.id)) continue;
if (!playingOnly || t.isPlaying) ts.Add(t);
if (!playingOnly || t.isPlaying) fillableList.Add(t);
}
if (ts.Count > 0) return ts;
if (fillableList.Count > 0) return fillableList;
return null;
}
// Returns all active tweens with the given target
internal static List<Tween> GetTweensByTarget(object target, bool playingOnly)
internal static List<Tween> GetTweensByTarget(object target, bool playingOnly, List<Tween> fillableList = null)
{
if (_requiresActiveReorganization) ReorganizeActiveTweens();
if (totActiveTweens <= 0) return null;
int len = totActiveTweens;
List<Tween> ts = new List<Tween>(len);
if (fillableList == null) fillableList = new List<Tween>(len);
for (int i = 0; i < len; ++i) {
Tween t = _activeTweens[i];
if (t.target != target) continue;
if (!playingOnly || t.isPlaying) ts.Add(t);
if (!playingOnly || t.isPlaying) fillableList.Add(t);
}
if (ts.Count > 0) return ts;
if (fillableList.Count > 0) return fillableList;
return null;
}

View File

@ -32,7 +32,7 @@ namespace DG.Tweening
public class DOTween
{
/// <summary>DOTween's version</summary>
public static readonly string Version = "1.1.660";
public static readonly string Version = "1.1.665";
///////////////////////////////////////////////
// Options ////////////////////////////////////
@ -924,9 +924,10 @@ namespace DG.Tweening
/// Returns NULL if there are no active playing tweens.
/// <para>Beware: each time you call this method a new list is generated, so use it for debug only</para>
/// </summary>
public static List<Tween> PlayingTweens()
/// <param name="fillableList">If NULL creates a new list, otherwise fills this one (and thus saves allocations)</param>
public static List<Tween> PlayingTweens(List<Tween> fillableList = null)
{
return TweenManager.GetActiveTweens(true);
return TweenManager.GetActiveTweens(true, fillableList);
}
/// <summary>
@ -934,22 +935,24 @@ namespace DG.Tweening
/// Returns NULL if there are no active paused tweens.
/// <para>Beware: each time you call this method a new list is generated, so use it for debug only</para>
/// </summary>
public static List<Tween> PausedTweens()
/// <param name="fillableList">If NULL creates a new list, otherwise fills this one (and thus saves allocations)</param>
public static List<Tween> PausedTweens(List<Tween> fillableList = null)
{
return TweenManager.GetActiveTweens(false);
return TweenManager.GetActiveTweens(false, fillableList);
}
/// <summary>
/// Returns a list of all active tweens with the given id.
/// Returns NULL if there are no active tweens with the given id.
/// <para>Beware: each time you call this method a new list is generated</para>
/// <param name="playingOnly">If TRUE returns only the tweens with the given ID that are currently playing</param>
/// </summary>
public static List<Tween> TweensById(object id, bool playingOnly = false)
/// <param name="playingOnly">If TRUE returns only the tweens with the given ID that are currently playing</param>
/// <param name="fillableList">If NULL creates a new list, otherwise fills this one (and thus saves allocations)</param>
public static List<Tween> TweensById(object id, bool playingOnly = false, List<Tween> fillableList = null)
{
if (id == null) return null;
return TweenManager.GetTweensById(id, playingOnly);
return TweenManager.GetTweensById(id, playingOnly, fillableList);
}
/// <summary>
@ -957,10 +960,11 @@ namespace DG.Tweening
/// Returns NULL if there are no active tweens with the given target.
/// <para>Beware: each time you call this method a new list is generated</para>
/// <param name="playingOnly">If TRUE returns only the tweens with the given target that are currently playing</param>
/// <param name="fillableList">If NULL creates a new list, otherwise fills this one (and thus saves allocations)</param>
/// </summary>
public static List<Tween> TweensByTarget(object target, bool playingOnly = false)
public static List<Tween> TweensByTarget(object target, bool playingOnly = false, List<Tween> fillableList = null)
{
return TweenManager.GetTweensByTarget(target, playingOnly);
return TweenManager.GetTweensByTarget(target, playingOnly, fillableList);
}
#endregion

View File

@ -734,34 +734,38 @@
A tween is considered as playing even if its delay is actually playing
</summary>
</member>
<member name="M:DG.Tweening.DOTween.PlayingTweens">
<member name="M:DG.Tweening.DOTween.PlayingTweens(System.Collections.Generic.List{DG.Tweening.Tween})">
<summary>
Returns a list of all active tweens in a playing state.
Returns NULL if there are no active playing tweens.
<para>Beware: each time you call this method a new list is generated, so use it for debug only</para>
</summary>
<param name="fillableList">If NULL creates a new list, otherwise fills this one (and thus saves allocations)</param>
</member>
<member name="M:DG.Tweening.DOTween.PausedTweens">
<member name="M:DG.Tweening.DOTween.PausedTweens(System.Collections.Generic.List{DG.Tweening.Tween})">
<summary>
Returns a list of all active tweens in a paused state.
Returns NULL if there are no active paused tweens.
<para>Beware: each time you call this method a new list is generated, so use it for debug only</para>
</summary>
<param name="fillableList">If NULL creates a new list, otherwise fills this one (and thus saves allocations)</param>
</member>
<member name="M:DG.Tweening.DOTween.TweensById(System.Object,System.Boolean)">
<member name="M:DG.Tweening.DOTween.TweensById(System.Object,System.Boolean,System.Collections.Generic.List{DG.Tweening.Tween})">
<summary>
Returns a list of all active tweens with the given id.
Returns NULL if there are no active tweens with the given id.
<para>Beware: each time you call this method a new list is generated</para>
<param name="playingOnly">If TRUE returns only the tweens with the given ID that are currently playing</param>
</summary>
<param name="playingOnly">If TRUE returns only the tweens with the given ID that are currently playing</param>
<param name="fillableList">If NULL creates a new list, otherwise fills this one (and thus saves allocations)</param>
</member>
<member name="M:DG.Tweening.DOTween.TweensByTarget(System.Object,System.Boolean)">
<member name="M:DG.Tweening.DOTween.TweensByTarget(System.Object,System.Boolean,System.Collections.Generic.List{DG.Tweening.Tween})">
<summary>
Returns a list of all active tweens with the given target.
Returns NULL if there are no active tweens with the given target.
<para>Beware: each time you call this method a new list is generated</para>
<param name="playingOnly">If TRUE returns only the tweens with the given target that are currently playing</param>
<param name="fillableList">If NULL creates a new list, otherwise fills this one (and thus saves allocations)</param>
</summary>
</member>
<member name="T:DG.Tweening.DOVirtual">

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.