Forum rules - please read before posting.

Pinch Zoom and Panning on Mobiles

1235»

Comments

  • I used the script. The console still does not say anything. I am unable to assign the camera manually at runtime - there is just nothing to choose from in Assets or Scene. The only way I can assign the camera is if I move the prefab of the Menu into the Scene or if I make the NavCamUI a prefab. Then the Console says the camera was Found. The image is still double.

    Regarding calling the menu background - thanks for the tip, i removed the Image child and set the background image in the Panel. I also noticed i set the Panel rect was to stretch to all dimensions (while retaining aspect). I changed that to stretch only vertically and now the image fills the space fully in all resolutions (it is cut from sides depending on the resolutions, but that was the intention).

  • Don't assign the NavCamUI as a prefab - you need to assign the instance of it in the scene.

    I am unable to assign the camera manually at runtime - there is just nothing to choose from in Assets or Scene.

    How are you attempting this? By the small circle in the Inspector? Drag it in from the Hierarchy instead - any screenshots you can share will help clarify the situation.

  • edited May 26

    How are you attempting this? By the small circle in the Inspector? Drag it in from the Hierarchy instead - any screenshots you can share will help clarify the situation.

    Yes, because the Menu is a prefab of its own. So when I open the prefab, it opens in the Hierarchy tab, and I cannot access the Hierarchy of the Scene (to grab and drag the camera). Or is there some trick to have both opened at the same time?

    I can only drag the camera in the menu if I move the menu into the scene. Then the script says it was Found.

  • Yes, because the Menu is a prefab of its own.

    I'm referring to once you're in Play mode and the Menu has been spawned into the scene automatically. That's when I'm suggesting you (temporarily) assign the Camera in the Canvas Inspector.

  • My apologies, I didn't realize I could do that. The NavCamUI does appear in the Menu automatically on Runtime, and the script confirms it was assigned and found in the console. I don't understand why the console was silent yesterday, I did, however, make a few minor changes in the menu and its image in the meantime based on your suggestions (or maybe it just needed a restart?).

    Runtime Menu Inspector:

    Console:

  • With the Camera now assigned, and with the Panel displaying the image, what issues now remain?

  • I forced a maximum aspect ratio in Settings Manager. But when i run the game on a device with larger ratio (even simulated in Editor), the camera doubles itself on the left side (only). So i have a "double vision".

  • If you can PM me a cut-down project zip along with instructions on how to reproduce the issue, I will take a look.

  • Thanks for the PM - though the project was presenting a black screen upon opening. I had to create and assign a new URP renderer in the Graphics settings.

    It's also the case that the issue appears intermittently - but I have a list of suggestions that should help.

    • First, set the MainCamera's Background type to Uninitialised, and check Render border camera? in the Settings Manager's Camera settings panel.
    • Next, try relying on camera stacking for the UI camera. To do this, set the NavCamUI's Render type to Overlay, and then assign it in the MainCamera's Stack array.
    • If you rely on stacking, the Auto Correct UI Dimensions component should be avoided - remove it for the background UI prefab
    • The background UI prefab's Image also likely needs Preserve Aspect to be unchecked to have it fill the screen. Otherwise, it's a case of playing with the Canvas Scaler component - but this is not AC-related
    • With stacking, the Inventory (top bar) UI also needs adjusting - have its RectTransform stretch itself along the top edge, with min/max anchor points of (0,1) and (1,1) respectively.
  • Chris, thank you for the tips. The double image has disappeared, and everything now shows properly.

    The project was presenting a black screen upon opening. I had to create and assign a new URP renderer in the Graphics settings.

    I don't understand how this is possible? I am sure I didn't meddle with anything of the sort. I did, however, move the project between computers. Is it possible that the renderer got corrupted? Or any other idea how did I end up without the URP? I had no issues on my computer, and the game worked when built.

    I did create a new URP Asset 2D (is that the correct choice? The other option was Universal) and assigned it in Project settings/Graphics and /Quality. I followed a YT tutorial, is this correct and all that is needed?

    However, I have another problem now. I had a Brightness option created using the PostProcessing package, and now it stopped working. I googled that URP has its own post processing options, so i assume that's the cause and i should implement that. But i have absolutely no clue how to to that, as i followed a manual before including your input. Discussed here.

    Please can you advise me on what changes I must make now to make it all work again?

  • You'd need to affect the URP Volume component to affect the values inside e.g. Color Adjustments.

    This isn't an AC issue, but you can find some discussion on this on the Unity forums, such as this thread:

    https://forum.unity.com/threads/changing-color-adjustments-in-real-time.1214919/#post-8046893

  • edited May 31

    --- deleted comment (figured it out)

  • edited May 31

    I made it almost work, but the discussion belongs here now.

  • Chris, I found another issue which is, I think, connected with the forced Maximum aspect ratio (which is 2.17). I have a scene that i horizontally quite wide, so the camera on runtime fits the scene vertically, and then you can scroll to the sides. But when i run the game in the larger aspect ratios (21:9, 22:9), i cannot scroll to the extreme left and right sides of the scene. The larger the aspect ratio, the larger portion of the side of the scene becomes unavailable. Any idea how I can solve this, please?

  • Are you constraining the camera with a background sprite, or set values?

    Duplicate the scene, and swap out your custom camera with AC's default Drag camera, and remove all custom scripts/cameras etc that may be a contributing factor. Does it still occur?

  • I am constraining with a background sprite.
    When I swapped the camera for a default Drag one with the same background constraint, it worked properly.

    When using the default Drag camera, I can see that the rectangle representing the camera in the scene view moves "outside" of the background when the aspect ratio is set higher than the set maximum. With the custom camera, the opposite happens, and the rectangle never reaches the edge of the background.

  • When using the default Drag camera, I can see that the rectangle representing the camera in the scene view moves "outside" of the background when the aspect ratio is set higher than the set maximum.

    The Drag camera will move outside, but its the MainCamera to look for - that should remain within the backround's range.

    When I swapped the camera for a default Drag one with the same background constraint, it worked properly.

    With matching orthographic size? Share a link to the custom camera script.

  • Yes, the MainCamera does remain within the background range, and orthographic size has the same values for both main and NavCam and is also set to fit.

    The custom camera script is here.

  • Thanks Chris, it works properly now!

Sign In or Register to comment.

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Welcome to the official forum for Adventure Creator.