I created a unity application for desktop and mobile platforms. There is a map on top-left corner of the screen. I draw circle on this map each frame. The position of the circle changes at runtime anytime.
To do for this task, I draw circle on texture and draw this texture. This code works on emulator but not android phone or tablet. I don't see any circle on the map.
My code is here :
TextAsset imageAsset; // .png changes to .png.bytes. And the file dragged to this variable on inspector.
Start () {
texture.LoadImage(imageAsset.bytes);
}
void OnGUI () {
Circle(texture, x, y, Color.red);
if (Event.current.type.Equals(EventType.Repaint))
{
Graphics.DrawTexture(new Rect(..), texture);
}
}
Some people say deprecated OnGUI
. But if I create a button in OnGUI
, it is displayed at runtime on android.
I tried another solution. I create a 3d plane object on my scene, and drag .png file as texture. But I don't change this texture using Texture2D
variable that is drawed circle.