Forum rules - please read before posting.

Unity UI Interaction Menu - Strange offset issue

Hi Chris & AC forum

a little problem that's driving me craaaazzzy!

My Unity UI Interaction menu always appears offset... but only the 1st time I click on a hotspot.
This happens every time I launch the game.
Or every time I resize the game window.

Second, third and other clicks with the same window size thereafter always produce the menu in the right place.

My setup:

  • Unity prefab UI
  • Appear at cursor and freeze
  • Scale with screen size (800 x 600)
  • Linked the Canvas and Panel in the Menu manager
  • Force aspect ratio to 1.7778

What didn't work:

  • Menu with and without animations
  • Changing Canvas scaler options
  • Changing aspect ratios
  • Not forcing aspect ratio
  • Different Main Camera setups (adding / removing scripts)
  • Locking / unlocking interaction menu

Any idea why the first hotspots click only fails??


  • By how much is it offsetting? Does it's new position / offset amount depend on which side of the screen you click on? As this is a visual problem, screenshots will help a lot to convey the issue.

    You're setting it to scale with screen size, but with a different aspect ratio (1.33) to your forced aspect ratio. Try setting these to match each other.

    Does this occur in builds only, or the Editor too?

    What are your AC / Unity versions, also? Be sure to test the latest AC if you haven't already, as this may have been fixed in the current release.

  • Thanks Chris,

    I've updated to the last version and changed by resolution to 800 x450 - no luck.

    Here's a GIF of the offending behaviour.

    One think I realised is the offset seems related to the amount of scaling. But why just the first click??

    I'm on MacOS Mojave
    Unity 2018.3.1f1
    AC 1.68

  • Again though, is this in builds as well or just the Editor?

    I suspect this is due to the fact that UI Canvas GameObjects are disabled when their associated Menus are considered "off", while the components themselves needing at least one frame with the root enabled in order to calculate its correct position.

    If you can share screenshots of the Menu's properties, and Canvas's full Inspector, I will attempt a recreation.

  • Sorry, yes forgot to say it's in editor and builds too.
    Here are the screenshots:

  • I can't reproduce such an issue. Are you controlling the UI's position at all through animation? You stated above you tested without, but try removing the Animator completely.

    Otherwise, I'll need to see this for myself - in which case, PM me a .unitypackage of your eight Managers, your Canvas prefab and associated UI assets (graphics/animation), and I'll take a look.

  • Thanks for taking the time to look into it.

    I just tried in a brand new project with a fresh AC install.

    Used all the default managers. I only replaced the Interaction menu with the attached Unity prefab. The problem still persists.

    The menu does appear in the right place on the first click when the UI Canvas is set to Screen Space - Camera, without assigning a camera.

    Unfortunately that seems to cause other issues, so can't use it for my game.

    Unity UI prefab:

  • OK, I'll let you know what I find.

  • The menu does appear in the right place on the first click when the UI Canvas is set to Screen Space - Camera, without assigning a camera.

    But that's the way the prefab is set up, meaning it works for me just fine. What Render Mode must it be set to for the issue to occur?

    If the Render Mode is set to Screen Space - Camera, but no camera is assigned, AC will automatically assign the MainCamera on startup.

  • edited June 20

    Yes, sorry I forgot to change it back before sending the prefab.
    It's with Screen Space - Overlay that the problem arises.

  • Even in that mode I still have no issue.

    I've assigned the prefab as the Interaction's Canvas, and its immediate child as the RectTransform boundary - you did the same?

    I'll need those Managers, and a test scene as well, to be sure we're looking at the same thing.

  • Thanks again Chris,

    here is a Zip file of a new GIF + the Unity Package

  • Received, will update.

  • I can't see any problem with this either, I'm afraid - though the Menu's Position type was set to Manual initially.

    Unless I can recreate the issue, there's not too much I can suggest. There are, however, a couple of changes you can make to AC's Menu.cs script that may help reveal the issue.

    First, try changing line 1135:

    if (RuntimeCanvas.renderMode == RenderMode.ScreenSpaceCamera)


    if (RuntimeCanvas.renderMode == RenderMode.ScreenSpaceCamera || RuntimeCanvas.renderMode == RenderMode.ScreenSpaceOverlay)

    If no change there, find lines 1849/1850:

    EnableUI ();
    SetCentre (new Vector2 (KickStarter.playerInput.GetInvertedMouse ().x, Screen.height + 1f - KickStarter.playerInput.GetInvertedMouse ().y));

    And swap them around. Any change in behaviour?

  • Yessssss!!!! First line fixed it - thanks so much!

    Note: still the same issue when the Panel's rect transform anchors aren't in the centre of the panel, but I can work around that.

    Thanks again!

  • Well, unfortunately that was more of a test than a fix. That'll actually cause issues with other menus, and unless I can recreate the issue myself it's not a change I can make officially.

    Knowing that this addresses the issue, however, does mean a custom script can be used to implement the same change. Something like this should do it:

  • Oh I see - well I've added the custom script to the game engine prefab.

    So far so good, and it even works with the offset rect transform anchors.

    Thanks again for the dedicated support!

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.
Do NOT follow this link or you will be banned from the site!