Forum rules - please read before posting.

Manual Update Request: Unity UI Cursor

edited September 2021 in Engine development

Hello,

I have so many questions regarding the Unity UI cursor settings but the manual doesn't provide much insight.

Could we get a more comprehensive overview / guide how to use the Unity UI cursor?

My first question would be how are the 'main cursor settings' relevant in this case? If you're using a prefab, I assume the cursor texture is setup in the prefab. Is that the idea? If so what does 'replace mouse cursor' / texture option do?

Comments

  • edited October 2021

    I'll update the Manual, certainly.

    If you assign the Inspector's "Raw Image To Control" field, then that'll use the textures assigned in the Cursor Manager and behave as it would normally with the Software rendering option.

    Otherwise, the cursor's appearance is determed internally, which could be through use of animation - as the Unity UI cursor allows for animator parameters to be set based on the current cursor state.

    It's important to note, though, that AC doesn't require that the provided Unity UI Cursor script to actually be used. It can be adapted/replaced to suit your exact needs.

  • edited October 2021

    I find a step by step example setup or walkthrough goes a long way to getting started with something. I'm still having a lot of trouble with this / not understanding how things should be setup.

    For insight, this is how I've understood and approached things so far:

    Step 1) I've set the cursor rendering to Unity UI, using the default prefab

    Step 2) I've gone into the prefab and set a texture for the raw image

    Step 3) I've made sure the 'Raw Image To Control' is assigned

    Step 4) When a menu appears however, only the system cursor appears. There's no sign of the prefab graphic I've setup.

  • edited October 2021

    If you assign the "Raw Image To Control", then AC will update its Image field automatically using the textures assigned in the Cursor Manager. Any texture you assign in the component manually will be overridden at runtime.

    Since you've opted to not show a main cursor, the UI cursor will rely on the assigned "Empty Texture".

    If you want to rely on a single texture, you can keep it assigned in the Raw Image (or even just use an Image component + sprite), and unset the "Raw Image To Control" field in the Inspector.

    This is separate to the "RectTransform To Position" field, which separately controls where the cursor graphic is drawn.

  • edited October 2021

    All this info is gold. Super valuable.

    The UI Cursor is showing, but is always visible outside of menus, even though 'hide cursor when locked in screen's centre' is true

    Is that a bug?

  • If you've opted to have AC set the cursor's graphic, then yes. I'll look into this.

    Also to note: this cursor should only be used in conjunction with Unity UI menus. Adventure Creator menus will always be rendered above this cursor type, since they rely on Unity's OnGUI system - which is always the last thing to be drawn in any given frame.

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.