Unity buttons sometimes black out in Android - android

I recently started developing in Unity and I like it a lot so far, but there is this one bug, I can't tell where it comes from and similar reports of others I read didn't help me.
The problem is that buttons sometimes (almost always by now, not so often in earlier versions of my project) are straight up black and have very dark grey text in them, which is completely different from how they are supposed to look like.
Even if I put all buttons of the color to straight white, this happens - only in Android btw! (Not tested in iOS, but it's neither happening in the editor, nor in desktop builds.
As I said, this seems to happen more often, now that the game got bigger, has more buttons etc. - so I would guess that is has something to do with setting the Source Image of those buttons to UISprite. Also this does not happen to buttons that have an actual image as Source Image, not the default UISprite.
So this is an example of how it is supposed to look like
And this is how it actually looks like:
Has someone got an idea? I assume it is something about loading the UISprite.

According to your comment, the correct answer was what I thought (see my comment).
Too big textures are hardly supported by Android devices, because of the heavy memory consumption. Scaling down all textures should solve the problem. You can also simply add a lower scale of the texture and switch it before rendering if the device is a mobile. Add a script to your buttons and insert this :
public Image loweredSprite;
public Button button;
void Start() {
#if UNITY_ANDROID
button.image.overrideSprite(loweredSprite);
#endif
}

Related

Wear OS watchface with complications ambient colour

I'm designing my first watch face (just for me) I've been through the "Adding Complications to your Wear OS Watch Face" codelab (https://developer.android.com/codelabs/complications#0) and I would like to make the complications a darker grey (in the sample they show as white) when in ambient mode. An added complication (the normal kind, not the watch face kind) is that it seems to work in the android emulator, but not on my physical device (Ticwatch C2+, I don't have another to test it with).
I've been through everywhere I can look and the sensible place seems to be in custom_complication_styles.xml which I have edited as below:
<ambient
app:backgroundColor="#android:color/black"
app:borderRadius="50dp"
app:borderStyle="solid"
app:borderWidth="1dp"
app:highlightColor="#color/gray"
app:iconColor="#color/gray"
app:rangedValuePrimaryColor="#color/gray"
app:titleColor="#color/gray"
app:textColor="#color/gray"
app:borderColor="#android:color/transparent"
app:rangedValueSecondaryColor="#android:color/transparent"/>
The colours come from the colours.xml in the sample project, which (sensibly) includes gray. Just to make sure it isn't just my eyes not seeing the colours properly, I've tried something really obvious, like blue, and it still shows as white.
Adding the border information seems to work (initially in the sample there were no borders), but it doesn't seem to matter what I change the colours to, they are always white. I have tried this with an unedited copy of the sample with the same outcome.
I can change the colour of other elements of the watchface in ambient mode, just not the complications.
Hopefully, it is something really obvious and easy to someone out there, but documentation/tutorials seem a bit thin on the ground for wear os development. Thanks in advance to whoever can help!
TofferJ's comment was the answer I was looking for, disabling low bit ambient on the watch means the complications now use the colour set in the styles xml. Thanks!

Android 4.4.2 webview + targetSdkVersion=19 issues

I'm working on an update for an app (implementing immersive mode) but I'm having issues with the webview as soon as I change the targetSdkVersion in the androidmanifest file.
At first it only rendered the background color. It did load the resources because I could see that happening in the debug console but it just didn't show anything. So I googled a bit and found an answer that stated I should disable hardware accelaration like this:
webView.setLayerType(View.LAYER_TYPE_SOFTWARE, null);
Now it does show content but really tiny, as if the webview was zoomed out to 25% or something like that. Also it shows some sort of grid..?
I've attached two screenshots (taken with my phone which is actually too small for the layout but I didn't have my tablet around). The first is with targetSdkVersion=18 (and looks like it should), the second is targetSdkVersion=19 and is broken.
help?
Thanks,

How to fix PNG image banding on Android Browser (Mobile Website)?

For a mobile website project I encountered a problem that (only on android browser), the gradient to transparency (smooth outer glow) does not look clean. Instead you can see clear edges around it. Strangely though it seems to disappear for as long as I scroll the page.
http://i.stack.imgur.com/qGmXj.png
The problem does not occur on any Desktop Browser or on iOS Devices.
Thanks for your help!
UPDATE:
I found out, that the problem is called PNG Banding and only occurs with PNG-24 (24 bit) on the 16bit displays. As I cannot go with an 8-Bit Image (which would render fine) because of the quality loss, I still did not find a solution for the problem
I have also not found a solution to this problem.
In my case, I had a PNG with a white-to-transparent gradient that I would overlay on top of elements with solid background colours to give them a "shine" up top. No matter what I tried, there would always be banding on the Android browser (and no other browsers at all).
Before I even tried the PNG gradient, I tried doing so with CSS3, but that suffered from the same issue.
In the end, I was forced to create opaque PNGs with the white-to-transparent gradient layer merged with the colour layer. This meant I had to do the Photoshop equivalent of "hard-coding" each possible shine/shadow with whatever colour it would be on top of. Not the best solution, but it displays fine on Android browser without any banding and I needed do something, so yeah. :|
In photoshop, Save For Web. Choose PNG-8 bit. Dither Option: choose pattern or noise. This will smooth out the gradient banding.

Android Text Display - Canvas.drawText() output pixelated

My Android app displays text in a few different ways, and there are some annoying differences between them I was hoping folks could help with.
When I use display methods that might be termed "automatic," the text is displayed very nicely. By automatic methods, I'm referring tools, like Toasts and Button widgets where I just have supply the text, and the OS (or "environment" or whatever) displays it for me. The letters are nicely curved, pleasant to look at, and easily legible.
However, in my code where I handle the text display (using Canvas.drawText() in a Surface Runner View), the text quality is poor. The text is still legible, but it looks pixelated. The letters just don't look their best.
I've tried experimenting with Paint.setTypeface(), using Typeface.SANS_SERIF for example, but the quality of the display when it's my code is always poor. Doable, but poor.
Has anybody else experienced this? By any chance does anybody have a solution?
You might also try playing around with Paint.setAntiAlias(boolean) or Paint.setSubpixelText(boolean).

Problem in Android Game using AndEngine

Hey all,
I am having an unusual problem with my Game. I am loading six textures in my Game, the initial one is a type of Game Background. Now at click of a Sprite i load a Dialog with infalted XML. The problem occurs here, when it first loads my game Background becomes black, when it reloads again it returns to it's original, when it reloads again it's black and it continues like this. It's a big code and that's why i cannot post it here, may be any one of you help me in this. I am stuck since many days in this, I have not unloaded any Texture, but still it's looking like that...............
Hope to get some help from you all..................
Thanks............
Try copying your game to another project and keep removing stuff to narrow down the problem until you don't have the problem anymore. I'd start with removing textures.
How many textures of what size do you have?
This is my raw guess.
you could have kept the Dialog's inflated xml root layer's(linearlayout) height and width as fill_parent. This could have occupied the entire screen and let things black.
make it as wrap_content to both.
1024x600 Textures are impossible! Both dimensions have to be a power of two, AndEngine does not accept other dimensions as many (all?) devices would not allow this.
Sorry but my time is currently very limited (due to exams =( ).
kkkkk SO it's a very delayed answer but still, may be it may help others. I exactly don't know what the problem was but after removing a texture, making size of some other's small, and also when android got updated, the problem is now very delayed, or it rarely comes.
So as per what i can think there seems only two issues, some memory prob or some bug in android which resolved with new update.

Categories

Resources