static void UpdateTexture(ref Texture2D RamTexture, UnityEvent_Texture Event, byte[] Ram, ComponentSize Size, int Width = 256) { var DataLength = Ram.Length / (int)Size; var Height = DataLength / Width; if (!Mathf.IsPowerOfTwo(Height)) { Height = Mathf.NextPowerOfTwo(Height); } if (RamTexture == null || RamTexture.width != Width || RamTexture.height != Height) { RamTexture = null; } if (RamTexture == null) { var Format = Size == ComponentSize.Eight ? TextureFormat.R8 : TextureFormat.RG16; RamTexture = new Texture2D(Width, Height, Format, false); RamTexture.filterMode = FilterMode.Point; RamTexture.wrapMode = TextureWrapMode.Clamp; } var PixelData = GetTextureSizedBytes(RamTexture, Ram); RamTexture.LoadRawTextureData(PixelData); RamTexture.Apply(); Event.Invoke(RamTexture); }