Ejemplo n.º 1
0
        private void CreateScreenShot()
        {
            string path = Util.FixPath(EditorUtility.SaveFilePanel("Select Export Path", "Assets", Util.GetNameWithoutExtension(VoxelFilePath) + "_screenShot", "png"));

            if (!string.IsNullOrEmpty(path))
            {
                path = Util.FixedRelativePath(path);
                if (!string.IsNullOrEmpty(path))
                {
                    bool oldShow = ShowBackgroundBox;
                    CubeTF.gameObject.SetActive(false);
                    BoxRoot.gameObject.SetActive(false);
                    var texture = Util.RenderTextureToTexture2D(Camera);
                    if (texture)
                    {
                        texture = Util.TrimTexture(texture, 0.01f, 12);
                        Util.ByteToFile(texture.EncodeToPNG(), path);
                        VoxelPostprocessor.AddScreenshot(path);
                        AssetDatabase.SaveAssets();
                        AssetDatabase.Refresh();
                        EditorApplication.delayCall += VoxelPostprocessor.ClearAsset;
                    }
                    CubeTF.gameObject.SetActive(true);
                    BoxRoot.gameObject.SetActive(oldShow);
                }
                else
                {
                    Util.Dialog("Warning", "Export path must in Assets folder.", "OK");
                }
            }
        }
Ejemplo n.º 2
0
        private void CreateSprite(Core_Sprite.SpriteType type)
        {
            if (!Data)
            {
                return;
            }
            string path = Util.FixPath(EditorUtility.SaveFilePanel("Select Export Path", "Assets", Util.GetNameWithoutExtension(VoxelFilePath) + type.ToString(), "png"));

            if (!string.IsNullOrEmpty(path))
            {
                path = Util.FixedRelativePath(path);
                if (!string.IsNullOrEmpty(path))
                {
                    bool oldShow = ShowBackgroundBox;
                    CubeTF.gameObject.SetActive(false);
                    BoxRoot.gameObject.SetActive(false);

                    var result = Core_Sprite.CreateSprite(
                        Data,
                        CurrentModelIndex,
                        type,
                        GetSpriteNum(type),
                        GetSpriteLight(type),
                        GetSpritePivot(type),
                        Camera,
                        Sprite25DCameraScale
                        );

                    CubeTF.gameObject.SetActive(true);
                    BoxRoot.gameObject.SetActive(oldShow);

                    if (result.Texture)
                    {
                        Util.ByteToFile(result.Texture.EncodeToPNG(), path);
                        VoxelPostprocessor.AddSprite(path, new VoxelPostprocessor.SpriteConfig()
                        {
                            width       = result.Width,
                            height      = result.Height,
                            Pivots      = result.Pivots,
                            spriteRects = result.Rects,
                            Names       = result.NameFixes,
                        });
                        AssetDatabase.SaveAssets();
                        AssetDatabase.Refresh(ImportAssetOptions.ForceUpdate);
                        EditorApplication.delayCall += VoxelPostprocessor.ClearAsset;
                    }
                }
                else
                {
                    Util.Dialog("Warning", "Export path must in Assets folder.", "OK");
                }
            }
        }