Author Topic: Is there a way of setting the target of UIDragObject via code?  (Read 3508 times)

jaz1974

  • Guest
Is there a way of setting the target of UIDragObject via code?
« on: November 26, 2013, 02:27:36 PM »
Hi there,

Hoping someone can offer some help on this one.

I'm adding a GameObject and with the UIDragObject component in runtime.

I 'think' I'm doing that part ok - at least it adds the object and assigns the component to it.

I'm having difficulty getting it to assign the 'Target object' though.

Any advice on how I do this?  Been trying several things, but none seem to work.


Many thanks,

Jaz

jaz1974

  • Guest
Re: Is there a way of setting the target of UIDragObject via code?
« Reply #1 on: November 26, 2013, 02:42:32 PM »
ah...I think I may have got it :

subParentObject.GetComponent<UIDragObject>().target = subParentObject.transform;

....this seems to work for me.

Essentially assigning the target as itself.
Please feel free to correct it if it's not the way I should be doing it.

Regards,

Jaz

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: Is there a way of setting the target of UIDragObject via code?
« Reply #2 on: November 26, 2013, 11:37:56 PM »
Yeah that's perfectly fine.