Beispiel #1
0
    void OnGUI()
    {
        EditorGUILayout.BeginHorizontal();
        EditorGUILayout.LabelField("INSTANT EVAL");
        if (GUILayout.Button("run!"))
        {
            /*
             * var result = UssParser.Parse(script);
             * UssStyleModifier.Apply(
             *  UssRoot.FindRootInScene().gameObject,
             *  result.styles);
             */
            UssStyleModifier.LoadUss(script);
        }
        EditorGUILayout.EndHorizontal();

        script = GUI.TextArea(new Rect(0, 30, position.width, 300), script);

        var editor = (TextEditor)GUIUtility.GetStateObject(typeof(TextEditor), GUIUtility.keyboardControl);

        if (string.IsNullOrEmpty(editor.SelectedText) == false)
        {
            if (prevSelectionText == editor.SelectedText)
            {
                return;
            }

            var result = UssParser.ParseConditions(editor.SelectedText);
            Selection.objects = UssStyleModifier.FindObjects(
                UssRoot.FindRootInScene().gameObject,
                result);

            prevSelectionText = editor.SelectedText;
        }
    }
Beispiel #2
0
    void OnGUI()
    {
        EditorGUI.DrawPreviewTexture(new Rect(position.width / 2 - 50, 20, 100, 100), cssTex);
        GUILayout.Space(140);

        if (GUILayout.Button("apply"))
        {
            UssAutoRefresh.currentUcss = "Assets/Resources/default.ucss";
            UssStyleModifier.LoadUss(File.ReadAllText("Assets/Resources/default.ucss"));
        }
    }
Beispiel #3
0
    public static void EnsureLastUcssLoaded()
    {
        if (UssStyleModifier.loaded)
        {
            return;
        }

        if (string.IsNullOrEmpty(currentUcss) == false)
        {
            UssStyleModifier.LoadUss(File.ReadAllText(currentUcss));
        }
    }
Beispiel #4
0
    static void OnPostprocessAllAssets(string[] importedAssets, string[] deletedAssets, string[] movedAssets, string[] movedFromAssetPaths)
    {
        foreach (var asset in importedAssets)
        {
            if (asset.EndsWith(".ucss") == false)
            {
                continue;
            }

            if (asset == currentUcss)
            {
                UssStyleModifier.LoadUss(File.ReadAllText(asset));
            }
        }
    }
Beispiel #5
0
    public void Rebuild(string doc)
    {
        for (int i = 0; i < transform.childCount; i++)
        {
            DestroyImmediate(transform.GetChild(0).gameObject);
        }

        var html = new HtmlDocument();

        html.LoadHtml(doc);

        inlineStyle = "";
        foreach (var child in html.DocumentNode.ChildNodes)
        {
            ComposeNode(child, transform);
        }

        if (string.IsNullOrEmpty(inlineStyle) == false)
        {
            UssStyleModifier.ApplyUss(inlineStyle);
        }
        UssStyleModifier.LoadUss(UssRoot.FindRootInScene().ucssPath);
    }