fix line endings.
This commit is contained in:
@@ -1,18 +1,18 @@
|
|||||||
using UnityEngine;
|
using UnityEngine;
|
||||||
|
|
||||||
public class GetPixelsExample : MonoBehaviour
|
public class GetPixelsExample : MonoBehaviour
|
||||||
{
|
{
|
||||||
[SerializeField] uDesktopDuplication.Texture uddTexture;
|
[SerializeField] uDesktopDuplication.Texture uddTexture;
|
||||||
|
|
||||||
[SerializeField] int x = 100;
|
[SerializeField] int x = 100;
|
||||||
[SerializeField] int y = 100;
|
[SerializeField] int y = 100;
|
||||||
[SerializeField] int w = 64;
|
[SerializeField] int w = 64;
|
||||||
[SerializeField] int h = 32;
|
[SerializeField] int h = 32;
|
||||||
|
|
||||||
public Texture2D texture;
|
public Texture2D texture;
|
||||||
Color32[] colors;
|
Color32[] colors;
|
||||||
|
|
||||||
void CreateTextureIfNeeded()
|
void CreateTextureIfNeeded()
|
||||||
{
|
{
|
||||||
if (!texture || texture.width != w || texture.height != h)
|
if (!texture || texture.width != w || texture.height != h)
|
||||||
{
|
{
|
||||||
@@ -20,28 +20,28 @@ public class GetPixelsExample : MonoBehaviour
|
|||||||
texture = new Texture2D(w, h, TextureFormat.ARGB32, false);
|
texture = new Texture2D(w, h, TextureFormat.ARGB32, false);
|
||||||
GetComponent<Renderer>().material.mainTexture = texture;
|
GetComponent<Renderer>().material.mainTexture = texture;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void Start()
|
void Start()
|
||||||
{
|
{
|
||||||
CreateTextureIfNeeded();
|
CreateTextureIfNeeded();
|
||||||
}
|
}
|
||||||
|
|
||||||
void Update()
|
void Update()
|
||||||
{
|
{
|
||||||
CreateTextureIfNeeded();
|
CreateTextureIfNeeded();
|
||||||
|
|
||||||
// must be called (performance will be slightly down).
|
// must be called (performance will be slightly down).
|
||||||
uDesktopDuplication.Manager.primary.useGetPixels = true;
|
uDesktopDuplication.Manager.primary.useGetPixels = true;
|
||||||
|
|
||||||
var monitor = uddTexture.monitor;
|
var monitor = uddTexture.monitor;
|
||||||
if (!monitor.hasBeenUpdated) return;
|
if (!monitor.hasBeenUpdated) return;
|
||||||
|
|
||||||
if (monitor.GetPixels(colors, x, y, w, h)) {
|
if (monitor.GetPixels(colors, x, y, w, h)) {
|
||||||
texture.SetPixels32(colors);
|
texture.SetPixels32(colors);
|
||||||
texture.Apply();
|
texture.Apply();
|
||||||
}
|
}
|
||||||
|
|
||||||
Debug.Log(monitor.GetPixel(monitor.cursorX, monitor.cursorY));
|
Debug.Log(monitor.GetPixel(monitor.cursorX, monitor.cursorY));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user