/// <summary> /// Reset anything that may be loaded or cached. /// </summary> public void ResetLayout() { startingLayer = null; document = null; //if (spriteLayers != null) { spriteLayers.Clear(); } }
/// <summary> /// Parse the document into /// </summary> void ParseDocumentIntoDictionary() { try { _documentDictionary = Ps2D.MiniJSON.Json.Deserialize(input) as Dictionary <string, object>; document = new LayerMap(); // create a "root" element that looks like a photoshop layer. document.root = new Layer(); document.root.photoshopLayerId = -1; document.root.photoshopLayerName = "root"; document.root.indentLevel = -1; document.root.isVisible = true; document.root.bounds = new PixelBounds(); document.root.hierarchyString = ""; document.root.order = -1; } catch { errorParsing = true; errorMessage = "Invalid file format."; } }
/// <summary> /// Load the document. /// </summary> public void Load() { ResetLayout(); if (layoutDocumentAsset == null) { return; } // load! Loader _loader = new Loader(); _loader.input = layoutDocumentAsset.text; _loader.Load(); // assign the document if (!_loader.errorParsing) { document = _loader.document; CreateSpriteLayers(); ResetHierarchyLabels(); } }