VectorImage color

Hi

I really like the fact that I can start using vector images with UI Toolkit. I got it working by naming each Image in the xml the name of the svg I wanted to use and then I load it in manually. Support for the Image class (and its vectorImage property) would be really nice in the UI Builder, but I understand that things take time :slight_smile:

    public void CreateGUI()
    {
        // Each editor window contains a root VisualElement object
        VisualElement root = rootVisualElement;
        root.Clear();
       
        root.Add(new Button(RefreshXML));

        root.styleSheets.Add(AssetDatabase.LoadAssetAtPath<StyleSheet>("Assets/Editor/asdf.uss"));

        // Import UXML
        var visualTree = AssetDatabase.LoadAssetAtPath<VisualTreeAsset>("Assets/Editor/asdf.uxml");
        VisualElement tree = visualTree.CloneTree();
        var images = tree.Query<Image>();
        images.ForEach(UpdateImages);
        root.Add(tree);
    }

    private void UpdateImages(Image image)
    {
        string path = "Assets/Editor/Textures/" + image.name + ".svg";
        var vectorImage = AssetDatabase.LoadAssetAtPath<VectorImage>(path);
        image.vectorImage = vectorImage;
    }

That being said, I would really love it if the #color property in the stylesheet worked on the vector images as right now they are all black. Opacity does work though, which is good!

Hello! Thanks for reporting this. The problem is that the vector image makes use of the color channel to store the shapes’ colors, so that channel can’t be used for “tinting” with the color property.

We’ll investigate for a workaround. Thanks!