Creating virtual instanced materials in Editor

(For some reason, image upload on discord seems to hang. Might be more useful to post it here so that more people can see it in the future)

[original question]

Hello! Does Flax support creating virtual material instances that are editable on the object’s properties panel, or is it necessary to create new material instances for every object with different material properties, even if they use the same material instance and only differ in properties?

According to the Instanced Materials Docs, if you create a virtual material in code, then you don’t need to create another material in the editor - just reference the base material.
If you want, you can even set colors in the Editor by adding a public Color variable.
Note: colors will be updated when Play Mode starts.

BEFORE Play Mode has started

AFTER Play Mode has started

Here is the updated script:

using FlaxEngine;
namespace Game;

/// <summary>
/// MaterialInstance_Test Script.
/// </summary>
 public class MaterialInstance_Test : Script
{
    [Tooltip("Base material asset to override its properties")]
    public Material BaseMaterial;
    public Color color;

    public override void OnStart()
    {
        // Create dynamic material instance and modify parameter

        var instance = BaseMaterial.CreateVirtualInstance();

        // instance.SetParameterValue("Color", new Color(0xff00ff));
        instance.SetParameterValue("Color", color);

        // Assign instance to the material
        Actor.As<StaticModel>().SetMaterial(0, instance);
    }
}