Esempio n. 1
0
        public static void Export(PsdExportSettings settings, PsdFileInfo fileInfo)
        {
            for (int i = 0; i < settings.Psd.Layers.Count; i++)
            {
                var groupInfo = fileInfo.GetGroupByLayerIndex(i);
                if (groupInfo != null && !groupInfo.visible)
                {
                    continue;
                }

                if (!fileInfo.LayerVisibility[i])
                {
                    continue;
                }

                var layer = settings.Psd.Layers[i];
                CreateSprite(settings, layer);
            }
            settings.SaveMetaData();
        }
Esempio n. 2
0
        private void DrawPsdLayers()
        {
            EditorGUILayout.LabelField("Layers", styleHeader);

            scrollPos = EditorGUILayout.BeginScrollView(scrollPos);

            int indentLevel = 0;

            PsdFile psd = settings.Psd;

            for (int i = psd.Layers.Count - 1; i >= 0; i--)
            {
                Layer layer = psd.Layers[i];

                var  groupInfo = fileInfo.GetGroupByLayerIndex(i);
                bool inGroup   = groupInfo != null;

                bool startGroup = false;
                bool closeGroup = false;

                if (inGroup)
                {
                    closeGroup = groupInfo.start == i;
                    startGroup = groupInfo.end == i;
                }

                // If entering a layer group, indent
                if (closeGroup)
                {
                    indentLevel--;
                    continue;
                }

                if (inGroup && !startGroup)
                {
                    // Skip contents if group folder closed
                    if (!groupInfo.opened)
                    {
                        continue;
                    }
                    if (!groupInfo.visible)
                    {
                        GUI.enabled = false;
                    }
                }

                if (layer.Name != "</Layer set>")
                {
                    EditorGUILayout.BeginHorizontal();

                    bool visToggle = true;
                    if (startGroup)
                    {
                        visToggle = groupInfo.visible;
                    }
                    else
                    {
                        visToggle = fileInfo.LayerVisibility[i];
                    }

                    // Draw layer visibility toggle
                    visToggle = EditorGUILayout.Toggle(visToggle, GUILayout.MaxWidth(15f));
                    GUILayout.Space(indentLevel * 20f);

                    if (startGroup)
                    {
                        // Draw the layer group name
                        groupInfo.opened            = EditorGUILayout.Foldout(groupInfo.opened, layer.Name);
                        groupInfo.visible           = visToggle;
                        fileInfo.LayerVisibility[i] = visToggle;
                    }
                    else
                    {
                        // Draw the layer name
                        GUILayout.Label(layer.Name, styleLabelLeft);
                        fileInfo.LayerVisibility[i] = visToggle;
                    }

                    EditorGUILayout.EndHorizontal();
                }

                // If close group, just continue to the next layer
                if (startGroup)
                {
                    indentLevel++;
                }

                GUI.enabled = true;
            }             // End layer loop
            EditorGUILayout.EndScrollView();
        }