Tasharen Entertainment Forum

Support => NGUI 3 Support => Topic started by: citizen12 on August 06, 2012, 03:30:02 PM

Title: UITexture disappears
Post by: citizen12 on August 06, 2012, 03:30:02 PM
I am trying a small test with NGUI.  I created a New UI, then created a New Widget -- UITexture.  I place a texture on it and can see the rectangle in the Game view.  I then hit Play an the texture disappears from the Game view.  It does not come back when I hit stop.  Also, even though I see that the game object still has the UITexture script, the other info, like the Depth and Make Pixel-Perfect UI elements have gone away.  I have to reset the Texture in order for them to come back.  I am using 3.5.4.

Title: Re: UITexture disappears
Post by: ArenMook on August 06, 2012, 07:03:32 PM
What version of NGUI do you use? There was an issue in one of the earlier versions but has since been fixed.
Title: Re: UITexture disappears
Post by: vei on August 07, 2012, 05:06:38 AM
Having the same problem. I'm using Unity 3.5.4 with NGUI 2.1.3.
Title: Re: UITexture disappears
Post by: ArenMook on August 07, 2012, 12:20:15 PM
Hmm you're right. Something must have gotten broken in the last update. Lemme fix it.
Title: Re: UITexture disappears
Post by: citizen12 on August 10, 2012, 01:14:27 PM
Looking forward to the fix.  Thanks.
Title: Re: UITexture disappears
Post by: PhilipC on August 10, 2012, 01:22:17 PM
Have you updated to 2.1.4? i believe that we have already fixed this.... Let us know if its still not working.
Title: Re: UITexture disappears
Post by: citizen12 on August 10, 2012, 04:06:11 PM
I updated to 2.1.4 and Unity 3.5.5.  It's still broken.  I can send you my project if it would help.

Title: Re: UITexture disappears
Post by: ArenMook on August 10, 2012, 04:50:27 PM
Try this UITexture file and see if it still happens.
Title: Re: UITexture disappears
Post by: citizen12 on August 10, 2012, 05:04:40 PM
Same thing.  After 3 or 4 plays, it just chokes and the custom property window for the UITexture goes away.

I don't know if it matters, but I am setting the mainTexture property on my UITexture in script when my game is running.
Title: Re: UITexture disappears
Post by: ArenMook on August 10, 2012, 05:06:45 PM
If you set it while the game is running, then it will not (and should not) persist when you stop the game.
Title: Re: UITexture disappears
Post by: citizen12 on August 10, 2012, 05:08:52 PM
If you set it while the game is running, then it will not (and should not) persist when you stop the game.

How am I supposed to modify the Depth & Pivot etc if that UI goes away?
Title: Re: UITexture disappears
Post by: ArenMook on August 10, 2012, 05:10:38 PM
Set the texture edit mode.
Title: Re: UITexture disappears
Post by: citizen12 on August 10, 2012, 05:14:57 PM
Set the texture edit mode.

Not sure what you mean by that.
Title: Re: UITexture disappears
Post by: ArenMook on August 10, 2012, 06:19:55 PM
In the editor, while the application is not running, choose a texture that will be used by UITexture by selecting it via the inspector window.
Title: Re: UITexture disappears
Post by: RocketPop Games on August 10, 2012, 09:08:56 PM
FYI RenderTextures made this happen every time to me (drop a RTT on a UITexture texture inspector) - but the patched file above fixed it . I spoke too soon. The updated file above makes it work in edit mode but after playing it disappears. The temporary fix is to make a material for the RT, and then it works..

Thanks!
Title: Re: UITexture disappears
Post by: ferretnt on August 22, 2012, 02:57:50 PM
I'm seeing the same issue - in my panel I have six buttons displaying UITextures (they're showing user-generated textures and not during gameplay so atlasing isn't an issue.)

When I hit "play", the UITexture textures are semi-randomly cleared, that is, by the time I've played the game three or four times they're all reset. Looking at the diffs of my scene file in source control confirms this.

For now, I've created a material per button as RocketPop suggested, but it would be great to confirm this issue still exists and it's nothing else I'm doing.

To confirm, is the UITexture script for download above identical to that included in 2.1.4a? I can't see any difference.

Thanks,
Alex
Title: Re: UITexture disappears
Post by: ArenMook on August 22, 2012, 03:11:52 PM
UIWidget is what changed there, so I'd look at that one.
Title: Re: UITexture disappears
Post by: ferretnt on August 22, 2012, 03:56:56 PM
I'm confused - I saw a download of UITexture.cs in this thread previously. Didn't see a download of UIWidget.cs though.
Title: Re: UITexture disappears
Post by: ArenMook on August 22, 2012, 04:30:01 PM
Grab 2.1.5 and see if it still happens.
Title: Re: UITexture disappears
Post by: ferretnt on August 22, 2012, 05:33:15 PM
Still broken (but, I think, slightly different, it's difficult to flip backwards and forwards between versions) behaviour.

Now, it looks like I never lose ALL of the UITextures - one of them (and which one is non-deterministic) always seems to survive.

Here's my repro steps:
1. Make a panel.
2. Make a Button.
3. Delete the UILabel component from the button. Replace it with a UI Texture.
4. Bias the label (UITexture) element forward in Z (otherwise it won't sort in front of the background.)
5. Duplicate that button a bunch of times.
6. Assign a different texture to each UITexture.
7. Start/Stop the app in the editor a couple of times

I should add that the UITextures are set to null in the inspector (they're not just depth-sorted away or anything dumb like that.)

Let me know if you can't repro that and I'll send you my UI Testbed Scene.

I see a large volume of diffs with 2.1.5 - thanks for all the work!
Title: Re: UITexture disappears
Post by: Seigman on September 14, 2012, 06:59:09 AM
I have the same issue with UITextures. If I remove the line where mTex is set to null in UIWidget.set_material then this problems goes away...
Title: Re: UITexture disappears
Post by: itszander on September 14, 2012, 08:31:49 AM
Hi all,
I am also have the same problem. I am working with Unity 3.5.5.f3 and nGUI 2.1.6.

I've tried the following

1. downloaded the UItexture.cs referenced in the previous post. This gave me a compile error override error. I tried to fix this but then the UItexture sprites were no longer visible.

2. I reverted to the UITexture that shipped with 2.1.6 but I can't find reference to either mTEX or the Null object specified in the previous post.

This is a big problem because I can't go any further on this UI implementation without my UItexture sprites staying visible.

HELP?!

Thanks.

-zander
Title: Re: UITexture disappears
Post by: ArenMook on September 14, 2012, 08:34:46 AM
That reference is in the UIWidget class, Zander. It's the class UITexture derives from.
Title: Re: UITexture disappears
Post by: itszander on September 14, 2012, 08:52:01 AM
hi,
I should note that I am not a programmer but have one here helping me.

I opened UIwidget.cs and looked for the MTEX = null references listed above. I couldn't find a UIWidget.set_material reference anywhere. Thus,  I don't know what to change.

?

-zander

(thanks!)
Title: Re: UITexture disappears
Post by: itszander on September 14, 2012, 12:13:39 PM
Hi all, I made this change. IS it correct?

   public virtual Material material
   {
      get
      {
         return mMat;
      }
      set
      {
         if (mMat != value)
         {
            if (mMat != null && mPanel != null) mPanel.RemoveWidget(this);

            mPanel = null;
            mMat = value;
             /// mTex = null;

            if (mMat != null) CreatePanel();
         }
      }
   }

   /// <summary>
   /// Returns the texture used to draw this widget.
   /// </summary>
Title: Re: UITexture disappears
Post by: itszander on September 14, 2012, 04:06:17 PM
Update... I fixed this by grabbing the new UItexture.cs script.  I thought I did it before, but apparently did not.
Title: Re: UITexture disappears
Post by: Dover8 on April 03, 2013, 09:33:25 AM
Digging up an old post, but I'm experiencing this too now. Using Unity 3.5.2 and NGUI 2.3.1.

My scenario is that I have created 3D data panels that get populated at run time. (See the attached image for the layout, should be fairly self explanatory). I also have a 2D filter panel for choosing which data is shown on the 3D panels. I think I have narrowed it down to only happening when all the filters are turned off, and therefore the Table has no children, but the issue happens so sparsely and otherwise randomly that it is hard to say for sure. It also only ever happens with the first 3D panel you open at any time (i.e close all open panels, open one it will be broken, open another without closing the broken one and the new one will be fine and you won't get another broken one again until all other panels are closed first).

You can't see this in the image I posted, but data items are added to the table by an empty gameObject with a pair of UILabel children.

What you can see in the inspector image is that even though the textures aren't appearing on the panel, they are set in the inspector. If I go onto the inspector and update the sprite (even to the same one it already has) then it comes back on in the game view.

I have tried to suggestions in this thread, none of which worked.

Inspector view:
(https://dl.dropbox.com/u/9355226/inspector.png)

Working:
(https://dl.dropbox.com/u/9355226/working.png)

Not working:
(https://dl.dropbox.com/u/9355226/notworking.png)
Title: Re: UITexture disappears
Post by: ArenMook on April 03, 2013, 02:48:21 PM
First thing you should do is update to the latest version of both Unity (3.5.7) and NGUI (2.5.1). I never support older versions.