Skip to content

Commit

Permalink
Added DOTween.PlayForward/Backwards overloads that accept both a targ…
Browse files Browse the repository at this point in the history
…et and an id
  • Loading branch information
Demigiant committed Apr 11, 2016
1 parent 8718c07 commit eb98935
Show file tree
Hide file tree
Showing 49 changed files with 130 additions and 1 deletion.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
8 changes: 8 additions & 0 deletions UnityTests.Unity4/Assets/Demigiant/DOTween/DOTween.XML

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Binary file modified UnityTests.Unity4/Assets/Demigiant/DOTween/DOTween.dll
Binary file not shown.
Binary file modified UnityTests.Unity4/Assets/Demigiant/DOTween/DOTween.dll.mdb
Binary file not shown.
Binary file modified UnityTests.Unity4/Assets/Demigiant/DOTween/DOTween43.dll
Binary file not shown.
Binary file modified UnityTests.Unity4/Assets/Demigiant/DOTween/DOTween43.dll.mdb
Binary file not shown.
Binary file modified UnityTests.Unity4/Assets/Demigiant/DOTween/DOTween46.dll
Binary file not shown.
Binary file modified UnityTests.Unity4/Assets/Demigiant/DOTween/DOTween46.dll.mdb
Binary file not shown.
Binary file modified UnityTests.Unity4/Assets/Demigiant/DOTween/DOTween50.dll
Binary file not shown.
Binary file modified UnityTests.Unity4/Assets/Demigiant/DOTween/DOTween50.dll.mdb
Binary file not shown.
Binary file not shown.
Binary file not shown.
8 changes: 8 additions & 0 deletions UnityTests.Unity5/Assets/Demigiant/DOTween/DOTween.XML

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Binary file modified UnityTests.Unity5/Assets/Demigiant/DOTween/DOTween.dll
Binary file not shown.
Binary file modified UnityTests.Unity5/Assets/Demigiant/DOTween/DOTween.dll.mdb
Binary file not shown.
Binary file modified UnityTests.Unity5/Assets/Demigiant/DOTween/DOTween43.dll
Binary file not shown.
Binary file modified UnityTests.Unity5/Assets/Demigiant/DOTween/DOTween43.dll.mdb
Binary file not shown.
Binary file modified UnityTests.Unity5/Assets/Demigiant/DOTween/DOTween46.dll
Binary file not shown.
Binary file modified UnityTests.Unity5/Assets/Demigiant/DOTween/DOTween46.dll.mdb
Binary file not shown.
Binary file modified UnityTests.Unity5/Assets/Demigiant/DOTween/DOTween50.dll
Binary file not shown.
Binary file modified UnityTests.Unity5/Assets/Demigiant/DOTween/DOTween50.dll.mdb
Binary file not shown.
Binary file not shown.
Binary file not shown.
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
using UnityEngine;
using DG.Tweening;

public class DrawSegmentWithBounce : MonoBehaviour
{
public Material material;

bool isDrawing;
LineRenderer currLine;
Vector3 startPos, endPos;

void Update()
{
if (isDrawing) {
// Update line
endPos = GetWorldMousePos();
currLine.SetPosition(1, endPos);
}
if (Input.GetMouseButtonDown(0)) {
// Start new line
CreateLine();
isDrawing = true;
} else if (Input.GetMouseButtonUp(0) && isDrawing) {
// End line and add collider
isDrawing = false;
EdgeCollider2D col = currLine.gameObject.AddComponent<EdgeCollider2D>();
col.points = new Vector2[] { startPos, endPos };

// Tween line ending
// Find max bounce distance (along the correct axis)
// Change the last value (0.65f) to increase or decrease the bounce distance (inverse)
Vector3 bouncePoint = (endPos - startPos) - ((endPos - startPos) * 0.65f);
Vector3 tweenP = endPos;
LineRenderer tweenedL = currLine;
// The last 3 parameters indicate:
// - the duration of the tween
// - the vibration (how much it will oscillate)
// - if the bounce should go beyond the end point or not (0 means not)
DOTween.Punch(()=> tweenP, x=> tweenP = x, -bouncePoint, 0.6f, 8, 0)
.OnUpdate(()=> tweenedL.SetPosition(1, tweenP));
}
}

void CreateLine()
{
currLine = new GameObject("Line").AddComponent<LineRenderer>();
currLine.material = material;
currLine.SetVertexCount(2);
currLine.SetWidth(0.12f, 0.12f);
currLine.material.color = new Color(0, 0.7f, 0.63f, 0.2f);
currLine.useWorldSpace = false;
startPos = GetWorldMousePos();
currLine.SetPosition(0, startPos);
currLine.SetPosition(1, startPos);
}

Vector3 GetWorldMousePos()
{
Vector3 p = Camera.main.ScreenToWorldPoint(new Vector3(Input.mousePosition.x, Input.mousePosition.y, 10));
p.z = 0;
return p;
}
}

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Binary file not shown.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

16 changes: 15 additions & 1 deletion _DOTween.Assembly/DOTween/DOTween.cs
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ namespace DG.Tweening
public class DOTween
{
/// <summary>DOTween's version</summary>
public static readonly string Version = "1.1.260";
public static readonly string Version = "1.1.270";

///////////////////////////////////////////////
// Options ////////////////////////////////////
Expand Down Expand Up @@ -772,6 +772,13 @@ public static int PlayBackwards(object targetOrId)
if (targetOrId == null) return 0;
return TweenManager.FilteredOperation(OperationType.PlayBackwards, FilterType.TargetOrId, targetOrId, false, 0);
}
/// <summary>Plays backwards all tweens with the given target and ID and returns the number of actual tweens played
/// (meaning the tweens that were not already started, playing backwards or rewinded)</summary>
public static int PlayBackwards(object target, object id)
{
if (target == null || id == null) return 0;
return TweenManager.FilteredOperation(OperationType.PlayBackwards, FilterType.TargetAndId, id, false, 0, target);
}

/// <summary>Plays forward all tweens and returns the number of actual tweens played
/// (meaning tweens that were not already playing forward or complete)</summary>
Expand All @@ -786,6 +793,13 @@ public static int PlayForward(object targetOrId)
if (targetOrId == null) return 0;
return TweenManager.FilteredOperation(OperationType.PlayForward, FilterType.TargetOrId, targetOrId, false, 0);
}
/// <summary>Plays forward all tweens with the given target and ID and returns the number of actual tweens played
/// (meaning the tweens that were not already started, playing backwards or rewinded)</summary>
public static int PlayForward(object target, object id)
{
if (target == null || id == null) return 0;
return TweenManager.FilteredOperation(OperationType.PlayForward, FilterType.TargetAndId, id, false, 0, target);
}

/// <summary>Restarts all tweens, then returns the number of actual tweens restarted</summary>
public static int RestartAll(bool includeDelay = true)
Expand Down
8 changes: 8 additions & 0 deletions _DOTween.Assembly/bin/DOTween.XML

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Binary file modified _DOTween.Assembly/bin/DOTween.dll
Binary file not shown.
Binary file modified _DOTween.Assembly/bin/DOTween.dll.mdb
Binary file not shown.
Binary file modified _DOTween.Assembly/bin/DOTween43.dll
Binary file not shown.
Binary file modified _DOTween.Assembly/bin/DOTween43.dll.mdb
Binary file not shown.
Binary file modified _DOTween.Assembly/bin/DOTween46.dll
Binary file not shown.
Binary file modified _DOTween.Assembly/bin/DOTween46.dll.mdb
Binary file not shown.
Binary file modified _DOTween.Assembly/bin/DOTween50.dll
Binary file not shown.
Binary file modified _DOTween.Assembly/bin/DOTween50.dll.mdb
Binary file not shown.
Binary file modified _DOTween.Assembly/bin/Editor/DOTweenEditor.dll
Binary file not shown.
Binary file modified _DOTween.Assembly/bin/Editor/DOTweenEditor.dll.mdb
Binary file not shown.

0 comments on commit eb98935

Please sign in to comment.