Beispiel #1
0
        private void LoadMetaData()
        {
            string[] nameStrings = Enum.GetNames(typeof(PSDExporter.PivotPos));
            Array    nameVals    = Enum.GetValues(typeof(PSDExporter.PivotPos));

            string[] labels = AssetDatabase.GetLabels(Image);
            foreach (var label in labels)
            {
                if (label.Equals("ImportX1"))
                {
                    ScaleBy = 0;
                }
                if (label.Equals("ImportX2"))
                {
                    ScaleBy = 1;
                }
                if (label.Equals("ImportX4"))
                {
                    ScaleBy = 2;
                }

                if (label.StartsWith("ImportAnchor"))
                {
                    string pivotType = label.Substring(12);
                    if (pivotType.StartsWith("Custom"))
                    {
                        //string values = pivotType.Substring(pivotType.IndexOf("["), pivotType.IndexOf("]"));
                        //string[] vals = values.Split(',');
                        //PivotVector = new Vector2(float.Parse(vals[0]), float.Parse(vals[1]));
                        Pivot = PSDExporter.PivotPos.Custom;
                    }
                    else
                    {
                        // Find by enum
                        for (int i = 0; i < nameStrings.Length; i++)
                        {
                            if (pivotType == nameStrings[i])
                            {
                                Pivot = (PSDExporter.PivotPos)nameVals.GetValue(i);
                            }
                        }
                    }
                }                 // End import anchor if

                if (label.StartsWith("ImportPTU|"))
                {
                    string ptuVal = label.Substring(10);
                    PixelsToUnitSize = Single.Parse(ptuVal);
                }
            }             // End label loop
        }
Beispiel #2
0
        public PsdExportSettings(Texture2D image)
        {
            string path = AssetDatabase.GetAssetPath(image);

            if (!path.ToUpper().EndsWith(".PSD"))
            {
                return;
            }

            Psd      = new PsdFile(path, Encoding.Default);
            Filename = Path.GetFileNameWithoutExtension(path);
            Image    = image;

            ScaleBy          = 0;
            Pivot            = PSDExporter.PivotPos.Center;
            PixelsToUnitSize = 100f;

            LoadMetaData();
        }