Demigiant Forum

Unity Assets => DOTween & DOTween Pro => Topic started by: szymonwlo2 on May 28, 2015, 06:39:08 PM

Title: LineRenderer in DOTween PRO
Post by: szymonwlo2 on May 28, 2015, 06:39:08 PM
Hi,

Is DOTween Pro capable of drawing the line (Catmull rom) created by using the Path Manager, so the created lines would be seen also after launching the game not only in Gizmos?

Thanks,
Szymon
Title: Re: LineRenderer in DOTween PRO
Post by: Daniele on May 28, 2015, 08:39:29 PM
Hi,

Sorry but no, lines are only drawn as a visual cue in the Editor, not in the game itself.

Cheers,
Daniele
Title: Re: LineRenderer in DOTween PRO
Post by: szymonwlo2 on May 28, 2015, 09:22:36 PM
Thanks for the quick respond!
Is there any way to get the coordinates of the intermediate points between the waypoints, so I could use it to draw a line?
Title: Re: LineRenderer in DOTween PRO
Post by: Daniele on May 29, 2015, 10:26:01 AM
I'm adding this to my todo list. I'm working on other DOTween Pro features right now, but I'll see if I can push this forward, since it shouldn't be too difficult.
Title: Re: LineRenderer in DOTween PRO
Post by: Daniele on May 30, 2015, 01:44:02 PM
Voilą :)

If you didn't already do it, update to DOTween Pro's latest version, then overwrite the Demigiant/DOTween folder with the one attached here. After that, you can do:

Code: [Select]
myDOTweenPath.GetTween().PathGetDrawPoints();
to get a series of points you can use to draw the path at runtime. Note that PathGetDrawPoints also accepts an optional parameter to tell it how many subdivisions per segment to create. The higher the subdivisions, the more points will be generated and the more curved it will look when drawn (in case of curved paths: it's completely ignored in case of linear ones). The default value, 10, should be already ok anyway.

Here is also an example MonoBehaviour that I used to test it:

Code: [Select]
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]);
}
}
Title: Re: LineRenderer in DOTween PRO
Post by: szymonwlo2 on July 09, 2015, 10:55:06 PM
Thank you for updates. By using DOTween I managed to finish the game :)
Title: Re: LineRenderer in DOTween PRO
Post by: Daniele on July 09, 2015, 11:56:52 PM
That is great to hear, and I applaud you! Link, link! :)
Title: Re: LineRenderer in DOTween PRO
Post by: szymonwlo2 on July 10, 2015, 10:43:04 AM
It is not perfect but still working on it :)

https://play.google.com/store/apps/details?id=com.terribleapp.nextlevel (https://play.google.com/store/apps/details?id=com.terribleapp.nextlevel)
Title: Re: LineRenderer in DOTween PRO
Post by: Daniele on July 10, 2015, 03:30:42 PM
Nice! :)
Title: Re: LineRenderer in DOTween PRO
Post by: rhaziell on November 11, 2015, 07:16:04 PM
Bump!

I cannot get the PathGetDrawPoints from DOTween pro 0.9.380 - there is no such method or extension in any namespace inside DG.

Could you provide me with solution?
Title: Re: LineRenderer in DOTween PRO
Post by: Daniele on November 11, 2015, 07:56:30 PM
I just checked and it's there indeed. Are you sure you imported the correct namespace? It's DG.Tweening, not just DG.
Title: Re: LineRenderer in DOTween PRO
Post by: rhaziell on November 12, 2015, 12:14:52 AM
I double checked and found that the issue was with priviledges to DOTween.XML files - once I set them straight I was able to correctly update plugin and mentioned method was there.

Thank you
Title: Re: LineRenderer in DOTween PRO
Post by: Daniele on November 12, 2015, 01:47:12 AM
Weird, first time I hear about that. Thanks for letting me know.