Hello.
Yesterday I changed from the old input system to the new one. In my game scene, everything works great, and I’m very happy.
But, it’s broken my Character Creation Screen.
I used to have two different types of Pointer/Mouse handlers for tooltips.
One for event Data (on UI elements)
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.EventSystems;
public class OnHoverMakeActiveUI : MonoBehaviour, IPointerEnterHandler, IPointerExitHandler
{
[SerializeField]
public GameObject _gameObjectToMakeActive;
public void OnPointerEnter(PointerEventData eventData)
{
_gameObjectToMakeActive.SetActive(true);
}
public void OnPointerExit(PointerEventData eventData)
{
_gameObjectToMakeActive.SetActive(false);
}
}
And one that used OnMouseEnter() (on things like sprites with a capsule Collider)
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.EventSystems;
using UnityEngine.InputSystem;
public class OnHoverMakeActive : MonoBehaviour
{
[SerializeField]
public GameObject _gameObjectToMakeActive;
public void OnMouseEnter()
{
_gameObjectToMakeActive.SetActive(true);
}
public void OnMouseExit()
{
_gameObjectToMakeActive.SetActive(false);
}
}
I ported across to the new Input system, and bam, the second one didn’t work. After investigating, I found out this is a common issue, and OnMouseOver doesn’t work with the new Input system.
Never fear, I thought. I still have my other script I was using for UI elements, so I’ll just do that.
The suggestion Ive seen is to:
- make sure you have a 2D raycaster on your camera. I do
- make sure you have a InputSystemUIInputModule on your Event System. I do
- Collider on your GameObject (I do)
- I already had a lot of these things set up because I had these two types of Hover scripts.
Anyway. Long story short, it isn’t working. Anyone know how I can get this functionality to work?
I know I could just convert my sprite to an image, or add a button, and the other script will work, but for a number of reasons, those two options weren’t very attractive.