0

I am having some problems with canvases and UI elements in Unity 2d.

I am trying to use a single scene, with multiple "screens" that will always be active and I just move the camera location to the correct place to view them. For example, the main camera would be at position 0,0,-10 - I would then use transform.position to move it to 0,300,-10.

The UI elements and canvas work correctly in the cameras starting location. However once I use transform.position to move the camera to the new location the UI elements in that area wont work (they will not interact at all).

The UI elements are on separate canvases (rather than having one huge canvas to keep things simple). Both canvases are in Render Mode: World Space. Both canvases and buttons are set up identically (they are copied from the working one).

Any ideas please?

Seconday Camera Location

Initial Camera location

Code that moves camera location. z-10 is to keep the z axis the same as its default start location after the move

Canvas settings. Both canvas objects have identical settings

Two areas with a cavas on each

user2779315
  • 49
  • 1
  • 1
  • 8
  • Canvas Rect Transform is at (0, 0, 0), but what about its parent? Is it positioned correctly? – Phillip Zoghbi May 25 '23 at 23:49
  • Main Screen: (0,0,0) > Canvas (0,0,0) Planet Screen (0,300,0) > Canvas (0,0,0) So unless im missing something, the correct Camera transform should be (0,300,-10) - which is what its at once the script shown in the screenshot is run. To add to that - The camera definitely is looking at the right place, I have objects there that show up correctly. I can see the buttons, its just not possible to interact with them. Thanks – user2779315 May 28 '23 at 09:35
  • UPDATE: After some testing I have determined that multiple canvases is not the issue. If I create a single large canvas the issue still remains. Therefore I think it might be something to do with how the camera.transform is done? – user2779315 May 28 '23 at 09:57

0 Answers0