Author Topic: UITextures becoming UISprites?  (Read 7800 times)

Ferazel

  • Full Member
  • ***
  • Thank You
  • -Given: 1
  • -Receive: 2
  • Posts: 150
    • View Profile
UITextures becoming UISprites?
« on: October 09, 2013, 01:43:36 PM »
I'm encountering a weird inconsistent bug and it appears that UITextures are changing into UISprites for some reason which is causing null references to the UITexture. I've only noticed this post 3.0? I've tried to replicate, but I'm not sure what is happening. Is there any reason why the code would be replaced as a UISprite like that? Can anyone else corroborate this issue and see if maybe we can track it down?

Edit: I know that it is not post is not helpful from a technical support perspective until I have repeatable steps. I'm just curious if other have noticed this before I really dig in to try to track this down.

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: UITextures becoming UISprites?
« Reply #1 on: October 09, 2013, 01:45:43 PM »
UITexture will change to a UISprite if you select the UI hierarchy, open the atlas maker, and hit the Add/Update button.

It's actually a hidden feature -- you can create your entire UI layout using UITextures, then create an atlas just by selecting the UIRoot -- and NGUI will automatically replace all UITextures with UISprites for you.

And, on the next episode of The More You Know™... I shall reveal the hidden "Make My Game" button that comes with NGUI. Stay tuned...

Nicki

  • Global Moderator
  • Hero Member
  • *****
  • Thank You
  • -Given: 33
  • -Receive: 141
  • Posts: 1,768
    • View Profile
Re: UITextures becoming UISprites?
« Reply #2 on: October 10, 2013, 01:12:41 AM »
If you add the texture you were using in the UITexture to an atlas, the UITexture is changed to a UISprite with a reference to that sprite instead. If this is not intended to be what you want - like you want both the UITexture working with the raw texture and have the texture available for a sprite, this will fight you a little bit.

I'd recommend you have textures for the atlas entirely separate from textures you're using directly, so you don't get into a situation like that.

Ferazel

  • Full Member
  • ***
  • Thank You
  • -Given: 1
  • -Receive: 2
  • Posts: 150
    • View Profile
Re: UITextures becoming UISprites?
« Reply #3 on: October 10, 2013, 08:10:38 AM »
That definitely helps! I think the biggest problem is that I was hoping to use the same name for the larger-sized resource in addition to the sprite name for the atlased version. I'll have to add a suffix to the big image loading so that it doesn't think that the images are the same as the ones located in the atlas. Thanks for your omniscient help ArenMook and Nicki. :)

madcalf

  • Newbie
  • *
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 4
    • View Profile
Re: UITextures becoming UISprites?
« Reply #4 on: February 13, 2014, 07:59:07 PM »
I have also been having this issue and I thought i was imagining it until it happened a third time and was able to connect it with updating my atlas! I had switched from using UISprites to UITextures for certain images because I need to load them dynamically from files outside the project folder, but completely neglected to remove them from the atlas.

So does the switch only happen if the UI hierarchy is selected when you update the atlas? Meaning if i need the images to co-exist, can i avoid this by just not having the UI selected whenever i update my atlas? Or do i need to name the images differently?

thanks!
d

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: UITextures becoming UISprites?
« Reply #5 on: February 14, 2014, 05:21:27 AM »
Co-existing images imply duplicated texture memory, which is a pretty expensive waste to have. You should either use textures, or sprites, not both. Once something gets added to the atlas, there is no sense in keeping UITextures referencing the original images. Keeping the references is also bound to lead to confusion.

As for your question... to be honest I am not sure if this occurs only if you have the hierarchy selected or not as I added this feature many months ago. It may happen on whatever you have active in the scene at the time of the atlas update.

armanigt

  • Newbie
  • *
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 2
    • View Profile
Re: UITextures becoming UISprites?
« Reply #6 on: January 27, 2015, 11:15:45 PM »
Hi -

This behavior is causing me a great deal of pain - if there's any way to disable it I would be very greatful.

Here's why:

I have an application that uses UITextures to dynamically render textures that are provided by the user at run time, such as photo-album pics. However, before those textures are loaded, I have a default texture that is shown. I also have a lot of sprites in my atlas. So any time I go to update my atlas, some of my UITextures (amazingly not all) get changed into UISprites, and the connection to the public UITexture ** variables in my classes get broken.

The project is pretty far along so changing textures might be time expensive.

So . . . is there any way to disable this feature?


ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: UITextures becoming UISprites?
« Reply #7 on: January 28, 2015, 02:36:07 AM »
I've answered this question a few times now. Simply open UIAtlasMaker, find line 1064 and comment it out.
  1. //NGUIEditorTools.UpgradeTexturesToSprites(NGUISettings.atlas);