Author Topic: WP8 Material and Shader problem  (Read 6194 times)

elvess

  • Newbie
  • *
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 44
    • View Profile
WP8 Material and Shader problem
« on: August 22, 2013, 08:47:32 AM »
I already wrote a topic but now I found a reason.  http://www.tasharen.com/forum/index.php?topic=5477.0

This happens because there is no Material on the UITexture. Why can it happens? I start a scene - there is a material, than change a scene and turn back - no material, than again - there is material.
I think the issue is in UITexture, not in Unity.
Somewhere in shader or material method of UITexture. As it cant find a material and set defaulf shader to Unlit/Texture, but as there is no material texture is no visible.

Aren Mook, can U help me deal with it?
I bought NGUI and have the latest version?
(In attachment - ScreenShot1 - is right windows, ScreenShot2 - is what need to be fixed, Some textures have Unlit/Texture shader. some are invisible)
« Last Edit: August 22, 2013, 09:19:10 AM by elvess »

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: WP8 Material and Shader problem
« Reply #1 on: August 22, 2013, 10:03:05 AM »
Here's a question for you.. why are you using UITextures here? Why aren't you using sprites? Looking at what you have I don't see any good reason not to use sprites.

elvess

  • Newbie
  • *
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 44
    • View Profile
Re: WP8 Material and Shader problem
« Reply #2 on: August 22, 2013, 10:08:38 AM »
We decided to use UITextures instead of UISprites because of Localization system that was wrote before we integrated NGUI. Core of project was ready and it was to long to rewrite all classes that deals with localization.

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: WP8 Material and Shader problem
« Reply #3 on: August 22, 2013, 10:10:07 AM »
NGUI comes with a localization system that's also fully capable of localizing sprites.

UITextures cause extra draw calls for each one, so you are killing your own performance in addition to causing all kinds of Z-based issues.

elvess

  • Newbie
  • *
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 44
    • View Profile
Re: WP8 Material and Shader problem
« Reply #4 on: August 22, 2013, 10:12:46 AM »
I know it. In next project we are using Sprites. But what to do with my issue?

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: WP8 Material and Shader problem
« Reply #5 on: August 22, 2013, 10:17:15 AM »
Simple fix? Create and assign a material. Don't rely on it to create a material. Why it happens on WP8? I don't know what's different about it. Maybe a bug in Unity.

elvess

  • Newbie
  • *
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 44
    • View Profile
Re: WP8 Material and Shader problem
« Reply #6 on: August 22, 2013, 10:21:34 AM »
Materials are created and assigned. There is no dynamically assigned materials. Only textures are set when clicking the button. When I try to debug invisible textures its return that material is null.
If we will change UITextures to UISprites U suppose it will work? Is it worth to do?

elvess

  • Newbie
  • *
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 44
    • View Profile
Re: WP8 Material and Shader problem
« Reply #7 on: August 22, 2013, 10:22:27 AM »
I wrote to Unity about it. If they will tell something worth of attention Ill let U know.

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: WP8 Material and Shader problem
« Reply #8 on: August 22, 2013, 10:23:23 AM »
With sprites there is no need to change the material, ever. So yes, it will work.

elvess

  • Newbie
  • *
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 44
    • View Profile
Re: WP8 Material and Shader problem
« Reply #9 on: August 22, 2013, 10:24:04 AM »
Ill try. Thank U.

elvess

  • Newbie
  • *
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 44
    • View Profile
Re: WP8 Material and Shader problem
« Reply #10 on: August 22, 2013, 10:33:04 AM »
I made UISprite and atlas. It became invisible. There is nothing except  UISprite script on an object.

elvess

  • Newbie
  • *
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 44
    • View Profile
Re: WP8 Material and Shader problem
« Reply #11 on: August 22, 2013, 10:36:58 AM »
Atlas uses one material for all sprites and it shows in debug as null.

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: WP8 Material and Shader problem
« Reply #12 on: August 22, 2013, 11:03:39 AM »
Did you check the FAQ about depth vs Z? Did you adjust your widget so that it's in front?

elvess

  • Newbie
  • *
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 44
    • View Profile
Re: WP8 Material and Shader problem
« Reply #13 on: August 23, 2013, 03:26:03 AM »
Yes. There is everything ok with Z depth. It becomes invisible when I turn it on second time. First time its ok

elvess

  • Newbie
  • *
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 44
    • View Profile
Re: WP8 Material and Shader problem
« Reply #14 on: August 23, 2013, 06:13:14 AM »
Id like to add that Sprite becomes invisible because its material is null. How its possible for material to be not null, and after changing the scene - null.