Is it possible to move a UI Menu through scripts?I've tried several available functions but none of them seem to work. As for an AC menu no problem but I can not do the same thing with an identical menu but with Source = Unity UI. The same functions I use with AC Menu can not be used with UI Menu but after several tests I would like to know if it is possible.
Comments
How a Menu is positioned is dependent upon its Position type field. If it's set to Manual, then it can be controlled through script - however other settings assume AC has control and it is updated accordingly. If you set it to e.g. Follow Cursor, and remove your own scripts, does it correctly move?
Is your "RectTransform" correctly assigned? It should be a direct child of the Canvas that spans the total area of the UI - see the provided default UI prefabs for examples.
The Menu script's SetCentre function can be used to reposition UI menus, but if the Canvas' Render Mode is set to World Space then SetCentre3D must be used instead. Generally speaking, the scripting guide can be used to learn the available functions - here is the Menu script's entry.
It looks to me like the smaller window doesn't give a bigger offset - just the same offset in exact pixels.
Be aware that you're not limited to using AC's SetCentre function. If the Appear type is Manual, you can manipulate the UI's RectTransform components directly through script.
The SetCentre function will centre the RectTransform on a given point - which may differ visually from the rounded square that's visible in your screenshots. To ease debugging, add a grey image or something to the Menu's RectTransform boundary so that we can see more clearly where the boundary and centre of the Menu lies.
I would also suggest writing a Debug statement to output the position of the mouse cursor, so that you can see the co-ordinates any given point on the screen at runtime.
But to summarise, so far as I can tell, the code works when the "hidden" menu's position is Manual, but there's an offset when "On Hotspot". Is that right? If so, at what point are you calling the code? Every frame?