- Home /
gameobjects are pink in apk built on linux
Hello,
I am using Unity 2020.2 on linux and I try to export an APK but all my GameObjects are pink in the APK. In the editor, everything is fine. I have reduced my problem to the simple example below, with a sphere and no colour. I am associating this script to the main camera. The sphere is gray in the editor and pink in the APK.
If instead I add a sphere in the scene through the editor, still with no materials, and build the APK, then the sphere is correctly rendered in the APK.
I have tried this on two recent Android phones and an older Samsung tablet, and the results are identical.
I see only two solutions:
1) either something is missing in my script (but it can't be the colors, since it works without colors when I add the sphere through the interface with no materials);
2) or there is some problem with the linux version of Unity; I can't test Unity on Windows at the moment.
Can someone else confirm this behaviour on linux?
Thanks
using UnityEngine;
public class Example : MonoBehaviour
{
void Start()
{
GameObject sphere = GameObject.CreatePrimitive(PrimitiveType.Sphere);
}
void Update()
{
}
}
I believe that the problem is linked with the default material setting. When an object is created in the editor, it gets some default material and shader, and this default should be reproduced in the script. I have tried to add a new $$anonymous$$aterial within the script, with the standard shader, and linked it to the sphere, but it doesn't help. The sphere is still pink (in the APK only) when it is entirely scripted, and fine (APK and editor) when it is first created through the editor.
I have finally solved the problem, at least for the moment. I have created several material assets which I have put in the Resources folder. Then, I loaded the material with mat1 = ($$anonymous$$aterial)Resources.Load("$$anonymous$$at1"); and assigned them to the objects. It works in the APK! But still, I assume that there is a way to create the materials without going through Assets.
Your answer
![](https://koobas.hobune.stream/wayback/20220613023905im_/https://answers.unity.com/themes/thub/images/avi.jpg)
Follow this Question
Related Questions
Objects Not Rendering On Android 1 Answer
Create a mesh and color cubes 2 Answers
Material doesn't have a color property '_Color' 2 Answers
rgb value detail 0 Answers