As in title, I want to remove the whole word in the input field, if one character is removed.
Do you have help?
Thanks in advance
Hey,
simply add a script to your input field wich keeps track of the current string in your field.
Then you add the following function to your Input field in the “OnValueChanged” section.
public void StringGotChanged(string newstring){
if(!newstring.Contains(oldstring))
{
//something got deleted
// split the strings by Spaces and then iterate over all the words. -> compare them from oldstring to newstring.
//after comparing you can reconstruct the whole string and reset it in the inputfield text
}
else
{
oldstring = newstring;
}
}
When you change the value of the InputField is changed this function is called and the new string is passed along. Now you can compare the new string with the old one. If the new string still contains the old value then it only get longer and nothing was deleted. When this does by some chance not work try comparing the lengths of the strings. This should also work.
Don’t forget to initialize your “oldstring” value in the Start-function.