예제 #1
0
    public void OnSelectorChanged(string text)
    {
        var conditions = UssParser.ParseConditions(text);
        var go         = UssStyleModifier.FindObjects(
            UssRoot.FindRootInScene().gameObject, conditions);

        foreach (var c in prevObjects)
        {
            if (go.Contains(c.gameObject))
            {
                continue;
            }
            c.CrossFadeColor(Color.white, 0, true, true);
        }
        prevObjects.Clear();

        foreach (var g in go)
        {
            foreach (var c in g.GetComponentsInChildren <Graphic>())
            {
                c.CrossFadeColor(new Color32(255, 64, 64, 255), 0.5f, true, true);
                prevObjects.Add(c);
            }
        }

        selectedObjects.text = go.Length + " object(s)";
    }
예제 #2
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;
        }
    }
예제 #3
0
    void OnGUI()
    {
        EditorGUILayout.BeginHorizontal(GUI.skin.FindStyle("Toolbar"));
        query = GUILayout.TextField(query, GUI.skin.FindStyle("ToolbarSeachTextField"));
        EditorGUILayout.EndHorizontal();
        EditorGUILayout.Space();

        EditorGUILayout.LabelField(selections + " object(s) found.");

        if (GUI.changed && string.IsNullOrEmpty(query) == false)
        {
            var conditions = UssParser.ParseConditions(query);
            if (conditions.Length == 0)
            {
                return;
            }

            Selection.objects = UssStyleModifier.FindObjects(
                UssRoot.FindRootInScene().gameObject, conditions);

            selections = Selection.objects.Length;
        }
    }