// Copyright (c) Wojciech Figat. All rights reserved.
using System;
namespace FlaxEngine.GUI
{
///
/// Implementation of for rendering.
///
///
public sealed class MaterialBrush : IBrush, IEquatable
{
///
/// The material.
///
[ExpandGroups, Tooltip("The material to use for GUI control area rendering. It must be GUI domain.")]
public MaterialBase Material;
///
/// Initializes a new instance of the class.
///
public MaterialBrush()
{
}
///
/// Initializes a new instance of the struct.
///
/// The material.
public MaterialBrush(MaterialBase material)
{
Material = material;
}
///
public Float2 Size => Float2.One;
///
public void Draw(Rectangle rect, Color color)
{
Render2D.DrawMaterial(Material, rect, color);
}
///
public bool Equals(MaterialBrush other)
{
return other != null && Material == other.Material;
}
///
public override bool Equals(object obj)
{
return obj is MaterialBrush other && Equals(other);
}
///
public override int GetHashCode()
{
return HashCode.Combine(Material);
}
///
public int CompareTo(object obj)
{
return Equals(obj) ? 1 : 0;
}
}
}