zoukankan      html  css  js  c++  java
  • 用于切割字符串的方法

    using UnityEngine;
    using System.Collections;
    using UnityEngine.UI;
    using System.Collections.Generic;

    public class ReadEditorInfo : MonoBehaviour
    {  //传值对象为字符串
      string ContentInfo;//存储输入的文本内容
      string[] con;//将输入的文本信息存储到数组中
      private GameObject[] ReadInfo;//存储分割后字符串的数组
      //显示信息的Text
      public List<GameObject> textInfoShow = new List<GameObject>();

      public void ReadInfoFunc(string conten, char split)

      {    //方法1:用于字符串的传值
        this.ContentInfo = conten;
        //";" 切割字符串的标志
        string[] ReadInfo = ContentInfo.Split(new char[] { split });

        for (int i = 0; i < textInfoShow.Count; i++)
        {
          int j = i;
          textInfoShow[j].GetComponent<Text>().text = ReadInfo[j];
          if (textInfoShow[j].GetComponent<Text>().text == "")
          {
            textInfoShow[j].GetComponent<Text>().text = "获取信息失败";
          }
        }
      }
      public void ReadInfoFunc(string[] conten)
      {  //方法2:传值对象为字符串数组
        this.con = conten;
        for (int i = 0; i < textInfoShow.Count; i++)
        {
          textInfoShow[i].GetComponent<Text>().text = con[i];
          if (textInfoShow[i].GetComponent<Text>().text == "")
          {
            textInfoShow[i].GetComponent<Text>().text = "获取信息失败";
          }
        }
      }
    }

  • 相关阅读:
    python logging模块
    python re模块
    python xml模块
    python json,pickle,shelve模块
    python os,sys模块
    python 临时添加环境变量
    python random模块
    python time模块
    python 装饰器的简单使用
    python学习之路(二)
  • 原文地址:https://www.cnblogs.com/Cocomo/p/5714157.html
Copyright © 2011-2022 走看看