Search Unity

Question removing specif text

Discussion in 'Code Editors & IDEs' started by mindingou, Dec 15, 2022.

  1. mindingou

    mindingou

    Joined:
    Jan 11, 2022
    Posts:
    2
    hi!, i need some help, i already searched alot for this one, all i could find was, replace, remove, and do it like variable = "", but for some reason when i try to remove a certain text from de text in the ui it just doesnt work, already used a debug an it acctually shows what i mean it to show, and still, nothing.
    texto.desc.text += "\n"+quest.Descrição; <- thats how i put the text that i want in the ui
    texto.desc.text.Replace(quest.Descrição, ""); <- and thats how im trying to take it of.
    please help.
     
  2. mgear

    mgear

    Joined:
    Aug 3, 2010
    Posts:
    9,435
    looks like this line takes the string from text element,
    and replaces that string, but doesn't assign it back to that text element:
    Code (CSharp):
    1. texto.desc.text.Replace(quest.Descrição, "");
    so its like doing
    Code (CSharp):
    1. mystring.Replace("asdf","");
    instead of
    Code (CSharp):
    1. mystring = mystring.Replace("asdf","");
     
  3. mindingou

    mindingou

    Joined:
    Jan 11, 2022
    Posts:
    2
    mgear. man... sometimes i guess im a little too stupid, or distracted, anyway, thanks alot! it worked