Beispiel #1
0
        public void Import(UnityStyleSheet asset, string contents)
        {
            ParserStyleSheet styleSheet = m_Parser.Parse(contents);

            if (styleSheet.Errors.Count > 0)
            {
                foreach (StylesheetParseError error in styleSheet.Errors)
                {
                    m_Errors.AddSyntaxError(error.ToString());
                }
            }
            else
            {
                try
                {
                    VisitSheet(styleSheet);
                }
                catch (Exception exc)
                {
                    Debug.LogException(exc);
                    m_Errors.AddInternalError(exc.StackTrace);
                }
            }

            if (!m_Errors.hasErrors)
            {
                m_Builder.BuildTo(asset);
                OnImportSuccess(asset);
            }
            else
            {
                OnImportError(m_Errors);
            }
        }
Beispiel #2
0
        public bool Import(UnityStyleSheet asset, string contents)
        {
            ParserStyleSheet styleSheet = m_Parser.Parse(contents);

            if (styleSheet.Errors.Count > 0)
            {
                foreach (StylesheetParseError error in styleSheet.Errors)
                {
                    m_Errors.AddSyntaxError(error.ToString());
                }
            }
            else
            {
                try
                {
                    VisitSheet(styleSheet);
                }
                catch (Exception exc)
                {
                    m_Errors.AddInternalError(exc.Message);
                }
            }

            if (!m_Errors.hasErrors)
            {
                m_Builder.BuildTo(asset);
            }

            return(!m_Errors.hasErrors);
        }
Beispiel #3
0
        internal static CursorStyle CreateDefaultCursorStyle(StyleSheet sheet, StyleValueHandle handle)
        {
            int         type   = StyleSheetCache.GetEnumValue <MouseCursor>(sheet, handle);
            CursorStyle cursor = new CursorStyle()
            {
                texture = null, hotspot = Vector2.zero, defaultCursorId = type
            };

            return(cursor);
        }
 internal static int GetCursorId(StyleSheet sheet, StyleValueHandle handle)
 {
     return(StyleSheetCache.GetEnumValue <MouseCursor>(sheet, handle));
 }
Beispiel #5
0
 protected void OnImportSuccess(UnityStyleSheet asset)
 {
     m_Context.AddObjectToAsset("stylesheet", asset);
     m_Context.SetMainObject(asset);
 }