Author Topic: mySprite.sprite deprecated?  (Read 2810 times)

theprojectabot

  • Guest
mySprite.sprite deprecated?
« on: February 26, 2013, 04:39:59 PM »
Hi there, just updated to the new version of NGUI and now my wIcon.sprite = sT.sprite; is no longer working.  I understand it is now protected with SetAtlasSprite.  But for some reason my dumb brain isnt getting how to replicate the behavior I had before.  Could you help me?

  1. private void SwapTool(GameObject selectedTool)
  2.         {
  3.                 //Tool gets pressed, so the pickedObject.  
  4.                 Transform background = SearchHierarchyForTransform(selectedTool.transform, "Background");
  5.                 UISlicedSprite sT = background.GetComponentInChildren<UISlicedSprite>();
  6.                 if(sT != null)
  7.                 {
  8.                         //Swap out icon on active tool and close log bar.
  9.                         //  Need: reference to active tool icon.
  10.                         if(WeaponIcon != null)
  11.                         {
  12.                                 //Get component
  13.                                 UISprite wIcon = WeaponIcon.GetComponentInChildren<UISprite>();
  14.                                 if(wIcon != null)
  15.                                 {
  16.                                         wIcon.sprite = sT.sprite;
  17.                                         //NOW wIcon.SetAtlasSprite(sT.GetAtlasSprite());   though this doesnt work...
  18.                                 }
  19.                         }
  20.                 }
  21.                 // Close log bar
  22.                 if(BottomControls != null)     
  23.                 {
  24.                         NGUITools.SetActive(BottomControls, false);
  25.                 }
  26.                
  27.                 // change power on BrontoController
  28.                
  29.         }
  30.         #endregion

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: mySprite.sprite deprecated?
« Reply #1 on: February 26, 2013, 07:42:43 PM »
I removed it precisely because people were using it.

Always set your sprite using UISprite.spriteName.

theprojectabot

  • Guest
Re: mySprite.sprite deprecated?
« Reply #2 on: February 26, 2013, 08:37:12 PM »
Ok ill go that route.