$begingroup$

Im create TextMeshPro from “Create -> 3D Object ->Text – TextMeshPro”
How to obtain mouse button click on occasion for TextMeshPro?
I attempted by way of Physics.Raycast/Collider however it would not work. It’s not “Create -> UI ->Text – TextMeshPro” although.
I additionally tried so as to add GraphicRaycaster part to TextMeshPro as for UI ingredient, however it would not work.I didn’t perceive the place to create EventSystem. I simply added it as a part to TextMeshPro.
Also tried so as to add Button Component to TextMeshPro.

public class Math : MonoBehaviour
{
    // Start known as earlier than the primary body replace
    GraphicRaycaster m_Raycaster;
    PointerEventInformation m_PointerEventInformation;
    void Start()
    {
        m_Raycaster = GameObject.Find("Solution").GetComponent<TextMeshPro>().GetComponent<GraphicRaycaster>();
        m_EventSystem = GameObject.Find("Solution").GetComponent<TextMeshPro>().GetComponent<EventSystem>();
        Solution = GameObject.Find("Solution").GetComponent<TextMeshPro>();
    }
    void Update()
    {
        if (Input.GetMouseButtonDown(0))
        {
            m_PointerEventInformation = new PointerEventInformation(null);
            m_PointerEventInformation.place = Input.mousePosition;
            List<RaycastEnd result> outcomes = new List<RaycastEnd result>();
            m_Raycaster.Raycast(m_PointerEventInformation, outcomes);
            foreach (RaycastEnd result end in outcomes) //Results - null
            {
                Debug.Log("Hit " + consequence.recreationObject.identify); //not enter
            }
            Ray ray = GetComponent<Camera>().ScreenPointToRay(Input.mousePosition);
            RaycastHit hit;
            if (Physics.Raycast(ray, out hit))
            {
                if (hit.collider.recreationObject.identify == "Solution")
                {
                    Debug.Log("Hit " + hit.collider.recreationObject.identify); //not enter
                }
            }
        }
        
    }
}

fredwriter is a brand new contributor to this web site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.

$endgroup$

You should log in to reply this query.