Ejemplo n.º 1
0
        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);
        }
        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();
            }
        }