How do I simulate a click of a canvas in unity?

Viewed 17

I have a canvas in world space and a point that I want to virtually click on the canvas. How do I click at said point?

using UnityEngine;

[RequireComponent(typeof(Canvas))]
public class canvasClicker : MonoBehaviour
{
    private Canvas canvas;
    // Start is called before the first frame update
    void Start()
    {
        canvas = GetComponent<Canvas>();
    }

    // Update is called once per frame
    void Update()
    {
        Vector2 locationOnCanvas = Vector2.zero; // replaced with some (x, y) on the canvas
        
        // canvas.clickAt(x, y) type method
    }
}
0 Answers
Related