-
I have setup a circular scroll in my main menu, The canvas for the main menu is saved as a DontDestroyOnLoad to save menu properties. When I change my scene and change back to the menu while playing the game, I reassign the main camera through script: |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 1 reply
-
Hi, the list stores the referencing camera of the canvas in the initialization. Try this:
public void SetCanvasRefCamera(Camera camera)
{
_canvasRefCamera = camera;
}
public void ReassignCanvasRefCamera()
{
GetComponentReference()
_listPositionCtrl.SetCanvasRefCamera(_canvasRefCamera);
}
|
Beta Was this translation helpful? Give feedback.
Hi, the list stores the referencing camera of the canvas in the initialization.
And the list uses it to calculate the local position by calling
RectTransformUtility.ScreenPointToLocalPointInRectangle()
, which the null reference of the camera parameter is acceptable. That's why there has no error.But it will treat the canvas that it is in the screen space - overlay mode.
Therefore, you also have to reassign the camera into the list.
Try this:
ListPositionCtrl.cs
, removereadonly
keyword from the_canvasRefCamera
.ListPositionCtrl.cs
:C…