Esempio n. 1
0
        public Texture2D SaveShadowTexture()
        {
            string folderPath = AssetDatabase.GUIDToAssetPath(FolderGUID);
            string fileName   = SoftMaterial.name + "_shadow" + ".png";

            shadowOptions.SaveTexture(folderPath + "/" + fileName);
            Texture2D face = (Texture2D)AssetDatabase.LoadAssetAtPath(folderPath + "/" + fileName, typeof(Texture2D));

            ClassExtensions.ReimportTexture(face, false);
            return(face);
        }
Esempio n. 2
0
        public Texture2D SaveFaceTexture()
        {
            string folderPath = AssetDatabase.GUIDToAssetPath(FolderGUID);
            string fileName   = SoftMaterial.name + "_work" + ".png";

            faceOptions.SaveTexture(folderPath + "/" + fileName);
            Texture2D face = (Texture2D)AssetDatabase.LoadAssetAtPath(folderPath + "/" + fileName, typeof(Texture2D));

            if (Facetarget == FaceTarget.Font)
            {
                ClassExtensions.ReimportTexture(face, false);
            }
            else if (Facetarget == FaceTarget.Sprite)
            {
                ClassExtensions.ReimportTextureAsSprite_1(folderPath + "/" + fileName, faceOptions.pixelsPerUnit, false);
                GetComponent <SpriteRenderer>().sprite = (Sprite)AssetDatabase.LoadAssetAtPath(folderPath + "/" + fileName, typeof(Sprite));
            }
            return(face);
        }
Esempio n. 3
0
        /// <summary>
        /// Create unique font folder for SoftEffects Instance or clean existing.
        /// </summary>
        private void CreateSEFolder(string fontName, bool createNew)
        {
            if (!createNew)
            {
                // check for folder existing for SoftEffects Font
                if (AssetDatabase.IsValidFolder(AssetDatabase.GUIDToAssetPath(FolderGUID)))
                {
                    // delete all assets from folder if SE.isDirty
                    if (SoftEffects.debuglog)
                    {
                        Debug.Log("Folder for SeFont also exist: " + AssetDatabase.GUIDToAssetPath(FolderGUID));
                    }
                    if (SoftEffects.debuglog)
                    {
                        Debug.Log("Delete files from existing folder: " + AssetDatabase.GUIDToAssetPath(FolderGUID));
                    }

                    ClassExtensions.DeleteFilesFromDir(AssetDatabase.GUIDToAssetPath(FolderGUID), key);

                    if (SoftFont && SoftFont.material && SoftFont.material.mainTexture)
                    {
                        if (File.Exists(AssetDatabase.GetAssetPath(SoftFont.material.mainTexture)))
                        {
                            if (SoftEffects.debuglog)
                            {
                                Debug.Log("Texture File: " + AssetDatabase.GetAssetPath(SoftFont.material.mainTexture) + " - delete");
                            }
                            FileUtil.DeleteFileOrDirectory(AssetDatabase.GetAssetPath(SoftFont.material.mainTexture));
                        }
                    }

                    if (SoftFont && SoftFont.material)
                    {
                        if (File.Exists(AssetDatabase.GetAssetPath(SoftFont.material)))
                        {
                            if (SoftEffects.debuglog)
                            {
                                Debug.Log("Material File: " + AssetDatabase.GetAssetPath(SoftFont.material) + " - delete");
                            }
                            FileUtil.DeleteFileOrDirectory(AssetDatabase.GetAssetPath(SoftFont.material));
                        }
                    }

                    if (SoftFont)
                    {
                        if (File.Exists(AssetDatabase.GetAssetPath(SoftFont)))
                        {
                            if (SoftEffects.debuglog)
                            {
                                Debug.Log("Font File: " + AssetDatabase.GetAssetPath(SoftFont) + " - delete");
                            }
                            FileUtil.DeleteFileOrDirectory(AssetDatabase.GetAssetPath(SoftFont));
                        }
                    }
                    return;
                }
            }

            string seFolder = GetSEEditFolder();

            if (seFolder != "")
            {
                FolderGUID = AssetDatabase.CreateFolder(seFolder, fontName + SEFontSubFolderSufix);
                if (SoftEffects.debuglog)
                {
                    Debug.Log("Create new folder : " + AssetDatabase.GUIDToAssetPath(FolderGUID));
                }
            }
        }