/**
* Copyright(c) Live2D Inc. All rights reserved.
*
* Use of this source code is governed by the Live2D Open Software license
* that can be found at https://www.live2d.com/eula/live2d-open-software-license-agreement_en.html.
*/
using Live2D.Cubism.Rendering.Masking;
using UnityEngine;
namespace Live2D.Cubism.Samples.Masking
{
///
/// Allows previewing of a by assigning it to an attached .
///
[ExecuteInEditMode, RequireComponent(typeof(Renderer))]
public class MaskTexturePreview : MonoBehaviour
{
///
/// Mask texture to preview.
///
public CubismMaskTexture MaskTexture;
#region Unity Event Handling
///
/// Called by Unity. Applies to attached .
///
private void Start()
{
var material = (!Application.isEditor || Application.isPlaying)
? GetComponent().material
: GetComponent().sharedMaterial;
material.mainTexture = (Texture)MaskTexture;
}
#endregion
}
}