Tasharen Entertainment Forum

Support => NGUI 3 Support => Topic started by: Zophiel on October 11, 2013, 04:16:21 PM

Title: Resizable Sprite with drag handles on a timeline; Positioning checks.
Post by: Zophiel on October 11, 2013, 04:16:21 PM
Hello,

Ive created a timeline in Unity where you can drag and drop sprite into and then you can drag the sprites at the sides to increase/decrease the width.

It all works great except that i cant seem to determine the centerpoint and the start and end of the widget. Its built as follows:

Container - With a manager script for the objects interactions
      - Background sprite with collider for dragging
      - Arrows for resizing

The code can be seen here: http://pastebin.com/FfzRwKpq

Below is the code i use to see if a clips end or start point overlaps with that of another object in the time line
  1. !timeline.Any( o => o.ValueObject.start <= vo.end && o.ValueObject.end >= vo.start )

But this is giving me very inaccurate results for some reasons. The center point of the clip seems to be fine but any time i check the start and end points it gives very weird results as if the box is shifted over x-amount of pixels.
Title: Re: Resizable Sprite with drag handles on a timeline; Positioning checks.
Post by: Zophiel on October 12, 2013, 07:12:24 AM
Ive attached a webbuild to illustrate the behavior.

Just drag the existing one into the timeline, move the arrows a bit. then click a button on the left and drag that one into the scene. It should turn red if it's covering the one already in there.
Title: Re: Resizable Sprite with drag handles on a timeline; Positioning checks.
Post by: Zophiel on October 12, 2013, 07:47:24 AM
Problem has been resolved. I was calculating the start and end position incorrectly in the OnDrag method. Calculating the bounds and simply using those has fixed it.