03-04-2026, 03:45 PM
I see now that you solve that by using reflection.
But by deriving your own class from MultiLineNode (or any other class that is derived from LineBaseNode), you can change the protected material and lineBaseMaterial fields without using reflection.
For example, you can add the following code to a derived class to change the material:
But by deriving your own class from MultiLineNode (or any other class that is derived from LineBaseNode), you can change the protected material and lineBaseMaterial fields without using reflection.
For example, you can add the following code to a derived class to change the material:
Code:
public void ChangeMaterial(Material? newMaterial)
{
if (ReferenceEquals(newMaterial, material))
return;
DisposeRenderingItems(); // dispose existing RenderingItems
material = newMaterial;
if (newMaterial != null)
{
CheckIfMaterialIsDisposed(newMaterial);
if (Scene != null && !newMaterial.IsInitialized)
newMaterial.InitializeSceneResources(Scene);
lastMaterialVersion = -1; // This will update the material in CollectRenderingItems
}
// we store material also as LineMaterial for improved performance in getters and setters
lineBaseMaterial = newMaterial as LineMaterial;
NotifyChange(SceneNodeDirtyFlags.MaterialChanged);
}
Andrej Benedik

