void Start() { AsciiArt_Init(); _gid = 0; AsciiArt_PerlinNoise_SetNoiseSeed(_gid, 123); _perlinNoiseCommand = new CommandBuffer(); _perlinNoiseTexture = new Texture2D(perlinNoiseWidth, perlinNoiseHeight, TextureFormat.RGBA32, false); _perlinNoiseTexture.wrapMode = TextureWrapMode.Clamp; // initialize chars image Texture2D _chars = Resources.Load <Texture2D>(charsResName); _pixelsArray = _chars.GetRawTextureData <Color32>(); _charsPixels = _pixelsArray.ToArray(); Debug.Log(String.Format("_pixelsArray = {0} bytes", _pixelsArray.Length)); _charsHandle = GCHandle.Alloc(_charsPixels, GCHandleType.Pinned); IntPtr ptr = _charsHandle.AddrOfPinnedObject(); Debug.Log(String.Format("CharsImage: {0}x{1}, charWidth={2}", _chars.width, _chars.height, charWidth)); AsciiArt_Digit_SetCharsImage(_gid, ptr, _chars.width, _chars.height, charWidth); _digitCommand = new CommandBuffer(); _digitTexture = new Texture2D(perlinNoiseWidth * charWidth, perlinNoiseHeight * _chars.height, TextureFormat.RGBA32, false); _digitTexture.wrapMode = TextureWrapMode.Clamp; var prop = new MaterialPropertyBlock(); prop.SetTexture("_MainTex", _perlinNoiseTexture); prop.SetTexture("_DigitTex", _digitTexture); GetComponent <Renderer>().SetPropertyBlock(prop); }
private void LoadTextures() { System.Diagnostics.Stopwatch stopWatch = new System.Diagnostics.Stopwatch(); stopWatch.Reset(); stopWatch.Start(); Unity.Collections.NativeArray <byte> data = new Unity.Collections.NativeArray <byte>(System.IO.File.ReadAllBytes($"Texture_PNG.png"), Unity.Collections.Allocator.Temp); PNGTexture = new Texture2D(912, 513, TextureFormat.ARGB32, true); PNGTexture.LoadImage(data.ToArray()); PNGTexture.Apply(); data.Dispose(); stopWatch.Stop(); Debug.Log($"<color=red>Time taken for PNG :</color> {stopWatch.ElapsedMilliseconds} ms"); stopWatch.Reset(); stopWatch.Start(); DDSTexture = TextureUtils.LoadTexture_DDS(System.IO.File.ReadAllBytes($"Texture_DDS.DDS"), TextureFormat.DXT5); stopWatch.Stop(); Debug.Log($"<color=red>Time taken for DDS :</color> {stopWatch.ElapsedMilliseconds} ms"); }
IEnumerator Render() { while (true) { yield return(new WaitForEndOfFrame()); if (sora != null) { sora.OnRender(); } if (sora != null && !Recvonly) { var samples = AudioRenderer.GetSampleCountForCaptureFrame(); if (AudioSettings.speakerMode == AudioSpeakerMode.Stereo) { using (var buf = new Unity.Collections.NativeArray <float>(samples * 2, Unity.Collections.Allocator.Temp)) { AudioRenderer.Render(buf); sora.ProcessAudio(buf.ToArray(), 0, samples); } } } } }
public T[] ToArray() { NativeArray <T> nativeArray = this; return(nativeArray.ToArray()); }
public int[] ToArray() { NativeArray <int> nativeArray = this; return(nativeArray.ToArray()); }