예제 #1
0
        void GeneratePreview(Item item, UISnapshotPoint point)
        {
            if (item == null || item.prefab == null)
            {
                return;
            }
            {
                string preview_path = Application.dataPath + "/" + Configure.ResPath + "Preview/" + item.prefab.name + ".png";
                if (File.Exists(preview_path))
                {
                    Texture texture = UIEditorHelper.LoadTextureInLocal(preview_path);
                    item.tex = texture;
                }
                else
                {
                    Texture Tex = UIEditorHelper.GetAssetPreview(item.prefab);
                    if (Tex != null)
                    {
                        DestroyTexture(item);
                        item.tex = Tex;
                        UIEditorHelper.SaveTextureToPNG(Tex, preview_path);
                    }
                }

                item.dynamicTex = false;
                return;
            }
        }
예제 #2
0
 void GeneratePreview(Item item, bool isReCreate = true)
 {
     if (item == null || item.prefab == null)
     {
         return;
     }
     {
         string preview_path = Configure.ResAssetsPath + "/Preview/" + item.prefab.name + ".png";
         if (!isReCreate && File.Exists(preview_path))
         {
             Texture texture = UIEditorHelper.LoadTextureInLocal(preview_path);
             item.tex = texture;
         }
         else
         {
             Texture Tex = UIEditorHelper.GetAssetPreview(item.prefab);
             if (Tex != null)
             {
                 DestroyTexture(item);
                 item.tex = Tex;
                 UIEditorHelper.SaveTextureToPNG(Tex, preview_path);
             }
         }
         item.dynamicTex = false;
         return;
     }
 }
예제 #3
0
        void SaveTextureToPng()
        {
            for (int i = 0; i < mItems.size; i++)
            {
                Item item = mItems[i];
                if (item == null || item.prefab == null || item.tex == null || item.isDirty == false)
                {
                    continue;
                }
                UIEditorHelper.SaveTextureToPNG(item.tex, GetPreviewPath(item));
                string preview_path = GetPreviewPath(item);
                item.tex     = UIEditorHelper.LoadTextureInLocal(preview_path);
                item.isDirty = false;
            }
            GameObject root = GameObject.Find(Configure.PreviewCanvasName);

            if (root)
            {
                DestroyImmediate(root);
            }
        }