In my game, I have an "observation" mode that is toggled by pressing a key or an icon in the UI. When in this mode, I want the cursor to turn into an eye and when it passes over an "observable" object, I want the cursor to change to an highlighted version of the eye.

I change the cursor over an object using "scene object" components but I don't know how to change the default cursor at runtime from my standard arrow to an "eye" and then turn it back to an arrow when the player opts out of the observation mode. I've tried:
CursorChange c = new CursorChange();
ORK.CursorSettings.defaultCursor = c;

...but I wasn't able to set the texture of the CursorChange type to a Texture2D from Unity. What should I do?

Should I set the cursor using Unity's standard methods instead? Is there a better way to proceed in order for ORK to manage my cursor states in the case I want to add a new state that doesn't exist?
  • edited July 2020
    That's because the texture in a CursorChange isn't a texture, it's a AssetSource selection.

    If you're using a reference asset source (which is the default in a newly created instance), you can set it like this:
    ORK.CursorSettings.defaultCursor.settings.EditorAsset = texture;
    Post edited by gamingislove on
    Please consider rating/reviewing my products on the Asset Store (hopefully positively), as that helps tremendously with getting found.
    If you're enjoying my products, updates and support, please consider supporting me on patreon.com!
  • Thanks! However, to make that work, you need:
    ORK.CursorSettings.defaultCursor.texture.settings.EditorAsset = texture

    .texture was missing!
  • Ah, yeah, that's correct - just wrote that down from memory :)
    Please consider rating/reviewing my products on the Asset Store (hopefully positively), as that helps tremendously with getting found.
    If you're enjoying my products, updates and support, please consider supporting me on patreon.com!
  • Since beta 2.30.0, the behavior of ORK.CursorSettings.defaultCursor.texture.settings.EditorAsset = texture has changed. In order to update it, I need to add ORK.CursorSettings.ShowCursor(CursorType.Default); It might be related to the change with scene objects where, in 2.30.0, ORK now checks every frame...

    Anyway, I was able to make it work, but I thought you would like to know...
  • Hm, strange - that should only cause changes when the object below the cursor is changed while the cursor is over it, e.g. variable conditions enabling/disabling a scene object info.
    Please consider rating/reviewing my products on the Asset Store (hopefully positively), as that helps tremendously with getting found.
    If you're enjoying my products, updates and support, please consider supporting me on patreon.com!
  • Well then, it might be something else.

    Let's recap the situation: I want to implement an "examine" mode where, when the player presses Left Shift, the cursor turns from an arrow to an eye. If the player releases the Left Shift, then the cursor returns to the arrow. If, when in "examine" mode (eye cursor), the cursor hovers over an "examinable" item, the cursor texture should turn to an highlighted state as long as the cursor is over the item. It indicates that the player can now press the left mouse button to have info on the object.

    If I don't add the ShowCursor() line and only use ORK.CursorSettings.defaultCursor.texture.settings.EditorAsset = texture, what happens is that when I press the shift key while the cursor is NOT over an examinable item, it doesn't turn into the eye. If I keep the shift key pressed and move the cursor (that is an arrow but should be an eye) over an examinable object, then it correctly turns into an highlighted eye cursor. Then, when I place my cursor away from the horse, it correctly turns into the non-highlighted eye. However, when I release the shift key, it doesn't turn back to the arrow texture.

    All of this is solved when I add the ShowCursor() line. However, before I upgraded, it wasn't needed.

    Hope it helps!
  • edited July 2020
    Well, setting the setting's asset alone doesn't change the cursor, it'll only be used next time the cursor is changed to it. So, if the cursor needs to be changed immediately, you need to use ShowCursor anyway :)
    Post edited by gamingislove on
    Please consider rating/reviewing my products on the Asset Store (hopefully positively), as that helps tremendously with getting found.
    If you're enjoying my products, updates and support, please consider supporting me on patreon.com!
  • Ok. That's fine! I just wanted to make sure it was not a bug.
Sign In or Register to comment.