Author Topic: How to assign a sprite from a scriptable object?  (Read 2443 times)

will_brett

  • Newbie
  • *
  • Thank You
  • -Given: 1
  • -Receive: 0
  • Posts: 40
    • View Profile
How to assign a sprite from a scriptable object?
« on: December 29, 2014, 06:33:44 PM »
Hey all,

Im creating a scriptable object to manage a load of GUI shop items. The data in the scriptable object then modifies a template item.

My question is how do I define a sprite in a scriptable object? Would I do it as a string to the path of the sprite in the atlas and if so how?

Thanks

Will

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: How to assign a sprite from a scriptable object?
« Reply #1 on: December 30, 2014, 02:10:37 PM »
I am not quite clear on what you're asking. Are you asking how to assign a sprite? If so that's just sprite.spriteName = "Your Sprite". Or are you asking how to add a sprite to the atlas at run time? If so, that's not possible. Or are you asking how to add a new sprite to the scene? If so, NGUITools.AddWidget<UISprite>(parentObject).

will_brett

  • Newbie
  • *
  • Thank You
  • -Given: 1
  • -Receive: 0
  • Posts: 40
    • View Profile
Re: How to assign a sprite from a scriptable object?
« Reply #2 on: January 01, 2015, 01:39:22 PM »
Sprite.name = "yoursprite" should do the trick thanks