private bool SetupRenderMaterial(Entity target) { // If this Canvas was already rendering to an Entity previously, // remove the material from that entity and apply the original material to it again. if (_targetMaterial != null) { if (TargetEntity != null && _originalMaterial != null) { TargetEntity.Material = _originalMaterial; } _targetMaterial.Release(); _targetMaterial.Dispose(); } // In case the material is used on multiple entities it is duplicated here. // This prevents conflicts with entities with the same materials and/or textures. _originalMaterial = target.Material; var material = CopyMaterial(_originalMaterial); _targetMaterial = material; material.SetTexture(TargetTexture.ID); target.Material = material; TargetEntity = target; return(true); }
public void Dispose() { model?.Dispose(); material?.Dispose(); foreach (var component in components) { component.Dispose(); } }