- Home /
UI object drawing order is different between Unity Editor and Standalone version
I want to draw the objects in the canvas in the desired order.
I placed Background (Black Image) and CardPlace (transparent image) in the canvas. I add Card objects in CardPlace while the game is running.
The render mode of the canvas is "world space", the sorting layer is set to "UI", and the sorting layer of the Card object is set to a layer above "UI".
Sorting layers are not set for Background and CardPlace.
CardPlace and the Cards in it should always be drawn above the Background image.
When I run the game in the Unity Editor, it draws as I want. But when I build it for mac and run it standalone, a black translucent Background image is drawn on top.
How can I draw UI objects in the canvas as desired? Setting sorting group for CardPlace didn't work.
Thank you.
Answer by tormentoarmagedoom · Oct 04, 2019 at 09:46 PM
Woa Magic the gathering. Are you doing some unofficial game or what :D:D ??
Now, about your problem, Do you have any script doing something in the canvas? What we see in your Editor, is redened during runtime right (when is "play"? is not like that when is "stop".
Once, i had a problem because some scripts was not executing in the same order in editor and in stanalone. (some Start functions where called in diferent order) And get wird things like that.
I recommend you, just to be sure is not this, use the Script Execution Order settings (menu: Edit > Project Settings, then select the Script Execution Order__ category) and define the exact order you need to be sure everything is rendered int he correct way.
Another thing you can chek is the order in layer of all that elements, if they are in diferent layers you will not ahve strange things:
https://unity3d.com/es/learn/tutorials/topics/2d-game-creation/sorting-layers
Good luck!
Thank you for your reply. I'm making an unofficial $$anonymous$$TG game for personal use.
Background Image and Card object already have different sorting layers. Card object has a sorting group. So Card objects should always be displayed above the Background, but when I run standalone, it will appear below. After all, I didn't understand the cause of the problem, but when I changed the order in layer of the Card object from 0 to 1, it was displayed correctly.