An error was reported after importing the Aspose PSD DLL into Unity

20230719101217.png (111.1 KB)

@finalsun I’ve made investigation. Aspose.PSD works fine on Windows using .Net 2 Config.

Could you please provide some additional information:

  1. Version of OS
  2. Version of Aspose.PSD
  3. .Net version of Aspose.PSD
    Aspose.PSD_in_Unity.png (94.1 KB)

Here is my code (I’ve made very simple example)

    using Aspose.PSD.FileFormats.Psd.Layers;
    using Aspose.PSD.FileFormats.Psd;
    using Aspose.PSD.ImageLoadOptions;
    using System.Collections;
    using System.Collections.Generic;
    using UnityEngine;
    using Aspose.PSD;

    public class GameManager : MonoBehaviour
    {
        // Start is called before the first frame update
        void Start()
        {
    
        }

        public void ButtonClick()
        {
            var input = @"PathToFile.psd";
            var output = @"PathToFile.unity.out.psd";

            var opt = new PsdLoadOptions()
            {
                LoadEffectsResource = true,
            };

            using (PsdImage img = (PsdImage)Image.Load(input, opt))
            {

                foreach (var layer in img.Layers)
                {
                    if (layer is TextLayer)
                    {
                        var textLayer = (TextLayer)layer;
                        var width = (int)layer.Width;
                        var height = (int)layer.Height;
                        layer.Left = 50;
                        layer.Top = 50;
                        layer.Right = layer.Left + width;
                        layer.Bottom = layer.Top + height;
                    }
                }

                img.Save(output); ;
    }
}

        // Update is called once per frame
        void Update()
        {
    
        }
    }

Thank you for your reply. This is a bug in the Unity Brust plugin. I created a new blank project and imported Aspose. PSD without any errors. But adding my own scripts will reproduce this error. It is speculated that the confusion caused by Aspose. PSD caused the hash name of the script class to be duplicated with other scripts, resulting in Brust compilation errors. I have reported the bug to Unity.

1 Like