Author Topic: change spriteName problem in ngui 3  (Read 4447 times)

Markov

  • Newbie
  • *
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 27
    • View Profile
change spriteName problem in ngui 3
« on: October 09, 2013, 07:01:47 PM »
Hello!
I used to change sprites in this way:
sprite.spriteName = "spriteName";
sprite.MarkAsChanged();
But now in new NGUI this isn't working. What should I do?
A little clues:
- new sprite changes and appears, but doesn't show. If I set alpha to non 1, I see my changed sprite.
- also, if I click on sprite in editor it's staeting showing too.
« Last Edit: October 09, 2013, 07:28:30 PM by Markov »

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: change spriteName problem in ngui 3
« Reply #1 on: October 10, 2013, 07:34:43 AM »
MarkAsChanged shouldn't be needed. The sprite already gets marked as changed when you change its sprite name. This should work just fine. This is how all sprites are changed. Even in the UISpriteAnimation script. What else are you doing?

Markov

  • Newbie
  • *
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 27
    • View Profile
Re: change spriteName problem in ngui 3
« Reply #2 on: October 10, 2013, 03:09:18 PM »
Yea I deleted MarkAsChanged() but problem is still here. And it's everywhere in my project where Im changing a sprite name.

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: change spriteName problem in ngui 3
« Reply #3 on: October 11, 2013, 08:22:10 AM »
What version of NGUI?

The following script works just fine on a sprite with a collider on it, using the Wooden Atlas:
  1. public class Test : MonoBehaviour
  2. {
  3.         void OnClick ()
  4.         {
  5.                 UISprite sp = GetComponent<UISprite>();
  6.                 sp.spriteName = "Button";
  7.         }
  8. }
Changes the sprite just fine.