Hello.
We have a different behavior for IOS-build, which is build using Unity Cloud Build:
Scenario #1
Have 2 cameras:
one for gameobject’s, second for UI. Canvas Render mode: Screen space - Camera
No UI-elements is showen when run it on device
Scenario #2
Have 1 camera, and Canvas Renderer mode is Screen Space - Overlay.
All works fine on device.
In editor all scenarios work fine.
Have anyone got ideas?
Additionally in scenario #1 if I click on place where controls position expected I get normal response…
Did you ever figure this out? I’m having the same issue.
Having similar issue as well, our standalone build does not show our 2nd camera UI, everything works perfectly well in Editor.
We did some more testing.
Here is a component we use to force assignation of camera at runtime. Indeed screen space camera set in the scene is sometimes overridden by unity for no apparent reason.
Let’s call our scene where the screen space camera canvas is SceneCanvas and OtherScene any other scene that is loaded previously.
Now this works in the following scenarios :
1.A Editor with scene SceneCanvas directly : UI appears
1.B Editor with OtherScene that loads SceneCanvas directly : UI appears
2.A Standalone with scene SceneCanvas directly : UI appears
2.B Standalone with OtherScene that loads SceneCanvas directly : DOES NOT WORK
It’s very tricky to debug and fix. Do anyone know any related issue ?
In all those cases the logging is the one expected :
Canvas.worldCamera assigned to <Main UI Camera> in <UI_Board>
public class AssignCameraToCanvas : BaseMonoBehaviour, IHasOnEnable
{
[Tooltip("Assign camera to canvas, default camera is UI camera")]
[SerializeField]
private Camera _toAssign = null;
private Canvas _canvas;
public override void Awake ()
{
base.Awake();
_canvas = GetComponent<Canvas>();
_canvas.worldCamera = _toAssign.OrElse(GetMainCamera);
Debug.Log($"Camera to assign <{_toAssign.DoIfNotNull(t => t.name).OrElse(() => "ASSIGN_NOT_SET")}> in <{name}>");
}
private static Camera GetMainCamera()
{
return Camera.allCameras.FirstOrDefault(c => c.CompareTag(EGameObjectTag.MainCamera.ToString()));
}
public void OnEnable()
{
_canvas.worldCamera.DoIfNull(() => _canvas.worldCamera = _toAssign.OrElse(GetMainCamera));
Debug.Log($"Camera to assign <{_toAssign.DoIfNotNull(t => t.name).OrElse(() => "ASSIGN_NOT_SET")}> in <{name}>");
if (_canvas.worldCamera != _toAssign && _toAssign.IsNotNull())
{
_canvas.worldCamera = _toAssign;
Debug.Log($"Camera to assign <{_toAssign.DoIfNotNull(t => t.name).OrElse(() => "ASSIGN_NOT_SET")}> in <{name}>");
}
Debug.Log($"Canvas.worldCamera assigned to <{_canvas.worldCamera.DoIfNotNull(t => t.name)}> in <{name}>");
}
}
Check the depth of the cameras. Also read about depth of camera in unity help.