The mouse has entered the pop-up UI

External calls show and Hide Methods

using DG.Tweening;
using UnityEngine;
using UnityEngine.UI;

public class ShowInfo : MonoBehaviour {

    private bool _isshowing = false;
    public Canvas Canvas;

    // Use this for initialization
    void Start()
    {
        Hide();
    }

    // Update is called once per frame
    void Update()
    {

    }
    public void Hide()
    {
        transform.DOScale(Vector3.zero, 0.3f);
        _isshowing = false;
    }

    public void Show()
    {
        transform.DOScale(Vector3.one, 0.3f);
        _isshowing = true;
    }
    void FixedUpdate()
    {
        if (_isshowing)
        {
            Vector2 localPoint = Input.mousePosition - new Vector3(Screen.width * 0.5f, Screen.height * 0.5f);
            Vector3 pos = (localPoint / Canvas.transform.localScale.x);
            pos.x += 10f;
            transform.DOLocalMove(pos, 0.01f);
        }
    }
}


Guess you like

Origin blog.csdn.net/degyss/article/details/91413085