Author Topic: after building the project to android all UIs in Unity got pink  (Read 17102 times)

Spacez

  • Newbie
  • *
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 26
    • View Profile
first, i'm making the project in Unity using NGUI. When i click play and test my project in Unity everything works fine i can see every UI, also everything can do what i want.


Then i try building the project to Android after finished building and install .apk into my android phone
here are the problems

IN ANDROID PHONE
- only some texts and planes are shown, others are all black : planes, NGUI's UIs, etc

IN UNITY PC
- all UIs has gone PINK
- i tried searching some more in this sites and found that i could be something about OpenGL ES 2.0, so i went and check. I found that in my Edit -> Graphics Emulation , i already have checked in OpenGL ES 2.0 (and also in player setting is 2.0 too)

when i tried changing to 1.1 or no OpenGL ES, Unity CRASH .


Conclusion :
- i have problem building project into Android but almost everything has not shown
- every UIs in my Unity's gone pink


Thanks very much for helps :)

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: after building the project to android all UIs in Unity got pink
« Reply #1 on: July 09, 2013, 10:27:15 PM »
What version of Unity? What version of NGUI? What is your UI setup like? Are there clipped panels? You're missing all kinds of key information here that would help narrow down your issue.

Without it all I can say is this: Pink means shader couldn't compile.

Spacez

  • Newbie
  • *
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 26
    • View Profile
Re: after building the project to android all UIs in Unity got pink
« Reply #2 on: July 09, 2013, 11:00:30 PM »
Unity 4.1.2f1
NGUI 2.6.3
My UIs have 2 parts, first is simple sprites + buttons, second is something like scroll view using camera (from example 8 )
« Last Edit: July 10, 2013, 06:07:51 AM by Spacez »

Spacez

  • Newbie
  • *
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 26
    • View Profile
Re: after building the project to android all UIs in Unity got pink
« Reply #3 on: July 10, 2013, 07:06:30 AM »

when i tried changing to 1.1 or no OpenGL ES, Unity CRASH .


solved this case (just this single sentence but not the main TOPIC)

http://www.tasharen.com/forum/index.php?topic=4246.0
http://www.tasharen.com/forum/index.php?topic=3689.0

ps. i just went to check for update and found 4.1.5 but after reading the logs, i have no idea whether this issue got fixed ?
(also i'm thinking about down the version to 4.0 but i'm afraid that Unity has no backwards compatibility, so i'm still using 4.1.2)


btw, the main problem i'm facing is all my UIs turn into a pink box :(

here is a picture


*the blue bg picture that's not turned into pink is what i created from Unity plane
« Last Edit: July 10, 2013, 07:54:17 AM by Spacez »

Spacez

  • Newbie
  • *
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 26
    • View Profile
Re: after building the project to android all UIs in Unity got pink
« Reply #4 on: July 10, 2013, 07:45:58 AM »
update after some more trials

- created texture using NGUI and add the texture from my project into it -> the texture works fine (no pink box)
but creating other stuffs (such as sprite, button) -> pink box

- tried copy the NGUI folder from the project that has this problem and paste into the new project, then created the sprite using fantasy atlas, and it WORKS. Btw, i work this project with my team, so i cant just create the new one for my UIs only :(


thanks for any helps :)




edit: some more pictures
« Last Edit: July 10, 2013, 08:07:30 AM by Spacez »

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: after building the project to android all UIs in Unity got pink
« Reply #5 on: July 10, 2013, 12:50:37 PM »
You can't copy/paste things from one project to another without including metadata, which is by default happens to be hidden. Doing this without the matadata results in broken links, and nothing will work properly.

Graphics emulation should be "off".

Check the atlas you're using -- what material is it using? Go to that material. What shader is it referencing?

My guess is you copied the NGUI folder from one place to another, which broke all the linkage. You need to delete the NGUI folder and import it from a package, then start all over.

Spacez

  • Newbie
  • *
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 26
    • View Profile
Re: after building the project to android all UIs in Unity got pink
« Reply #6 on: July 10, 2013, 01:37:05 PM »
Thank you for the reply

- changed emulation to "off" -> nothing's changed

- Check the atlas' material -> SHADER IS MISSING -> select the unlit/transparent colored -> THE PINK DISAPPEARED !! TEXTURE COMES !!! yahoooo !!

THANKS SO MUCH ArenMook, you're the most dedicated Admin i've ever seen ! :)

ps. about the metadata issue, it's also my new knowledge ! Thanks !


btw, before i'm going to mark this thread as solved, i'd like to ask some more questions (so that i dont need to post new thread)

i'm creating games for mobile and now that my texture is quite LARGE, so i tried changing the inspector of the textures, but when i add THEM to the atlas, they will be changed to 4096, ARGB 32bit (very large size :( ) . Am i doing something wrong ? any suggestoins ?

Thank you very much AGAIN !

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: after building the project to android all UIs in Unity got pink
« Reply #7 on: July 10, 2013, 08:38:00 PM »
Keep in mind that simply fixing the references yourself will result in the same problems happening again when you update NGUI to a future version. You need to restart now by starting a new scene, deleting the NGUI folder, and importing NGUI from a the latest package. That's the only way all links will be correct.

Don't add large textures to an atlas. Use UITexture to draw large textures. It's a good idea to take advantage of 9-slicing, and to split up your large sprites into smaller components you can overlay to create complex looking elements.

Spacez

  • Newbie
  • *
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 26
    • View Profile
Re: after building the project to android all UIs in Unity got pink
« Reply #8 on: July 10, 2013, 11:16:17 PM »
i tried resized the original image to the smaller one (about 1092x614 pixels) and import it into the Unity, BUT, the same problem again after i selected and add it into the atlas the error show that i need smaller size of texture (how small i need ?)

again, i tried change the texture inspector Max Size to 512 and Format to DXT5 (and tried Truecolor also) , THEN after click add to atlas everything's been changed back to 4096 size and ARGB 32bit. (is this the format the texture needed to be to add to the atlas ?)

about using UITexture, i have no idea how to use UITexture as something like button ? (because when i creating button though Widget Tool, it requires textures from atlas ?)



Ps. i remove all of NGUI and re-imported.
Ps2. took a look at 9-slicing from tutorial, also from http://www.adobe.com/designcenter-archive/video_workshop/html/vid0204.html , but i dont get the idea though ;(


Thanks

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: after building the project to android all UIs in Unity got pink
« Reply #9 on: July 11, 2013, 07:12:04 PM »
1092x614 is too big -- no point in adding something that large to an atlas. Draw it using a UITexture instead. The whole point of atlassing is to save texture space, and you do that by splitting up your large textures into small components that you can place together to create a complex image. Changing the "max size" in inspector does nothing as it's flat out ignored when the texture is read. It's only used by Unity itself, not by reading the texture's data.

Now, the part where you ask about a button... do you seriously intend to create a 1092x614 size button? That's going to cover the entire screen for vast majority of the users! If you intend for it to be smaller, then open that image in photoshop and resize it down to what it should be -- then save it like that. Don't import massive textures into Unity.

Spacez

  • Newbie
  • *
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 26
    • View Profile
Re: after building the project to android all UIs in Unity got pink
« Reply #10 on: July 12, 2013, 09:03:24 AM »
Thanks ArenMook, :)

now that i finished things and tried build the project to Android phone, everything works well. But i notice that there is some delays (about 0.5 secs) after press the button before the popup shows. (my button's used for open menu like popup; in the script there is just some 'SetActive' commands)
*NOTE that when i test this in Unity, there is no problem like this (no delay, press the button -> the popup shows)


where should go check ? please suggest me


Thanks in advanced :)


ps. here is the Profiler, captured when i press the button in Unity Play Mode
ps2. the android mobile that's used to test is Galaxy Nexus
update: tried testing it in Nexus 7, same result (random delays after press the button)

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: after building the project to android all UIs in Unity got pink
« Reply #11 on: July 12, 2013, 01:38:14 PM »
What's in the popup? If it's using a UITexture, then Unity has to first load that texture into memory, and the bigger it is, the longer it's going to take.

Spacez

  • Newbie
  • *
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 26
    • View Profile
Re: after building the project to android all UIs in Unity got pink
« Reply #12 on: July 13, 2013, 12:08:55 AM »
how can i know how large the texture should be ?
can i just set the Format in the texture's inspector ? (now it's 'Truecolor')

after son searching i found some suggest the DXT5, is it ok ?


ps. i tried change the setting in the Build Setting (override compress) to DXT, but the problem persist (what is the differences between Compress in Build Setting and in Textures's inspector ?


Thanks :)

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: after building the project to android all UIs in Unity got pink
« Reply #13 on: July 13, 2013, 01:30:51 PM »
Select the texture and you should be able to see its size.

Spacez

  • Newbie
  • *
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 26
    • View Profile
Re: after building the project to android all UIs in Unity got pink
« Reply #14 on: July 13, 2013, 10:32:04 PM »
i meant 2000 is too large ? 1000 is too large ? 500 is too large ?