Example #1
0
    public void OnStyleSheetChanged(string text)
    {
        try
        {
            var styles = UssParser.Parse(text);
            UssStyleModifier.Apply(
                UssRoot.FindRootInScene().gameObject, styles.styles);

            errorMessage.CrossFadeColor(Color.white, 0.5f, true, true);
            errorMessage.text = "SUCCESS";
        }
        catch (Exception e)
        {
            errorMessage.CrossFadeColor(Color.red, 0.5f, true, true);
            errorMessage.text = e.Message;
        }
    }
Example #2
0
    public void OnGUI()
    {
        UssAutoRefresh.EnsureLastUcssLoaded();

        tab = GUILayout.Toolbar(tab, new string[] { "Color", "Number", "String" });
        EditorGUILayout.BeginHorizontal(GUI.skin.FindStyle("Toolbar"));
        query = GUILayout.TextField(query, GUI.skin.FindStyle("ToolbarSeachTextField"));
        EditorGUILayout.EndHorizontal();
        EditorGUILayout.Space();

        queryResults = 0;
        if (tab == 0)
        {
            DrawColors();
        }
        else if (tab == 1)
        {
            DrawNumbers();
        }
        else if (tab == 2)
        {
            DrawStrings();
        }

        if (queryResults == 0)
        {
            GUILayout.Box(noResultTex, GUILayout.Width(100), GUILayout.Height(100));
            EditorGUILayout.LabelField("No results");
        }

        if (GUI.changed)
        {
            var root = UssRoot.FindRootInScene();
            UssStyleModifier.Apply(root.gameObject);
            EditorUtility.SetDirty(root.gameObject);
        }
    }