public void Update() { if (!working) { return; } if (!retrievedData) { AsyncTextureReader.Status status = AsyncTextureReader.RetrieveBufferData(appendBuffer, data); if (status == AsyncTextureReader.Status.Succeeded) { retrievedData = true; } } if (!retrievedCount) { AsyncTextureReader.Status status = AsyncTextureReader.RetrieveBufferData(argBuffer, count); if (status == AsyncTextureReader.Status.Succeeded) { retrievedCount = true; } } if (retrievedData && retrievedCount) { MeshData data = BuildMeshData(1.0f); Mesh mesh = data.CreateMesh(); mf.mesh = mesh; working = false; } }
public void PathCompute() { float startTime = Time.realtimeSinceStartup; unfulfilledData[0] = 0; unfulfilledBuffer.SetData(unfulfilledData); int runsThisPass = 0; do { if (AtoB) { shader.SetBuffer(PathSolverHandle, "pathBufferFrom", pathBufferA); shader.SetBuffer(PathSolverHandle, "pathBufferTo", pathBufferB); } else { shader.SetBuffer(PathSolverHandle, "pathBufferFrom", pathBufferB); shader.SetBuffer(PathSolverHandle, "pathBufferTo", pathBufferA); } shader.Dispatch(PathSolverHandle, flowWidth / 8, flowHeight / 8, 1); currentRuns++; runsThisPass++; AtoB = !AtoB; } while (Time.realtimeSinceStartup - startTime < pathshare && runsThisPass < MaxRunsPerPass); if (currentRuns > runsBeforeCheck) { if (!waitingForRetrieval) { AsyncTextureReader.RequestBufferData(unfulfilledBuffer); waitingForRetrieval = true; } else { AsyncTextureReader.Status status = AsyncTextureReader.RetrieveBufferData(unfulfilledBuffer, unfulfilledData); if (status == AsyncTextureReader.Status.Succeeded) { waitingForRetrieval = false; if (unfulfilledData[0] == 0) { fulfilled = true; } } } } }
// Update is called once per frame void Update() { if (Pixels == null) { return; } AsyncTextureReader.Status status = AsyncTextureReader.RetrieveTextureData(DebugTexture, Pixels); Debug.Log("Retrieve Status: " + status); if (status == AsyncTextureReader.Status.Succeeded) { // print RGBA of first pixel Debug.LogFormat("Pixel RGBA: {0}; {1}; {2}; {3}", Pixels[0], Pixels[1], Pixels[2], Pixels[3]); Pixels = null; } }
private void GetPixels() { if (Pixels == null) { return; } AsyncTextureReader.Status status = AsyncTextureReader.RetrieveTextureData(DebugTexture, Pixels); Debug.LogFormat("Frame: {0}; Retrieve Status: {1}", Time.frameCount, status); if (status == AsyncTextureReader.Status.Succeeded) { // print RGBA of first pixel Debug.LogFormat("Pixel RGBA: {0}; {1}; {2}; {3}", Pixels[0], Pixels[1], Pixels[2], Pixels[3]); Pixels = null; } }
private void GetData() { #if UNITY_5_5_OR_NEWER if (_floats == null) { return; } AsyncTextureReader.Status status = AsyncTextureReader.RetrieveBufferData(_buffer, _floats); //Debug.LogFormat("Frame: {0}; Retrieve Buffer Status: {1}", Time.frameCount, status); if (status == AsyncTextureReader.Status.Succeeded) { Debug.LogFormat("Buffer Data: {0}; {1}; {2}; {3}", _floats[0], _floats[1], _floats[2], _floats[3]); _floats = null; } #endif }
public void Update() { if (free) { return; } #if UNITY_ASYNC if (!retrievedData) { if (appendRequest.hasError) { Debug.Log("Append Request Error"); } else if (appendRequest.done) { data = appendRequest.GetData <float>(); retrievedData = true; } } if (!retrievedCount) { if (argRequest.hasError) { Debug.Log("Arg Request Error"); } else if (argRequest.done) { count = argRequest.GetData <int>(); retrievedCount = true; } } #else if (!retrievedData) { AsyncTextureReader.Status status = AsyncTextureReader.RetrieveBufferData(appendBuffer, data); if (status == AsyncTextureReader.Status.Succeeded) { retrievedData = true; } } if (!retrievedCount) { AsyncTextureReader.Status status = AsyncTextureReader.RetrieveBufferData(argBuffer, count); if (status == AsyncTextureReader.Status.Succeeded) { retrievedCount = true; } } #endif if (retrievedData && retrievedCount) { bool lastCheck = cur.lastCheck(); if (!forgetNextResult && lastCheck) { cur.callback(BuildMeshData(), cur.id); } if (forgetNextResult) { Debug.Log("forgot last"); } if (!lastCheck) { //Debug.Log("last check fail post"); } free = true; } }