Exemplo n.º 1
0
        void PasteUSS(string copyBuffer)
        {
            // Paste does nothing if document has no stylesheets.
            var mainStyleSheet = m_PaneWindow.document.activeStyleSheet;

            if (mainStyleSheet == null)
            {
                return;
            }

            var pasteStyleSheet = StyleSheetUtilities.CreateInstance();
            var importer        = new BuilderStyleSheetImporter(); // Cannot be cached because the StyleBuilder never gets reset.

            importer.Import(pasteStyleSheet, copyBuffer);

            // Select all pasted selectors.
            m_Selection.ClearSelection(null);
            foreach (var selector in pasteStyleSheet.complexSelectors)
            {
                BuilderAssetUtilities.AddStyleComplexSelectorToSelection(pasteStyleSheet, selector);
            }

            BuilderAssetUtilities.TransferAssetToAsset(m_PaneWindow.document, mainStyleSheet, pasteStyleSheet);

            ScriptableObject.DestroyImmediate(pasteStyleSheet);
        }
        void PasteUSS(string copyBuffer)
        {
            var pasteStyleSheet = StyleSheetUtilities.CreateInstance();
            var importer        = new BuilderStyleSheetImporter(); // Cannot be cached because the StyleBuilder never gets reset.

            importer.Import(pasteStyleSheet, copyBuffer);

            BuilderAssetUtilities.TransferAssetToAsset(m_PaneWindow.document, pasteStyleSheet);

            ScriptableObject.DestroyImmediate(pasteStyleSheet);
        }
Exemplo n.º 3
0
        void PasteUSS(string copyBuffer)
        {
            var pasteStyleSheet = StyleSheetUtilities.CreateInstance();
            var importer        = new BuilderStyleSheetImporter(); // Cannot be cached because the StyleBuilder never gets reset.

            importer.Import(pasteStyleSheet, copyBuffer);

            BuilderAssetUtilities.TransferAssetToAsset(m_PaneWindow.document, pasteStyleSheet);

            m_Selection.ClearSelection(null);
            var scs = m_PaneWindow.document.mainStyleSheet.complexSelectors.Last();

            BuilderAssetUtilities.AddStyleComplexSelectorToSelection(m_PaneWindow.document, scs);

            ScriptableObject.DestroyImmediate(pasteStyleSheet);
        }