0
点赞
收藏
分享

微信扫一扫

探索未来:Java在人工智能领域的崛起

王传学 2023-07-15 阅读 35
android
using System.Collections;
using System.Collections.Generic;
using System.Text.RegularExpressions;
using UnityEngine;
using UnityEngine.UI;

public class NewBehaviourScript : MonoBehaviour
{
    // Start is called before the first frame update
    void Start()
    {
        GameObject.Find("com_btn").GetComponent<Button>().onClick.AddListener(() => {

            string str = GameObject.Find("com_inp").GetComponent<InputField>().text;

            if (str.Length <= 0)
            {
                str = "输入为空";
            }

            GameObject.Find("com_txt").GetComponent<Text>().text = str;

        });

        GameObject.Find("com_btn2").GetComponent<Button>().onClick.AddListener(() => {

            string str = GameObject.Find("com_inp").GetComponent<InputField>().text;
            str = FilterEmoji(str);
            if (str.Length <= 0)
            {
                str = "输入为空";
            }

            GameObject.Find("com_txt2").GetComponent<Text>().text = str;

        });
    }

    List<string> patten = new List<string>() { @"\p{Cs}", @"\p{Co}", @"\p{Cn}", @"[\u2702-\u27B0]" };

    private string FilterEmoji(string str)
    {
        for (int i = 0; i < patten.Count; i++)
        {
            str = Regex.Replace(str, patten[i], "");//屏蔽emoji   
        }
        return str;
    }
}

unity场景

 

举报

相关推荐

0 条评论