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

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

                    CubeTF.gameObject.SetActive(true);
                    SetBoxBackgroundActive(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");
                }
            }
        }
Ejemplo n.º 2
0
        // Data



        #endregion



        #region --- TSK ---



        private void CreateSprite(bool _8bit)
        {
            if (!Data)
            {
                return;
            }
            string path = Util.FixPath(EditorUtility.SaveFilePanel("Select Export Path", "Assets", Util.GetNameWithoutExtension(VoxelFilePath) + (_8bit ? "_8bit" : "_2D"), "png"));

            if (!string.IsNullOrEmpty(path))
            {
                path = EditorUtil.RelativePath(path);
                if (!string.IsNullOrEmpty(path))
                {
                    var result = _8bit ?
                                 Core_Sprite.Create8bitSprite(Data, CurrentModelIndex) :
                                 Core_Sprite.Create2DSprite(Data, CurrentModelIndex);
                    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
                {
                    EditorUtil.Dialog("Warning", "Export path must in Assets folder.", "OK");
                }
            }
        }