/// <summary>
        /// 读Txt转化成string
        /// </summary>
        /// <param name="txt"></param>
        /// <param name="isRemoveLine"></param>
        /// <returns></returns>
        public static string ReadTxt(TextAsset txt, U_String.En_RemoveLine removeMode = U_String.En_RemoveLine.去掉空行)
        {
            string allStr;

            allStr = txt.text;
            allStr = U_String.StrRemoveLine(allStr, removeMode);
            return(allStr);
        }
        public static List <List <string> > TxtToStrListList(string allStr, int typeCount, En_ListSplitType splitType = En_ListSplitType.根据类别分, string splitStr = U_String.TextSplitString, U_String.En_Trim enTrim = U_String.En_Trim.去掉前后空格)
        {
            List <List <string> > strListList = new List <List <string> >();

            string[] strS = U_String.SplitString(allStr, splitStr, enTrim);
            if (splitType == En_ListSplitType.根据类别分)
            {
                strListList = StrSTo_Type_List(typeCount, strS);
            }
            else if (splitType == En_ListSplitType.根究组别分)
            {
                strListList = StrSTo_Group_List(typeCount, strS);
            }
            return(strListList);
        }
Example #3
0
 void Judeorder(string mark)
 {
     GetMoveTransAndNameList(mark);
     if (orderList.Count != 0)
     {
         orderList.Clear();
     }
     foreach (string str in moveNames)
     {
         orderList.Add(U_String.LastStringToInt(str, 2));
         if (U_String.LastStringToInt(str, 2) > step)
         {
             step = U_String.LastStringToInt(str, 2);
         }
     }
 }
Example #4
0
        void GetMoveTransAndNameList(string mark)
        {
            U_List.ClearList(children, moveTrans);
            U_List.ClearList(childrenNames, moveNames);
            GetChildren();
            GetChildrenName();

            foreach (Transform trans in children)
            {
                if (U_String.JudeLastContain(trans.name, mark, 5))
                {
                    moveTrans.Add(trans);
                    moveNames.Add(trans.name);
                }
            }
        }
        /// <summary>
        /// 检测是两个列表里,是否有前半部分名字一样,但加了后缀的物体。最后一个参数是对下标需要控制时所用。
        /// </summary>
        /// <param name="trans01"></param>
        /// <param name="trans02"></param>
        /// <param name="mark"></param>
        /// <param name="isFirst"></param>
        /// <param name="lastTwoNumber">下标</param>
        /// <returns></returns>
        public static List <Transform> GetAddedStrTrans
            (List <Transform> trans01, List <Transform> trans02, string mark, int lastDigit, bool isFirst, int lastTwoNumber = 999)
        {
            List <Transform> trans     = new List <Transform>();
            List <string>    listStr01 = GetTranssName(trans01);
            List <string>    listStr02 = GetTranssName(trans02);

            //这么写是为了少执行一些if
            if (lastTwoNumber == 999)
            {
                for (int i = 0; i < listStr01.Count; i++)
                {
                    if (string.Compare(listStr01[i], listStr02[i]) < 0 && U_String.JudeLastContain(listStr02[i], mark, lastDigit))
                    {
                        if (isFirst)
                        {
                            trans.Add(trans01[i]);
                        }
                        else
                        {
                            trans.Add(trans02[i]);
                        }
                    }
                }
            }
            else
            {
                for (int i = 0; i < listStr01.Count; i++)
                {
                    if (string.Compare(listStr01[i], listStr02[i]) < 0 &&
                        listStr02[i].Contains(mark + U_String.IntToString(lastTwoNumber)))
                    {
                        if (isFirst)
                        {
                            trans.Add(trans01[i]);
                        }
                        else
                        {
                            trans.Add(trans02[i]);
                        }
                    }
                }
            }
            return(trans);
        }
        // 查看子物体中谁带了某个字符串
        public static List <Transform> GetChildrenWithString(Transform tran, string content, int length)
        {
            List <Transform> children     = GetChildren(tran);
            List <string>    childrenName = new List <string>();
            List <Transform> withStrList  = new List <Transform>();

            for (int i = 0; i < childrenName.Count; i++)
            {
                childrenName.Add(children[i].name);
            }
            for (int i = 0; i < childrenName.Count; i++)
            {
                if (U_String.JudeLastContain(childrenName[i], content, length))
                {
                    withStrList.Add(children[i]);
                }
            }
            return(withStrList);
        }
        public static int Get括号内的Index(Transform tran)
        {
            string str = tran.name;

            str = str.Remove(str.Length - 1, 1);
            string[] strS = str.Split('(');
            str = strS[strS.Length - 1];
            int index = 0;

            if (U_String.Is数字(str))
            {
                index = int.Parse(str);
            }
            else
            {
                Debug.LogError("不符合末尾英文括号+数字的命名规则");
            }
            return(index);
        }
        public virtual void UITextUpdate(int index)
        {
            if (nameText != null)
            {
                nameText.text = names[index];
            }

            if (introducionText != null)
            {
                if (isIntroductionIndent)
                {
                    string introducion = U_String.UGUI_Text_Indent(introductions[index]);
                    introducionText.text = introducion;
                }
                else
                {
                    introducionText.text = introductions[index];
                }
            }
        }
        public void ImportBySuffix()
        {
            foreach (string suffix in siffixS)
            {

                if (matS != null)
                { matS.Clear(); }
                if (textureS != null)
                { textureS.Clear(); }
                Object[] selection = Selection.GetFiltered(typeof(Material), SelectionMode.Editable | SelectionMode.TopLevel);
                if (selection.Length == 0) return;
                foreach (Material mat in selection)
                {
                    if (mat.mainTexture != null)
                    {
                        matS.Add(mat);

                        string matName;
                        if (mat.name.Contains("_"))
                        {
                            string[] strS = U_String.SplitString(mat.name, "_");
                            string last_Name = "_" + strS[strS.Length - 1];
                            matName = mat.name.Replace(last_Name, "");
                        }
                        else
                        {
                            matName = mat.name;
                        }
                        textureS.Add(path + "/" + matName + suffix + form);
                    }
                    else
                    {
                        matS.Add(null);
                        textureS.Add("0");
                    }
                }
                for (int i = 0; i < matS.Count; i++)
                {
                    if (!textureS[i].Equals("0"))
                    {
                        TextureImporter texture = (TextureImporter)AssetImporter.GetAtPath("Assets/Resources" + "/" + textureS[i]);
                        if (texture != null)
                        {
                            texture.textureType = TextureImporterType.NormalMap;
                            AssetDatabase.ImportAsset("Assets/Resources" + "/" + textureS[i]);
                            string picName = textureS[i].Replace(".jpg", "");
                            Texture temp = Resources.Load(picName) as Texture;
                            matS[i].SetTexture(textureType.ToString(), temp);
                            matS[i].SetTexture(textureType.ToString(), temp);
                            matS[i].SetFloat("_Metallic", matalicValue);
                            matS[i].SetFloat("_Glossiness", smoothnessValue);
                            try
                            {
                                matS[i].SetFloat("_BumpScale", normalValue);
                            }
                            catch
                            {
                                Debug.Log("没有法线贴图");
                            }
                        }
                    }
                }
                AssetDatabase.Refresh();
            }
        }