First Version

This commit is contained in:
xpeng
2022-05-16 23:38:40 +02:00
parent 9f8dfe4b2d
commit cfc2455e84
283 changed files with 36283 additions and 0 deletions
@@ -0,0 +1,48 @@
using UnityEngine;
namespace uWindowCapture
{
public class UwcGetPixelsExample : MonoBehaviour
{
[SerializeField] UwcWindowTexture uwcTexture;
[SerializeField] int x = 100;
[SerializeField] int y = 100;
[SerializeField] int w = 64;
[SerializeField] int h = 32;
public Texture2D texture;
Color32[] colors;
void CreateTextureIfNeeded()
{
if (!texture || texture.width != w || texture.height != h)
{
colors = new Color32[w * h];
texture = new Texture2D(w, h, TextureFormat.RGBA32, false);
GetComponent<Renderer>().material.mainTexture = texture;
}
}
void Start()
{
CreateTextureIfNeeded();
}
void Update()
{
CreateTextureIfNeeded();
var window = uwcTexture.window;
if (window == null || window.width == 0) return;
// GetPixels() can be run in another thread
if (window.GetPixels(colors, x, y, w, h)) {
texture.SetPixels32(colors);
texture.Apply();
}
}
}
}