- Home /
 
 
               Question by 
               watchermagic3 · Aug 08, 2018 at 05:12 PM · 
                c#textinputfield  
              
 
              How to convert text field to input field and back again?
I have a text mesh pro field where text is displayed through code based on scriptable-object assets called "Page"es. I'm trying to make the text field so that when I click it it's converted to a TMPro input field, and when I click away it's converted back to a normal text field with the changes to the string saved to the respective Page. I don't know much at all about c# so I have very little idea where to go, but here's what I've got:
 public class UserInputHandler : MonoBehaviour
 {
     public void PageTextOnFocus()
         {
             TextMeshProUGUI storyText = adventureGame.storyText; //references a serialized field from another script that contains the text component
     
             currentPage.GetPageText();
         }
 }
 [CreateAssetMenu(menuName = "Page")]
 public class Page : ScriptableObject
 {
 
     [SerializeField] [TextArea(10, 25)] string pageText;
     [SerializeField] Page[] nextPages;
 
     public string GetPageText()
     {
         return pageText;
     }
 
     public Page[] GetNextPages()
     {
         return nextPages;
     }
 
 }
 
              
               Comment
              
 
               
              Your answer