I have now converted all the AC menus in my game to Unity UI and they all work fine, except for one.
One of the menus is the game's HUD, which is to be displayed at the top of the screen. When it is set to work as an
AC menu, it works fine. But when I link it to a UI prefab, the menu displays properly, but prevents all the other interactions in my game from working (hotspots aren't visible, movable objects can't be moved...).
The menu is set to appear "During gameplay". The only difference is retrieving the menu's content from AC or as a Unity prefab. I also tried with or without linking the Unity UI Canvas RectTransform boundary in the menu panel, but it makes no difference.
Perhaps I'm missing some some setting related to Unity UI?
By the way, what does the "GUI depth" parameter at the top of the AC Global menu settings stand for? It's not described in the user manual.
Comments
You'll have to elaborate a bit more on the actual problem. By "hotspots aren't visible", you mean the Hotspot label menu doesn't show?
It sounds like your HUD Canvas is spanning the whole game window, and is causing it to block mouse clicks elsewhere. Check to see if it's the case. You can also attach a Canvas Group component to the root and uncheck "Interactable".
Not sure how to solve this, as with the canvas set to render "Screenspace - camera", using the First person camera as the render camera, it doesn't seem possible to change the canvas size. I can only do this if I set it to render in "World space".
Using a Canvas Group is not the solution, as it doesn't change anything to my problem. Furthermore, I don't want the HUD canvas to prevent interactions, as I have load & save buttons on it.
I know this is starting to be more of a Unity than AC issue, but as this is linking AC's menus to Unity UI, it's difficult to distinguish. Do you know of any good resources that explain these topics (the only reason I have been using AC & Playmaker, despite being able to code in C#, is that I didn't want to spend too much time learning all about the Unity concepts and architecture)? I don't find Unity's documentation very detailed and their video tutorials take too long to use as a reference.
I may well be mistaken, but the size of the root Canvas itself is not important - just the size of the RectTransform children it houses. Other than Unity's own tutorials on the matter, I can't think what else to suggest. It's indeed a Unity issue, though - AC just handles its enabled state and what happens when the components are clicked on.
I created an AC menu to replicate the UI elements in this canvas and linked this to the prefab. It worked fine also. However, if I then change the canvas render mode to "Screen space - camera", the problem occurs again (no objects being interactive in the game).
Following this, I deleted the AC menu (therefore removing any canvas-AC menu link, but leaving the canvas active in the game) and now the problem doesn't occur anymore (despite the canvas being active and its UI elements visible).
I just created a new game and am able to reproduce this behaviour:
- Create an empty scene with an object and a hotspot over it.
- Now create a canvas with "Worldspace" render mode, add a text element, link it to an AC menu displayed during gameplay (always active) and avoid the canvas overlapping the part of the screen with the hotspot. All works fine (the hotspot shows and can be clicked, the text shown on the screen is the one linked to in the AC menu element)
- If you now change the canvas render mode to "Screenspace - camera", using the same first person camera as with worldspace, the hotspot doesn't react anymore (yet the UI elements in the canvas have their Rect Transform component set in order to not overlap the hotspot in the scene)
As the problem doesn't occur with the canvas active without being linked to an AC menu, I'm thinking it is an issue with AC. Could you possibly check?
I can't recreate any issue. You've set your Canvas's Plane Distance to a high value?
Whether it's due to AC or not, there should still be some difference in the Canvas hierarchy between when it works and when it doesn't. See if you can find some key setting or value that's different.
Failing that, you can PM me a .unitypackage file of a test scene, Menu Manager asset, and Canvas prefab.
After sending you the file and following the advice in your feedback, it now works properly.
I did have another frame object with a TransformRect below my Unity UI canvas object and it is this object, not the canvas, that had to be linked to the RectTransform boundary field in the AC menu.
I hadn't really had an issue with all the other menus, as these either represented menus or dialogue boxes in my game. The HUD of course, being permanently displayed, did cause an issue.
Thanks again for your great support.