using System;
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
public class Test : MonoBehaviour {
Text text;
Button btn;
InputField inout;
string temp;
void Start () {
temp = null;
text = transform.GetChild(0).GetComponent
btn = transform.GetChild(1).GetComponent();
inout = transform.GetChild(2).GetComponent();
btn.onClick.AddListener(Send);
}
string mm;
void Send()
{
string s =inout.text;
List list = new List();
list.Add(“坏人啊”);
list.Add(“傻子”);
for(int i = 0; i < list.Count; i++)
{
for (int j = 0; j< s.Length; j++)
{
temp = temp + s[j];
//print(temp);
for (int z =j+1; z < s.Length; z++)
{
temp = temp+s[z];
print(temp);
if (temp.Equals(list[i]))
{
int y = z - j;
mm= s.Replace(temp,Change(y));
break;
}
}
temp = null;
}
}
text.text = mm;
}
private string Change(int y)
{
string s = null;
for (int i = 0; i <=y; i++)
{
s = s + "*";
}
return s;
}