diff --git a/Assets/uDesktopDuplication/Examples/Scripts/GetPixelsExample.cs b/Assets/uDesktopDuplication/Examples/Scripts/GetPixelsExample.cs index 7cc174c..94dcf2c 100644 --- a/Assets/uDesktopDuplication/Examples/Scripts/GetPixelsExample.cs +++ b/Assets/uDesktopDuplication/Examples/Scripts/GetPixelsExample.cs @@ -1,18 +1,18 @@ -using UnityEngine; - -public class GetPixelsExample : MonoBehaviour -{ - [SerializeField] uDesktopDuplication.Texture uddTexture; - - [SerializeField] int x = 100; - [SerializeField] int y = 100; - [SerializeField] int w = 64; - [SerializeField] int h = 32; - - public Texture2D texture; - Color32[] colors; - - void CreateTextureIfNeeded() +using UnityEngine; + +public class GetPixelsExample : MonoBehaviour +{ + [SerializeField] uDesktopDuplication.Texture uddTexture; + + [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) { @@ -20,28 +20,28 @@ public class GetPixelsExample : MonoBehaviour texture = new Texture2D(w, h, TextureFormat.ARGB32, false); GetComponent().material.mainTexture = texture; } - } - - void Start() - { - CreateTextureIfNeeded(); - } - - void Update() - { - CreateTextureIfNeeded(); - - // must be called (performance will be slightly down). - uDesktopDuplication.Manager.primary.useGetPixels = true; - - var monitor = uddTexture.monitor; - if (!monitor.hasBeenUpdated) return; - - if (monitor.GetPixels(colors, x, y, w, h)) { - texture.SetPixels32(colors); - texture.Apply(); - } - - Debug.Log(monitor.GetPixel(monitor.cursorX, monitor.cursorY)); - } -} + } + + void Start() + { + CreateTextureIfNeeded(); + } + + void Update() + { + CreateTextureIfNeeded(); + + // must be called (performance will be slightly down). + uDesktopDuplication.Manager.primary.useGetPixels = true; + + var monitor = uddTexture.monitor; + if (!monitor.hasBeenUpdated) return; + + if (monitor.GetPixels(colors, x, y, w, h)) { + texture.SetPixels32(colors); + texture.Apply(); + } + + Debug.Log(monitor.GetPixel(monitor.cursorX, monitor.cursorY)); + } +}