Unity3D C#检测违规词组

using UnityEngine;
using System.Collections;
using System.IO;

public class Test : MonoBehaviour
{
    public string a = "";

    private string b;
    // Use this for initialization
    void Start()
    {
        FileStream fs = new FileStream(Application.dataPath + "/a.txt", FileMode.Open, FileAccess.Read);
        StreamReader sr = new StreamReader(fs);
        b = sr.ReadToEnd();
        fs.Close();
        sr.Close();
        if (b.Contains(a))
        {
            Debug.Log("包含");
        }
    }

    // Update is called once per frame
    void FixedUpdate()
    {
        if (a!=""&&b.Contains(a))
        {
            Debug.Log("包含");
        }
    }

    void OnGUI()
    {
        a = GUI.TextField(new Rect(0, 0, 100, 20), a);
    }


}
这个功能的BUG太明显了,下次再修改。


你可能感兴趣的:(String,C#,unity3d)