Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 12 Next capture
2021 2022 2023
1 capture
12 Jun 22 - 12 Jun 22
sparklines
Close Help
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
  • Asset Store
  • Get Unity

UNITY ACCOUNT

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account
  • Blog
  • Forums
  • Answers
  • Evangelists
  • User Groups
  • Beta Program
  • Advisory Panel

Navigation

  • Home
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
    • Blog
    • Forums
    • Answers
    • Evangelists
    • User Groups
    • Beta Program
    • Advisory Panel

Unity account

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account

Language

  • Chinese
  • Spanish
  • Japanese
  • Korean
  • Portuguese
  • Ask a question
  • Spaces
    • Default
    • Help Room
    • META
    • Moderators
    • Topics
    • Questions
    • Users
    • Badges
  • Home /
  • Help Room /
avatar image
1
Question by INKnightStudio · Apr 10, 2017 at 03:34 PM · texttextfield

How do I make my script generate text in an InputField?

I have a code that can generate a code in a Text.UI, but it does not generate that code in texts with InputField.

 public InputField input;
     public Text resultMarkupFormat;
 
     public Toggle bold;
     public Toggle italic;
 
     public Dropdown colorList;
 
     string[] boldFormat = new string[2] { "<b>", "</b>" };
     string[] italicFormat = new string[2] { "<i>", "</i>" };
 
     string[] hexadecimal = new string[31]
     {
     "No Color",
     "<color=#ff0000>Red</color> :#ff0000",
     "<color=#ffe100>Yellow</color> :#ffe100",
     "<color=#ff6600>Orange</color> :#ff6600",
     "<color=#77c2ff>OrangeRed</color> :#77c2ff",
     "<color=#ccff00>Lime</color> :#ccff00",
     "<color=#00ff00>Green</color> :#00ff00",
     "<color=#62ffab>Teal</color> :#62ffab",
     "<color=#00ffff>Cyan</color> :#00ffff",
     "<color=#1e90ff>Dodger Blue</color> :#1e90ff",
     "<color=#0000ff>Blue</color> :#0000ff",
     "<color=#5a00ff>Blue Violet</color> :#5a00ff",
     "<color=#9800ff>Violet</color> :#9800ff",
     "<color=#ff00ff>Pink</color> :#ff00ff",
     "<color=#ff0084>Deep Pink</color> :#ff0084",
     "<color=#ff7777>Light Red</color> :#ff7777",
     "<color=#ffce81>Light Orange</color> :#ff9c70",
     "<color=#ffef81>Light Yellow</color> :#fff070",
     "<color=#ffef81>Light Lime</color> :#e3ff62",
     "<color=#77ff79>Light Green</color> :#77ff79",
     "<color=#81ffb6>Light Teal</color> :#81ffb6",
     "<color=#adfcff>Light Cyan</color> :#adfcff",
     "<color=#87c8ff>Light Dodger Blue</color> :#87c8ff",
     "<color=#77c2ff>Light Blue</color> :#77c2ff",
     "<color=#a087ff>Light BlueViolet</color> :#a087ff",
     "<color=#bd87ff>Light Violet</color> :#bd87ff",
     "<color=#f287ff>Light Pink</color> :#f287ff",
     "<color=#ff78d1>Light Deep Pink</color> :#ff78d1",
     "<color=#FFFFFF>White</color> :#FFFFFF",
     "<color=#969696>Gray</color> :#969696",
     "<color=#000000>Black</color> :#000000",
     };
 
     void Start()
     {
         colorList.ClearOptions();
 
         for (int i = 0; i < hexadecimal.Length; i++)
         {
             string[] hexa = hexadecimal[i].Split(':');
             Dropdown.OptionData data = new Dropdown.OptionData();
             data.text = hexa[0];
             colorList.options.Add(data);
         }
 
     }
 
     void Update()
     {
         resultMarkupFormat.text = VerifyResult();
     }
 
     string VerifyResult()
     {
         string[] markup = new string[2] { "", "" };
 
         if (input.text.Length > 0)
         {
 
             markup[0] = bold.isOn ? boldFormat[0] : "";
             markup[0] += italic.isOn ? italicFormat[0] : "";
             if (colorList.value > 0)
             {
                 string[] hexa = hexadecimal[colorList.value].Split(':');
                 markup[0] += "<color=" + hexa[1] + ">";
             }
 
             markup[1] = bold.isOn ? boldFormat[1] : "";
             markup[1] += italic.isOn ? italicFormat[1] : "";
 
             if (colorList.value > 0)
                 markup[1] += "</color>";
 
         }
 
         return markup[0] + input.text + markup[1];
     }
 }
Comment
Add comment
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users

1 Reply

· Add your reply
  • Sort: 
avatar image
0
Best Answer

Answer by Cuttlas-U · Apr 10, 2017 at 04:52 PM

Hi;

the InputFiled component has a text variable ; try to change the value of that and i think u are good to go ;

         GetComponent<InputField>().text = "your text";
 

alt text


terrain-to-mesh-v143.png (48.5 kB)
Comment
Add comment · Show 1 · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image INKnightStudio · Apr 10, 2017 at 09:47 PM 0
Share

Thank you! This worked :D

Your answer

Hint: You can notify a user about this post by typing @username

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Follow this Question

Answers Answers and Comments

101 People are following this question.

avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image

Related Questions

I'm trying to insert input field text into an arraylist 0 Answers

Working with the GUI 4.6 (textfields and buttons) 1 Answer

TextField does not update in Game 1 Answer

Text Boxes Not Visible 0 Answers

Can't put a text on an Object 0 Answers


Enterprise
Social Q&A

Social
Subscribe on YouTube social-youtube Follow on LinkedIn social-linkedin Follow on Twitter social-twitter Follow on Facebook social-facebook Follow on Instagram social-instagram

Footer

  • Purchase
    • Products
    • Subscription
    • Asset Store
    • Unity Gear
    • Resellers
  • Education
    • Students
    • Educators
    • Certification
    • Learn
    • Center of Excellence
  • Download
    • Unity
    • Beta Program
  • Unity Labs
    • Labs
    • Publications
  • Resources
    • Learn platform
    • Community
    • Documentation
    • Unity QA
    • FAQ
    • Services Status
    • Connect
  • About Unity
    • About Us
    • Blog
    • Events
    • Careers
    • Contact
    • Press
    • Partners
    • Affiliates
    • Security
Copyright © 2020 Unity Technologies
  • Legal
  • Privacy Policy
  • Cookies
  • Do Not Sell My Personal Information
  • Cookies Settings
"Unity", Unity logos, and other Unity trademarks are trademarks or registered trademarks of Unity Technologies or its affiliates in the U.S. and elsewhere (more info here). Other names or brands are trademarks of their respective owners.
  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Spaces
  • Default
  • Help Room
  • META
  • Moderators
  • Explore
  • Topics
  • Questions
  • Users
  • Badges