Is there any way to specify a cursor in code and ignore the element itself? I.e, I have a container of elements. Suppose each element is an asset. So, when I'm dragging an asset to that container, I want the cursor to change, depending on if you can add the asset or not (based on its type). Tried a lot of things, couldn't figure out how to do it reliably. Bare in mind that when I'm hovering over the elements, each element overrides the cursor, while I want it to stay the same if I'm dragging an asset over the container. Any thoughts would be appreciated. Some documentation or perhaps an easier way to change cursors and also utilize the different presets that Unity Editor would be super useful for something like this. It's weird if I can't find a way to change the cursor easily...
Try something like this: Code (CSharp): currentVisualElement.style.cursor = new UnityEngine.UIElements.Cursor() { defaultCursorId = (int)MouseCursor.FPS }; currentVisualElement.style.cursor = new UnityEngine.UIElements.Cursor() { defaultCursorId = (int)MouseCursor.Text };
For runtime, I've managed to change cursor only via code: Code (CSharp): var cursor = new UnityEngine.UIElements.Cursor(); cursor.texture = Resources.Load<Texture2D>($"UI/Cursors/mt-pipette-24"); cursor.hotspot = new Vector2(0, cursor.texture.height); _palette.style.cursor = new StyleCursor(cursor);