This may be a bit of an involved request, but I'm looking for direction in a good workflow to set up interactive computer screens in world space. Here's an example of what I've prototyped:
My objective is to have a reusable object the player can interact with, AC runs whatever necessary actions such as camera change, disabling hotspots, etc., and somehow offer me a way to modify what text the player will see on each specific computer terminal.
I'm not sure on how I can efficiently set up this workflow in as few manual edits as possible, making as many of the steps as prefabs or action list assets, and I'm also having issues with getting the custom AC menu buttons to perform any actions.
Each computer terminal ideally would have buttons that change depending on what screen the player's on, for example the player could be reading an NPC's emails, or navigating a text-adventure.
I've also set up a dedicated "back" button that will run it's own action asset that will switch the camera back and anything else, but again, I'm having issues making it work and I'm not sure what I'm doing wrong.
So far in my prototype, I have a scene hotspot that switches the camera, disables the hotspot, and enables the custom Unity UI prefab menu which is set to pause the game while enabled. I have a custom UI Menu linked up to the world-space Canvas with some "label" fields, and 6 pre-defined buttons. I was thinking at first maybe I'd just modify the label fields and enable/disable buttons as needed for each computer screen gets displayed, but I'm wondering if I should be making something custom here, or if there's a better workflow within AC.
Any thoughts on how I should approach this idea?
It looks like you're new here. If you want to get involved, click one of these buttons!
Comments
On further experimenting, I realize some things aren't linking from the menu because I didn't have "use tmpro components" ticked. I'm also noticing that the references to the buttons in my custom menu are breaking once I start running the game. I have the custom AC menu buttons linked to the buttons within the UI canvas prefab. Any idea how I can both place the ui canvas prefab into world space while still referencing the buttons from within the menu?
I expect this'd be best done with an Animator attached to the UI's root that controls various Canvas Group components to show/hide different tabs, coupled with the use of an Object: Animate Action run from a Button's "ActionList on click" asset.
First, though, best to get the Menu working properly when turning on and off.
You can remove the need to disable the Hotspot by assigning your regular gameplay camera in the Hotspot's Limit to camera field. When you then switch to the terminal camera, the Hotspot will automatically become non-interactive.
Is this to say that clicking them doesn't run the assigned ActionList?
What are your AC/Unity versions? The Buttons should re-link themselves when the scene opens, by referring to the Constant ID values. Check for any relevant messages appear in the Unity Console.
AC version 1.81.7, Unity version 2022.3.4f1
This is an interesting idea. I was originally planning something along the lines of having 6 permanently placed buttons in the ui prefab, and then upon interaction with the computer, using some mixture of ActionLists and parameters to update the ui label's on the screen, button labels, and button actions accordingly. On second thought, I also use the PixelCrushers dialogue system, so that might be useful here, but I'll address the button issues first.
This was a great idea, thank you. I alse ended up making two custom AC menu's, one for the terminal ui called "Terminal", and one for a 'back' button called "TerminalBack", and on the Terminal menu, I created an ActionList asset to turn on/off the 'TerminalBack' menu accordingly. That button works well.
Yes. I went back through and made sure to reassign all of the ui prefab's components to the custom AC menu correctly. I made sure the AC menu's constant ID's match the correct components in the prefab as well. I believe this made some progress because now the references are remaining linked between editor mode and play mode. However, clicking the buttons still does not run the assigned actions, nor are any logs printing to the console. I even set the custom button action as an "actionlist - comment" and nothing prints. I also feel its worth mentioning the buttons are being highlighted and animating when clicked.
Is the Button's Text updated to match the label you assign in the Menu Manager, and is the UI Canvas enabled at the time the scene begins? That'll be necessary for it to "find" the elements within it?
I can't recreate the issue otherwise - can you share screenshots of the Canvas / Buttons involved, as well as the Menu / Elements in the Menu Manager?
Okay I think I have narrowed down how to duplicate the issue.
It seems that it has to do with the ui prefab being in the scene prior to entering play mode.
I remade my custom ui prefab from scratch, then linked each element into the AC custom menu. It didn't matter between TMpro or legacy.
Found the buttons worked correctly if the prefab's canvas render mode was set to screen-space overlay without a prefab placed into the scene, but the reference links get confusing when the render mode is in world space.
After some troubleshooting, I realized that AC was creating a duplicate prefab at the world origin, so the prefab I placed into the world space manually was not getting linked up as I expected. If I hit the button at the prefab that gets created at world origin works correctly, but the one i placed manually does not react to anything.
https://imgur.com/1fWXquH
The "Unity UI Prefab" option will cause this - AC will assume that the UI is a prefab to be spawned in at runtime.
If the UI is already in the scene, which is often necessary for "World Space" menus, use "Unity UI In Scene" instead. AC won't duplicate the UI, but instead rely on the one already present.