Forum rules - please read before posting.

Menu Question - Hide/show element & Cursor Question

Hi. I hope everyone is having a great weekend. I have a question regarding menus and show/hide elements.

Firstly, how can I hide the previously selected menu elements when I reopen the tab? The information seems to remain there.

Example: I open a menu, select an objective or document (information like status, description, texture populates the fields). I switch to a different menu that shares many of the same fields, and that information is still there (from the previous item) until I select another document/objective. Here's a video showing this issue occurring.

https://drive.google.com/file/d/1islTKeNexTWOhOJXsYOVCr2QhBDLlyIe/view?usp=sharing

I'm sure it's something stupid and obvious that I'm missing, as usual. I've tried hiding the elements individually when the menu is off, when the menu is closed, but when I open the menu back up, it's back.

Secondly, I've been trying to get the cursor and all of the icons (when selected) to be affected by the post-processing filter I added, but I can't seem to do that. Currently, I have a CursorUI Prefab with "Screen Space - Camera" set, the render camera is set, and the plane/layer are set. That prefab is linked to "Unity UI Cursor Prefab," and cursor rendering is set to "Unity UI."
Have I missed something? All the cursor elements still don't appear to be affected by the post-processing filter.

Thank you!

Comments

  • Firstly, how can I hide the previously selected menu elements when I reopen the tab? The information seems to remain there.

    In the case of Objectives and Documents: AC records the "active" ones independently of when/how they might be displayed. To remove their display, you'll need to manually de-select them via the DeselectObjective and CloseDocument functions respectively.

    Here's a function you can copy into a C# script to handle this:

    public void DeselectObjectivesAndDocuments ()
    {
        AC.KickStarter.runtimeObjectives.DeselectObjective ();
        AC.KickStarter.runtimeDocuments.CloseDocument ();
    }
    

    To run this, attach to a prefab and then reference that prefab with the Object: Call event Action (see this tutorial for an example).

    Secondly, I've been trying to get the cursor and all of the icons (when selected) to be affected by the post-processing filter I added, but I can't seem to do that.

    AC won't be directly involved here, beyond the necessary use of the UI-based cursor. Screen Space Camera is the way to go - is it on a layer affected by the post-processing?

  • Yes, The Prefab is on the Screen Space Camera layer, which should be affected by the post processing. I use the same technique for the menu. Here's an image

    https://drive.google.com/file/d/1HLi_MOiUbhgehax0DaqOaH4ErFw3rATW/view?usp=sharing <- I added a screenshot of two separate prefabs with the same settings. You can see the Cursor Selection in the Character Menu - unaffected by the post-processing.

    Also, thank you for the script.

  • It's a case of no "Render Camera" assigned in the component, which isn't possible in the prefab as the MainCamera is part of the scene.

    You just need a script that assigns this at runtime:

    using UnityEngine;
    public class AssignCameraToCanvas : MonoBehaviour
    {
        void Start ()
        {
            GetComponent<Canvas> ().worldCamera = Camera.main;
        }
    }
    
  • edited April 8

    Thank you again. I'll look into that in a little bit. Sorry to pile more on top, but I've noticed that Objective States Descriptions don't update in the Description field when the State is changed. I added custom descriptions for each State of an Objective, but it seems to display the main top description instead of all of the Objective States Descriptions. I found this thread with a script from you. Should I just use this to fix this issue or am I doing something wrong/failing to update something properly in ActionList? Thank you https://www.adventurecreator.org/forum/discussion/10089/objectives-label-visible-after-completion

  • Please try to create separate threads when posting unrelated issues in future - it helps others to find them when they encounter similar questions.

    Does the Label element that shows the wrong text have its Objective text property set to Description or State Description? If the latter, does the issue only occur if the state is changed while the Menu is opened (i.e. closing/re-opening the Menu causes it to correct itself)?

    It'll be best to see screenshots of your setup.

  • Please ignore this last one pertaining to State Description and I'll add a new thread once I finish with these.

    The script for the Cursor worked - the cursor is now affected by the post processing effect, but there seems to be a new issue that I'm not sure how to fix.

    The Cursor graphic appears to move off center from the actual mouse the further you pan left or right, up or down. And it seems to occur whenever I enable the script. Here's a screenshot of what I mean.

    https://drive.google.com/file/d/1xB5zT6ZU4Q3-A8px03p8RsT0ROfK34Cl/view?usp=sharing

    I'm looking into methods for capturing both cursors in video. For some reason it doesn't want to capture both.

  • If you're rendering the Canvas in Screen Space, it will have a physical presence in the scene. It could be that the offset is caused by the "Plane Distance" field, but the Unity UI Cursor should account for this, and I can't reproduce such an issue.

    Can you share your CursorUI's root Inspector?

  • What is your Unity version, and what does the Canvas Scaler component look like?

    Do either the Plane Distance or Resize Canvas fields have an effect?

  • Hi. Sorry for the late Reply. My Unity version iss 2022.3.9f1 and here's the cursor set-up https://drive.google.com/file/d/18h04wttDt-H_cRwSf0gxy7r60IY6jD6v/view?usp=sharing. Thank you again.

  • Is your Game window's aspect ratio fixed at 1.778, and is there any difference in the position issue (ignoring scale changes) by tinkering with either the UI Scale Mode or Screen Match Mode fields?

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.