antsonthetree
Topic Author
Posts: 44
Joined: 09 Jan 2018, 15:56

Unity Mouse Cursors

14 Mar 2018, 14:14

Hello,

I am trying to change the mouse cursor in Unity using this code:
Cursor = Cursors.ScrollAll;

It works fine in Blend, but it does not seem to have any effect in Unity.
Is this supported or is this a defect?

Thanks
Jake
 
User avatar
sfernandez
Site Admin
Posts: 2984
Joined: 22 Dec 2011, 19:20

Re: Unity Mouse Cursors

14 Mar 2018, 19:10

Each FrameworkElement exposes a Cursor property that can be set to specify one of the available cursors in Cursor enum.

We provide a callback method that will be called everytime a control demands to change the cursor. In the callback you can use Unity API to set the cursor using your cursor textures:
Noesis.GUI.SetUpdateCursorCallback((cursor) =>
{
  UnityEngine.CursorMode cursorMode = CursorMode.Auto;
  UnityEngine.Vector2 hotSpot = Vector2.zero;
  switch (cursor)
  {
    case Noesis.Cursor.Arrow:
      UnityEngine.Cursor.SetCursor(cursorArrowTexture, hotSpot, cursorMode);
      break;
    case Noesis.Cursor.Hand:
      UnityEngine.Cursor.SetCursor(cursorHandTexture, hotSpot, cursorMode);
      break;
    ...
  }
});
 
User avatar
jsantos
Site Admin
Posts: 3906
Joined: 20 Jan 2012, 17:18
Contact:

Re: Unity Mouse Cursors

14 Mar 2018, 19:19

I don't know if we should offer a better integration for this. Like having a list of textures in NoesisSettings that we automatically use. That way our users don't need to add extra code for this part.

Who is online

Users browsing this forum: No registered users and 91 guests