Forum rules - please read before posting.

Cursor UI How to?

So I would like the interactions available from a hotspot to animate out form behind the main centred cursor when over hotspot, with a little lie text above left and live text above right and both correspond to left and right click. All three cursors (Main and left and right) would also loop through a spritesheet anim also. I know it is all about Cursor UI Unity, but I could indeed use a bit of help to get started please!

See pick of how i envision it.

https://www.dropbox.com/s/qg6u4s3kxftx9ky/Cursor Interface Idea.jpg?dl=0

Thanks!

Comments

  • Your Interaction method is "Context Sensitive", I take it?

    Starting from the default CursorUI prefab, attach an Animator that has a Bool parameter named HasLookIcon, and an Integer parameter named UseIconID.

    Then use this code to set these two parameters' values based on the Hotspot the cursor is currently over:

    public Animator _animator;
    public string useIconIDParameter = "UseIconID";
    public string hasLookIconParameter = "HasLookIcon";
    
    private void Update ()
    {
        bool hasLookIcon = false;
        int useIconID = -1;
    
        if (AC.KickStarter.stateHandler.IsInGameplay ())
        {
            AC.Hotspot hotspot = AC.KickStarter.playerInteraction.GetActiveHotspot ();
            if (hotspot)
            {
                hasLookIcon = hotspot.HasContextLook ();
                if (hotspot.HasContextUse ())
                {
                    useIconID = hotspot.GetFirstUseButton ().iconID;
                }
            }
        }
    
        _animator.SetInteger (useIconIDParameter, useIconID);
        _animator.SetBool (hasLookIconParameter, hasLookIcon);
    }
    

    Check that the parameter values in the Animator are changing correctly, and then use them to transition to the relevant Animations.

  • edited April 2022

    So I attach this script to the cursor? So will this set off an animation when hovering over a hotspot? And how will the cursor know to animate out the correct interactions?

    How do I connect the other hosposts into my CursorUI? Do I put raw images in seperately with scripts on? These will need to be animated.

    Does it connect to my original cursors in the cursor manager?

    If you could help with setting up my CursorUI for starters, and then explain how the above script fits in that would be excellent.

    Please see images here detailing how I would like the cursor to work:

    https://www.dropbox.com/s/qg6u4s3kxftx9ky/Cursor Interface Idea.jpg?dl=0

    Thanks Chris!

  • Attach an Animator to your CursorUI in the way I described above. The script will affect two parameters defined in that Animator: a Bool named "HasLookIcon", and an Integer named "UseIconID".

    The script will set "HasLookIcon" to True when hovering over a Hotspot with an "Examine" interaction defined, and will set "UseIconID" to the ID of the Hotspot's "Use" interaction, or -1 if there is no Hotspot.

    How you make use of these parameters is down to your intent, but at this point it's a case of using Unity's animation tools.

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.