Author Topic: Losing sprite references using Atlas reference  (Read 13429 times)

Game Whiz

  • Guest
Re: Losing sprite references using Atlas reference
« Reply #15 on: February 16, 2013, 02:28:24 PM »
Like I said, I have my atlases pointing to null with no problem whatsoever. To avoid having Unity loading up the last atlas in the editor, I have a "Force null" flag in my atlas manager, that I set prior to building. I run the game once in the editor, so that all atlases are set to null and then I clear that flag from my atlas manager. Then, at runtime, my atlas manager chooses the appropriate atlases.

FizzPow

  • Jr. Member
  • **
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 83
    • View Profile
    • FizzPow Games
Re: Losing sprite references using Atlas reference
« Reply #16 on: February 16, 2013, 02:31:20 PM »
Like I said, I have my atlases pointing to null with no problem whatsoever. To avoid having Unity loading up the last atlas in the editor, I have a "Force null" flag in my atlas manager, that I set prior to building. I run the game once in the editor, so that all atlases are set to null and then I clear that flag from my atlas manager. Then, at runtime, my atlas manager chooses the appropriate atlases.

Well I am having all kinds of trouble, so I don't know why it works for you.  I am pulling my hair out here because I am constantly losing my sprite names and not even realizing it until I go to send out a test build and some panel I haven't even looked at in a week is all using the first sprite in the atlas.  I have been trying to debug and fix the sprite code but having no luck myself.  I will make a repro project later when I have more time.  It's extremely simple to cause this problem so I don't know why noone else is seeing this.  I want to cry, lol.

SkaiCloud

  • Newbie
  • *
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 7
    • View Profile
Re: Losing sprite references using Atlas reference
« Reply #17 on: February 16, 2013, 03:41:56 PM »
I just now found out that if my atlas aren't even I loose sprite reference.

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: Losing sprite references using Atlas reference
« Reply #18 on: February 16, 2013, 09:22:28 PM »
Try 2.3.3d.

FizzPow

  • Jr. Member
  • **
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 83
    • View Profile
    • FizzPow Games
Re: Losing sprite references using Atlas reference
« Reply #19 on: February 17, 2013, 01:13:01 AM »
Try 2.3.3d.

Using this latest version.  If I just simply hit delete on the atlas on my reference I get below crash and one of my sprites loses its spritename to the first sprite on the atlas.  If I set it null with my editor code, I get the same crash on all my sprites and they all lose their spritenames.

  1. NullReferenceException: Object reference not set to an instance of an object
  2. UISprite.GetAtlasSprite () (at Assets/NGUI/Scripts/UI/UISprite.cs:129)
  3. UISprite.get_isValid () (at Assets/NGUI/Scripts/UI/UISprite.cs:162)
  4. UISprite.set_spriteName (System.String value) (at Assets/NGUI/Scripts/UI/UISprite.cs:110)
  5. UISprite.set_atlas (.UIAtlas value) (at Assets/NGUI/Scripts/UI/UISprite.cs:74)
  6. UIAtlas.MarkAsDirty () (at Assets/NGUI/Scripts/UI/UIAtlas.cs:388)
  7. UIAtlas.set_replacement (.UIAtlas value) (at Assets/NGUI/Scripts/UI/UIAtlas.cs:240)
  8. UIAtlasInspector.OnSelectAtlas (UnityEngine.MonoBehaviour obj) (at Assets/NGUI/Scripts/Editor/UIAtlasInspector.cs:76)
  9. ComponentSelector.Draw[UIAtlas] (System.String buttonName, .UIAtlas obj, .OnSelectionCallback cb, UnityEngine.GUILayoutOption[] options) (at Assets/NGUI/Scripts/Editor/ComponentSelector.cs:45)
  10. ComponentSelector.Draw[UIAtlas] (.UIAtlas obj, .OnSelectionCallback cb, UnityEngine.GUILayoutOption[] options) (at Assets/NGUI/Scripts/Editor/ComponentSelector.cs:54)
  11. UIAtlasInspector.OnInspectorGUI () (at Assets/NGUI/Scripts/Editor/UIAtlasInspector.cs:116)
  12. UnityEditor.InspectorWindow.DrawEditors (Boolean isRepaintEvent, UnityEditor.Editor[] editors, Boolean eyeDropperDirty) (at C:/BuildAgent/work/14194e8ce88cdf47/Editor/Mono/Inspector/InspectorWindow.cs:888)
  13. UnityEditor.InspectorWindow.OnGUI () (at C:/BuildAgent/work/14194e8ce88cdf47/Editor/Mono/Inspector/InspectorWindow.cs:243)
  14. System.Reflection.MonoMethod.Invoke (System.Object obj, BindingFlags invokeAttr, System.Reflection.Binder binder, System.Object[] parameters, System.Globalization.CultureInfo culture)

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: Losing sprite references using Atlas reference
« Reply #20 on: February 17, 2013, 05:09:42 AM »
If that's the case, then somehow mAtlas.spriteList[0] ends up being null for you. How that's possible -- I can't even imagine. Add a null check to mSpriteName = mSprite.name; (line 129 of UISprite). I have no idea what is going on there in your project, and I can't reproduce it here.

Game Whiz

  • Guest
Re: Losing sprite references using Atlas reference
« Reply #21 on: February 17, 2013, 07:13:07 AM »
2.33d is working perfectly for me. Thanks for also including the fix for UIWidget's finalAlpha.

FizzPow

  • Jr. Member
  • **
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 83
    • View Profile
    • FizzPow Games
Re: Losing sprite references using Atlas reference
« Reply #22 on: February 17, 2013, 01:07:03 PM »
If that's the case, then somehow mAtlas.spriteList[0] ends up being null for you. How that's possible -- I can't even imagine. Add a null check to mSpriteName = mSprite.name; (line 129 of UISprite). I have no idea what is going on there in your project, and I can't reproduce it here.

Yay, I always seem to have a knack for finding issues noone else has ;)  So I added a null check and that fixes the crash, but all my spritenames are still being messed up when I remove the atlas from the reference atlas.  What can I do to help you, help me?  I will start working on a repro project?

Edit: not sure if this matters, but all my atlases are created with Texture Packer.  Could this be related?
« Last Edit: February 17, 2013, 01:09:13 PM by FizzPow »

FizzPow

  • Jr. Member
  • **
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 83
    • View Profile
    • FizzPow Games
Re: Losing sprite references using Atlas reference
« Reply #23 on: February 17, 2013, 01:42:14 PM »
Ok here is a repro project as simple as I could make.  Just click the #1 sprite to toggle the reference and you will see they all switch from 1, 2, 3, 4 to 1, 1, 1, 1

Note: I am using Unity 3.5.7f6

Edit: You can also accomplish the same thing in the editor by just deleting the atlas on the reference and then setting it back again.
« Last Edit: February 17, 2013, 07:05:33 PM by ArenMook »

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: Losing sprite references using Atlas reference
« Reply #24 on: February 17, 2013, 07:05:48 PM »
You just posted NGUI's source code in public. Smart.

FizzPow

  • Jr. Member
  • **
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 83
    • View Profile
    • FizzPow Games
Re: Losing sprite references using Atlas reference
« Reply #25 on: August 06, 2013, 03:58:13 PM »
I didn't get a chance to reply to this at the time, but seeing as there have been so many views.  This was fixed a couple days later, but I don't recall which version exactly at the time it was.