Author Topic: Resizable Sprite with drag handles on a timeline; Positioning checks.  (Read 2238 times)

Zophiel

  • Jr. Member
  • **
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 54
    • View Profile
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.

Zophiel

  • Jr. Member
  • **
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 54
    • View Profile
Re: Resizable Sprite with drag handles on a timeline; Positioning checks.
« Reply #1 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.

Zophiel

  • Jr. Member
  • **
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 54
    • View Profile
Re: Resizable Sprite with drag handles on a timeline; Positioning checks.
« Reply #2 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.