1
0
mirror of https://github.com/Cardidi/dotween-upm-fork.git synced 2026-02-04 22:34:56 +08:00

Added PathGetDrawPoints tween method

This commit is contained in:
Daniele Giardini 2015-05-30 19:19:13 +02:00
parent 7545637cca
commit f8a483d91d
23 changed files with 221 additions and 16 deletions

View File

@ -785,16 +785,28 @@
</member>
<member name="M:DG.Tweening.TweenExtensions.PathGetPoint(DG.Tweening.Tween,System.Single)">
<summary>
Returns a point on a path based on the given path percentage
(returns <code>Vector3.zero</code> if this is not a path tween, if the tween is invalid, or if the path is not yet initialized)
Returns a point on a path based on the given path percentage.
Returns <code>Vector3.zero</code> if this is not a path tween, if the tween is invalid, or if the path is not yet initialized.
A path is initialized after its tween starts, or immediately if the tween was created with the Path Editor (DOTween Pro feature).
You can force a path to be initialized by calling <code>myTween.ForceInit()</code>.
</summary>
<param name="pathPercentage">Percentage of the path (0 to 1) on which to get the point</param>
</member>
<member name="M:DG.Tweening.TweenExtensions.PathGetDrawPoints(DG.Tweening.Tween,System.Int32)">
<summary>
Returns an array of points that can be used to draw the path.
Note that this method generates allocations, because it creates a new array.
Returns <code>NULL</code> if this is not a path tween, if the tween is invalid, or if the path is not yet initialized.
A path is initialized after its tween starts, or immediately if the tween was created with the Path Editor (DOTween Pro feature).
You can force a path to be initialized by calling <code>myTween.ForceInit()</code>.
</summary>
<param name="subdivisionsXSegment">How many points to create for each path segment (waypoint to waypoint).
Only used in case of non-Linear paths</param>
</member>
<member name="M:DG.Tweening.TweenExtensions.PathLength(DG.Tweening.Tween)">
<summary>
Returns the length of a path (returns -1 if this is not a path tween, if the tween is invalid, or if the path is not yet initialized).
Returns the length of a path.
Returns -1 if this is not a path tween, if the tween is invalid, or if the path is not yet initialized.
A path is initialized after its tween starts, or immediately if the tween was created with the Path Editor (DOTween Pro feature).
You can force a path to be initialized by calling <code>myTween.ForceInit()</code>.
</summary>

View File

@ -785,16 +785,28 @@
</member>
<member name="M:DG.Tweening.TweenExtensions.PathGetPoint(DG.Tweening.Tween,System.Single)">
<summary>
Returns a point on a path based on the given path percentage
(returns <code>Vector3.zero</code> if this is not a path tween, if the tween is invalid, or if the path is not yet initialized)
Returns a point on a path based on the given path percentage.
Returns <code>Vector3.zero</code> if this is not a path tween, if the tween is invalid, or if the path is not yet initialized.
A path is initialized after its tween starts, or immediately if the tween was created with the Path Editor (DOTween Pro feature).
You can force a path to be initialized by calling <code>myTween.ForceInit()</code>.
</summary>
<param name="pathPercentage">Percentage of the path (0 to 1) on which to get the point</param>
</member>
<member name="M:DG.Tweening.TweenExtensions.PathGetDrawPoints(DG.Tweening.Tween,System.Int32)">
<summary>
Returns an array of points that can be used to draw the path.
Note that this method generates allocations, because it creates a new array.
Returns <code>NULL</code> if this is not a path tween, if the tween is invalid, or if the path is not yet initialized.
A path is initialized after its tween starts, or immediately if the tween was created with the Path Editor (DOTween Pro feature).
You can force a path to be initialized by calling <code>myTween.ForceInit()</code>.
</summary>
<param name="subdivisionsXSegment">How many points to create for each path segment (waypoint to waypoint).
Only used in case of non-Linear paths</param>
</member>
<member name="M:DG.Tweening.TweenExtensions.PathLength(DG.Tweening.Tween)">
<summary>
Returns the length of a path (returns -1 if this is not a path tween, if the tween is invalid, or if the path is not yet initialized).
Returns the length of a path.
Returns -1 if this is not a path tween, if the tween is invalid, or if the path is not yet initialized.
A path is initialized after its tween starts, or immediately if the tween was created with the Path Editor (DOTween Pro feature).
You can force a path to be initialized by calling <code>myTween.ForceInit()</code>.
</summary>

View File

@ -785,16 +785,28 @@
</member>
<member name="M:DG.Tweening.TweenExtensions.PathGetPoint(DG.Tweening.Tween,System.Single)">
<summary>
Returns a point on a path based on the given path percentage
(returns <code>Vector3.zero</code> if this is not a path tween, if the tween is invalid, or if the path is not yet initialized)
Returns a point on a path based on the given path percentage.
Returns <code>Vector3.zero</code> if this is not a path tween, if the tween is invalid, or if the path is not yet initialized.
A path is initialized after its tween starts, or immediately if the tween was created with the Path Editor (DOTween Pro feature).
You can force a path to be initialized by calling <code>myTween.ForceInit()</code>.
</summary>
<param name="pathPercentage">Percentage of the path (0 to 1) on which to get the point</param>
</member>
<member name="M:DG.Tweening.TweenExtensions.PathGetDrawPoints(DG.Tweening.Tween,System.Int32)">
<summary>
Returns an array of points that can be used to draw the path.
Note that this method generates allocations, because it creates a new array.
Returns <code>NULL</code> if this is not a path tween, if the tween is invalid, or if the path is not yet initialized.
A path is initialized after its tween starts, or immediately if the tween was created with the Path Editor (DOTween Pro feature).
You can force a path to be initialized by calling <code>myTween.ForceInit()</code>.
</summary>
<param name="subdivisionsXSegment">How many points to create for each path segment (waypoint to waypoint).
Only used in case of non-Linear paths</param>
</member>
<member name="M:DG.Tweening.TweenExtensions.PathLength(DG.Tweening.Tween)">
<summary>
Returns the length of a path (returns -1 if this is not a path tween, if the tween is invalid, or if the path is not yet initialized).
Returns the length of a path.
Returns -1 if this is not a path tween, if the tween is invalid, or if the path is not yet initialized.
A path is initialized after its tween starts, or immediately if the tween was created with the Path Editor (DOTween Pro feature).
You can force a path to be initialized by calling <code>myTween.ForceInit()</code>.
</summary>

View File

@ -0,0 +1,27 @@
using UnityEngine;
using System.Collections;
using DG.Tweening;
public class PathsWDrawPaths : MonoBehaviour
{
public DOTweenPath path;
public int subdivisionsXSegment = 10;
public Color startColor = Color.white;
public Color endColor = Color.white;
public float startW = 1;
public float endW = 1;
public Material material;
void Start()
{
Vector3[] drawPoints = path.GetTween().PathGetDrawPoints(subdivisionsXSegment);
int pointsCount = drawPoints.Length;
LineRenderer lr = path.gameObject.AddComponent<LineRenderer>();
lr.material = material;
lr.SetColors(startColor, endColor);
lr.SetWidth(startW, endW);
lr.SetVertexCount(pointsCount);
for (int i = 0; i < pointsCount; ++i) lr.SetPosition(i, drawPoints[i]);
}
}

View File

@ -0,0 +1,12 @@
fileFormatVersion: 2
guid: b8412d3159b7e4f41a52d0726d03859f
timeCreated: 1432984650
licenseType: Free
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: 78b42a9711be35745a01f7ef360f60c0
timeCreated: 1432984644
licenseType: Free
DefaultImporter:
userData:
assetBundleName:
assetBundleVariant:

View File

@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: caadc059b8b98a845adf07082f904d83
timeCreated: 1432985499
licenseType: Free
NativeFormatImporter:
userData:
assetBundleName:
assetBundleVariant:

Binary file not shown.

After

Width:  |  Height:  |  Size: 6.1 KiB

View File

@ -0,0 +1,55 @@
fileFormatVersion: 2
guid: 9a032d2a2a862fb4e8d9a4acd8cf0093
timeCreated: 1432985686
licenseType: Free
TextureImporter:
fileIDToRecycleName: {}
serializedVersion: 2
mipmaps:
mipMapMode: 0
enableMipMap: 1
linearTexture: 0
correctGamma: 0
fadeOut: 0
borderMipMap: 0
mipMapFadeDistanceStart: 1
mipMapFadeDistanceEnd: 3
bumpmap:
convertToNormalMap: 0
externalNormalMap: 0
heightScale: .25
normalMapFilter: 0
isReadable: 0
grayScaleToAlpha: 0
generateCubemap: 0
cubemapConvolution: 0
cubemapConvolutionSteps: 8
cubemapConvolutionExponent: 1.5
seamlessCubemap: 0
textureFormat: -3
maxTextureSize: 128
textureSettings:
filterMode: -1
aniso: -1
mipBias: -1
wrapMode: 1
nPOTScale: 1
lightmap: 0
rGBM: 0
compressionQuality: 50
spriteMode: 0
spriteExtrude: 1
spriteMeshType: 1
alignment: 0
spritePivot: {x: .5, y: .5}
spriteBorder: {x: 0, y: 0, z: 0, w: 0}
spritePixelsToUnits: 100
alphaIsTransparency: 1
textureType: -1
buildTargetSettings: []
spriteSheet:
sprites: []
spritePackingTag:
userData:
assetBundleName:
assetBundleVariant:

View File

@ -32,7 +32,7 @@ namespace DG.Tweening
public class DOTween
{
/// <summary>DOTween's version</summary>
public static readonly string Version = "1.0.750";
public static readonly string Version = "1.0.755";
///////////////////////////////////////////////
// Options ////////////////////////////////////

View File

@ -138,6 +138,23 @@ namespace DG.Tweening.Plugins.Core.PathCore
return 0;
}
// USED EXTERNALLY, to output a series of points that can be used to draw the path outside of DOTween
// (called by TweenExtensions.PathGetDrawPoints)
internal static Vector3[] GetDrawPoints(Path p, int drawSubdivisionsXSegment)
{
int wpsCount = p.wps.Length;
if (p.type == PathType.Linear) return p.wps;
int gizmosSubdivisions = wpsCount * drawSubdivisionsXSegment;
Vector3[] drawPoints = new Vector3[gizmosSubdivisions + 1];
for (int i = 0; i <= gizmosSubdivisions; ++i) {
float perc = i / (float)gizmosSubdivisions;
Vector3 wp = p.GetPoint(perc);
drawPoints[i] = wp;
}
return drawPoints;
}
// Refreshes the waypoints used to draw non-linear gizmos and the PathInspector scene view.
// Called by Draw method or by DOTweenPathInspector
internal static void RefreshNonLinearDrawWps(Path p)

View File

@ -493,8 +493,8 @@ namespace DG.Tweening
#region Path Tweens
/// <summary>
/// Returns a point on a path based on the given path percentage
/// (returns <code>Vector3.zero</code> if this is not a path tween, if the tween is invalid, or if the path is not yet initialized)
/// Returns a point on a path based on the given path percentage.
/// Returns <code>Vector3.zero</code> if this is not a path tween, if the tween is invalid, or if the path is not yet initialized.
/// A path is initialized after its tween starts, or immediately if the tween was created with the Path Editor (DOTween Pro feature).
/// You can force a path to be initialized by calling <code>myTween.ForceInit()</code>.
/// </summary>
@ -523,7 +523,37 @@ namespace DG.Tweening
}
/// <summary>
/// Returns the length of a path (returns -1 if this is not a path tween, if the tween is invalid, or if the path is not yet initialized).
/// Returns an array of points that can be used to draw the path.
/// Note that this method generates allocations, because it creates a new array.
/// Returns <code>NULL</code> if this is not a path tween, if the tween is invalid, or if the path is not yet initialized.
/// A path is initialized after its tween starts, or immediately if the tween was created with the Path Editor (DOTween Pro feature).
/// You can force a path to be initialized by calling <code>myTween.ForceInit()</code>.
/// </summary>
/// <param name="subdivisionsXSegment">How many points to create for each path segment (waypoint to waypoint).
/// Only used in case of non-Linear paths</param>
public static Vector3[] PathGetDrawPoints(this Tween t, int subdivisionsXSegment = 10)
{
if (t == null) {
if (Debugger.logPriority > 1) Debugger.LogNullTween(t); return null;
} else if (!t.active) {
if (Debugger.logPriority > 1) Debugger.LogInvalidTween(t); return null;
} else if (t.isSequenced) {
if (Debugger.logPriority > 1) Debugger.LogNestedTween(t); return null;
}
TweenerCore<Vector3, Path, PathOptions> pathTween = t as TweenerCore<Vector3, Path, PathOptions>;
if (pathTween == null) {
if (Debugger.logPriority > 1) Debugger.LogNonPathTween(t); return null;
} else if (!pathTween.endValue.isFinalized) {
if (Debugger.logPriority > 1) Debugger.LogWarning("The path is not finalized yet"); return null;
}
return Path.GetDrawPoints(pathTween.endValue, subdivisionsXSegment);
}
/// <summary>
/// Returns the length of a path.
/// Returns -1 if this is not a path tween, if the tween is invalid, or if the path is not yet initialized.
/// A path is initialized after its tween starts, or immediately if the tween was created with the Path Editor (DOTween Pro feature).
/// You can force a path to be initialized by calling <code>myTween.ForceInit()</code>.
/// </summary>

View File

@ -785,16 +785,28 @@
</member>
<member name="M:DG.Tweening.TweenExtensions.PathGetPoint(DG.Tweening.Tween,System.Single)">
<summary>
Returns a point on a path based on the given path percentage
(returns <code>Vector3.zero</code> if this is not a path tween, if the tween is invalid, or if the path is not yet initialized)
Returns a point on a path based on the given path percentage.
Returns <code>Vector3.zero</code> if this is not a path tween, if the tween is invalid, or if the path is not yet initialized.
A path is initialized after its tween starts, or immediately if the tween was created with the Path Editor (DOTween Pro feature).
You can force a path to be initialized by calling <code>myTween.ForceInit()</code>.
</summary>
<param name="pathPercentage">Percentage of the path (0 to 1) on which to get the point</param>
</member>
<member name="M:DG.Tweening.TweenExtensions.PathGetDrawPoints(DG.Tweening.Tween,System.Int32)">
<summary>
Returns an array of points that can be used to draw the path.
Note that this method generates allocations, because it creates a new array.
Returns <code>NULL</code> if this is not a path tween, if the tween is invalid, or if the path is not yet initialized.
A path is initialized after its tween starts, or immediately if the tween was created with the Path Editor (DOTween Pro feature).
You can force a path to be initialized by calling <code>myTween.ForceInit()</code>.
</summary>
<param name="subdivisionsXSegment">How many points to create for each path segment (waypoint to waypoint).
Only used in case of non-Linear paths</param>
</member>
<member name="M:DG.Tweening.TweenExtensions.PathLength(DG.Tweening.Tween)">
<summary>
Returns the length of a path (returns -1 if this is not a path tween, if the tween is invalid, or if the path is not yet initialized).
Returns the length of a path.
Returns -1 if this is not a path tween, if the tween is invalid, or if the path is not yet initialized.
A path is initialized after its tween starts, or immediately if the tween was created with the Path Editor (DOTween Pro feature).
You can force a path to be initialized by calling <code>myTween.ForceInit()</code>.
</summary>

Binary file not shown.