Texture inheritance for materials, also script access

This commit is contained in:
Simon Lübeß
2025-03-01 00:03:38 +01:00
parent 824c19c0b2
commit b5088329f5
13 changed files with 470 additions and 82 deletions
+34 -3
View File
@@ -8,11 +8,16 @@ namespace GlitchyEngine.Graphics;
public class MeshRenderer : Component
{
/// <summary>
/// Gets or sets the Material of this <see cref="MeshRenderer"/>.
/// Gets or sets the instance Material of this <see cref="MeshRenderer"/>.
/// </summary>
/// <remarks>
/// If you get the <see cref="Material"/> and it is not yet a runtime-instance,
/// a new runtime-instance will be created and returned in its place.
/// If you get the <see cref="GlitchyEngine.Graphics.Material"/> and it is not yet a runtime-instance,
/// a new runtime-instance will be created and returned in its place. If you want to get the actual material instance,
/// use <see cref="SharedMaterial"/> instead.
/// <para>
/// <b>Note:</b> While the behaviour differs for getting <see cref="SharedMaterial"/> and <see cref="Material"/>,
/// the setter behaves identical for both properties.
/// </para>
/// </remarks>
public Material Material
{
@@ -24,4 +29,30 @@ public class MeshRenderer : Component
}
set => ScriptGlue.MeshRenderer_SetMaterial(_uuid, value._uuid);
}
/// <summary>
/// Gets or sets the shared Material of this <see cref="MeshRenderer"/>.
/// </summary>
/// <remarks>
/// <para>
/// In contrast to the <see cref="Material"/>-property this will not create a new runtime-instance and instead
/// always return the actual Material-Asset.
/// Making changes to the instance returned by this property will have global effect.
/// <see cref="GlitchyEngine.Graphics.Material"/> is used (and obviously instances/children of it).
/// </para>
/// <para>
/// <b>Note:</b> While the behaviour differs for getting <see cref="SharedMaterial"/> and <see cref="Material"/>,
/// the setter behaves identical for both properties.
/// </para>
/// </remarks>
public Material SharedMaterial
{
get
{
ScriptGlue.MeshRenderer_GetSharedMaterial(_uuid, out UUID materialHandle);
return new Material { _uuid = materialHandle };
}
set => ScriptGlue.MeshRenderer_SetMaterial(_uuid, value._uuid);
}
}