Files
VR-WuKong/Assets/ThirdParty/Tools/DrawShadowMask/DrawShadowMask.cs
2025-11-14 18:44:06 +08:00

45 lines
1.1 KiB
C#

using System.Collections;
using System.Collections.Generic;
using Unity.Burst.CompilerServices;
using UnityEngine;
public class DrawShadowMask : MonoBehaviour
{
public Texture2D shadowMaskTex;
public Material mat;
[Range(0, 1000)]
public float brushSize;
public bool isDrawing;
public Color color;
// Start is called before the first frame update
void Start()
{
Vector2Int centerPos = new Vector2Int((int)(0.5f * shadowMaskTex.width), (int)(0.5f * shadowMaskTex.height));
for (int y = -(int)brushSize; y <= (int)brushSize; ++y)
{
for (int x = -(int)brushSize; x <= (int)brushSize; ++x)
{
Vector2Int rang = new Vector2Int(x, y) + centerPos;
Debug.Log(rang);
if (rang.x > 0 && rang.x < shadowMaskTex.width || rang.y > 0 && rang.y < shadowMaskTex.height)
{
shadowMaskTex.SetPixel(rang.x, rang.y, Color.red);
}
}
}
shadowMaskTex.Apply();
}
// Update is called once per frame
void Update()
{
}
}