Question by 
               cgraf1 · Oct 09, 2017 at 07:08 PM · 
                texttransform.positiongameobjects  
              
 
              Moving a Text object in script
Hello everyone, In my current project, I have 3 Text Objects. After a certain condition, I want to move one of them to a new position. This should be very simple, but for some reason, after this condition and I try to move the Text Object, it winds up going to an extremely random position that is out of the scene view.
 using System.Collections;
 using System.Collections.Generic;
 using UnityEngine;
 using UnityEngine.UI;
 
 public class AssignManagerScript : MonoBehaviour {
 
     public Text assign_text_1;
     public Text assign_text_2;
     public Text assign_text_3;
 
     
 
     // Use this for initialization
     void Awake () {
 
         assign_text_2.enabled = false;
         assign_text_3.enabled = false;
         
         
     }
     
     // Update is called once per frame
     void Update () {
             
             if(ManagerScript.total_attacks > 10){
 
                 Vector3 pos = assign_text_1.transform.position;
                 pos.x = -282;
                 assign_text_1.transform.position = pos;
             }
                 
     }
 }
 
               Can anyone tell me what I am doing wrong? Thanks very much in advance.
               Comment
              
 
               
               
               Best Answer 
              
 
              Answer by FortisVenaliter · Oct 09, 2017 at 08:14 PM
Text objects don't use the standard transform, they use a RectTransform. Try getting that and modifying it instead of the root transform object for better results.
Thanks very much! I was able to get what I need with this in the if statement:
 RectTransform assign_text_1RT = assign_text_1.GetComponent<RectTransform>();
 assign_text_1RT.anchoredPosition = new Vector3(-288f, -494.5f, 0f);
   
                 Your answer