2020-05-01 17:38:37 +08:00
|
|
|
|
using System.Collections;
|
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
using UnityEngine;
|
|
|
|
|
using UnityEngine.UI;
|
|
|
|
|
|
2020-05-11 15:34:22 +08:00
|
|
|
|
namespace Coffee.UISoftMask.Demos
|
2020-05-01 17:38:37 +08:00
|
|
|
|
{
|
2020-05-11 15:34:22 +08:00
|
|
|
|
public class SoftMask_Demo : MonoBehaviour
|
|
|
|
|
{
|
|
|
|
|
[SerializeField] RawImage[] softMaskBufferViewer;
|
|
|
|
|
[SerializeField] SoftMask[] softMask;
|
|
|
|
|
[SerializeField] Text text;
|
|
|
|
|
[SerializeField] GameObject title;
|
2020-05-01 17:38:37 +08:00
|
|
|
|
|
|
|
|
|
|
2020-05-11 15:34:22 +08:00
|
|
|
|
// Use this for initialization
|
|
|
|
|
void OnEnable()
|
|
|
|
|
{
|
|
|
|
|
title.SetActive(true);
|
|
|
|
|
|
|
|
|
|
text.text = string.Format("GPU: {0}\nDeviceType: {1}\nShaderLevel: {2}\nUVStartsAtTop: {3}",
|
2020-05-01 17:38:37 +08:00
|
|
|
|
SystemInfo.graphicsDeviceName,
|
|
|
|
|
SystemInfo.graphicsDeviceType,
|
|
|
|
|
SystemInfo.graphicsShaderLevel,
|
|
|
|
|
SystemInfo.graphicsUVStartsAtTop);
|
|
|
|
|
|
2020-05-11 15:34:22 +08:00
|
|
|
|
for (int i = 0; i < softMask.Length; i++)
|
|
|
|
|
{
|
|
|
|
|
softMaskBufferViewer[i].texture = softMask[i].softMaskBuffer;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void SetWorldSpase(bool flag)
|
|
|
|
|
{
|
|
|
|
|
if (flag)
|
|
|
|
|
{
|
|
|
|
|
GetComponent<Canvas>().renderMode = RenderMode.ScreenSpaceCamera;
|
|
|
|
|
GetComponent<Canvas>().renderMode = RenderMode.WorldSpace;
|
|
|
|
|
transform.rotation = Quaternion.Euler(new Vector3(0, 6, 0));
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void SetScreenSpase(bool flag)
|
|
|
|
|
{
|
|
|
|
|
if (flag)
|
|
|
|
|
{
|
|
|
|
|
GetComponent<Canvas>().renderMode = RenderMode.ScreenSpaceCamera;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void SetOverlay(bool flag)
|
|
|
|
|
{
|
|
|
|
|
if (flag)
|
|
|
|
|
{
|
|
|
|
|
GetComponent<Canvas>().renderMode = RenderMode.ScreenSpaceOverlay;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|