how to access a text gameobjceet in unity and change it

Code Example - how to access a text gameobjceet in unity and change it

                
                        Text text = gameObj.GetComponentInChildren(typeof(Text)) as Text;
text.text = "text stuff";
text.font = prefferedFont;
                    
                
 

get text component unity

                        
                                GameObject.GetComponent<Text>().text = "Hello World!";
                            
                        
 

get text unity

                        
                                numericalScore.GetComponent<UnityEngine.UI.Text>().text = "Score : " + scoreManager.score;