Files
sbox-public/engine/Sandbox.Engine/Resources/Material/Material.Flags.cs
s&box team 71f266059a Open source release
This commit imports the C# engine code and game files, excluding C++ source code.

[Source-Commit: ceb3d758046e50faa6258bc3b658a30c97743268]
2025-11-24 09:05:18 +00:00

38 lines
1.0 KiB
C#

namespace Sandbox;
public partial class Material
{
/// <summary>
/// Access flags on this material, which usually hint about the contents. These are generally added by
/// the shader procedurally - but developers can add these in material editor too.
/// </summary>
public FlagsAccessor Flags => new FlagsAccessor( this );
public readonly ref struct FlagsAccessor
{
private readonly Material material;
public FlagsAccessor( Material material )
{
this.material = material;
}
public int GetInt( string name, int defaultValue = 0 )
{
return this.material.native.GetIntAttributeOrDefault( name, defaultValue );
}
public float GetFloat( string name, float defaultValue = 0 )
{
return this.material.native.GetFloatAttributeOrDefault( name, defaultValue );
}
public bool IsSky => GetInt( "sky" ) != 0;
public bool IsTranslucent => GetInt( "translucent" ) != 0;
public bool IsAlphaTest => GetInt( "alphatest" ) != 0;
[Obsolete( "Decal materials are obsolete" )]
public bool IsDecal => GetInt( "decal" ) != 0;
}
}