Author Topic: Adding Sprite Selector to my script  (Read 3631 times)

vallcrist

  • Newbie
  • *
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 49
    • View Profile
Adding Sprite Selector to my script
« on: January 17, 2014, 08:34:56 PM »
Hello there.

One of my buttons ( fullscreen button ) has 2 states, my script currently exchanges between those states by changing the spriteName property of the UISprite, this works well except for the fact that i need to type in the sprite name in the inspector, which is kinda error prone as one can easily mistype something or mistake the case of the word..

Is there any way to add the sprite selector which NGUI uses to a script i make, without having to create a custom inspector for it?

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: Adding Sprite Selector to my script
« Reply #1 on: January 17, 2014, 11:28:29 PM »
Have a look at NGUIEditorTools.Draw series of functions. NGUIEditorTools.DrawSpriteField for example.

vallcrist

  • Newbie
  • *
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 49
    • View Profile
Re: Adding Sprite Selector to my script
« Reply #2 on: January 17, 2014, 11:57:37 PM »
Hmm, thanks for the tip.

I'm currently trying to create a PropertyDrawer for sprite selection, if I manage to do it i'll share it here, with your permission ofc.

EDIT:

managed to do something, barely, though. Seems like propertydrawers doesn't allow for GUILayout usage so i had to hack a little. here's 2 images showing how it's working.

Code : http://ctrlv.in/284626
Inspector : http://ctrlv.in/284625
« Last Edit: January 18, 2014, 01:08:30 AM by vallcrist »