I am making a simple badword filter for my game! The badwords = string[] (that means that i can put all the bad words, that should be blocked, in strings[] in unity one by one.(picture one)
The problem is that i want many badwords to be blocked and it would probably take too much time to put all the badwords in strings[] one by one.
Solution: Is it possible to somehow put all the bad words in a script? So that i for example can copy&paste them from a badword list?
What I've tried: I've tried to make the string[] to a normal string and then string = "badwords" then i got an error that said that the string can't be converted to an char or something like that (picture 4)
I am thankful for any help! :D
Edit: That is the new code, i'm not really sure how to make this to the string[] badwors? I now noticed that in the second picture, there is no [] for the "String badwords", but usually there is a [] after the string(String[] badwords;)
public static void FormatBadWords()
{
string pattern = "[,]+";
string input = "bad, toobad, crazy";
string[] result = Regex.Split(input, pattern,
RegexOptions.IgnoreCase,
TimeSpan.FromMilliseconds(500));
for (int ctr = 0; ctr < result.Length; ctr++)
{
Console.Write("'{0}'", result[ctr]);
if (ctr < result.Length - 1)
Console.Write(", ");
}
Console.WriteLine();
}