コード例 #1
0
        ///////////////////////////////////////////////////////////////////////////////////////////////////////
        /// <summary>
        /// SaveAllGenericDecalMeshesDoDisk
        /// # Save all generic decal meshes to disk
        /// </summary>
        ///////////////////////////////////////////////////////////////////////////////////////////////////////
        void SaveAllGenericDecalMeshesDoDisk()
        {
            string savingPath = BasicDefines.MAIN_PATH + "Saved/GenericDecalMeshes/";

            Directory.CreateDirectory(savingPath);

            List <Object> actualMeshesInSavingFolderList = EditorBasicFunctions.GetObjectListFromDirectory(savingPath, ".asset");


            string savingBaseName = "GenericMeshDecal_savedMesh_";

            int lastDetectedIndex = 1;

            for (int i = 0; i < actualMeshesInSavingFolderList.Count; i++)
            {
                string actualName        = actualMeshesInSavingFolderList[i].name;
                string actualIndexString = "";

                for (int j = actualName.Length - 1; j >= 0; j--)
                {
                    string actualSubString = actualName.Substring(j, 1);

                    if (actualSubString == "_")
                    {
                        break;
                    }
                    else
                    {
                        actualIndexString = actualSubString + actualIndexString;
                    }
                }

                if (actualName.Length > 0)
                {
                    //Debug.Log ("actualIndexString: " + actualIndexString);

                    int actualIndex = -1;

                    int.TryParse(actualIndexString, out actualIndex);

                    if (actualIndex > lastDetectedIndex)
                    {
                        lastDetectedIndex = actualIndex;
                    }
                }
            }

            //Debug.Log ("lastDetectedIndex: " + lastDetectedIndex);

            foreach (GenericMeshDecal decal in GameObject.FindObjectsOfType <GenericMeshDecal>())
            {
                lastDetectedIndex++;

                Mesh actualMesh = decal.GetComponent <MeshFilter>().sharedMesh;
                AssetDatabase.CreateAsset(actualMesh, savingPath + savingBaseName + lastDetectedIndex + ".asset"); // saves to "assets/"
            }
        }