// Update is called once per frame void Update() { // if have new frames - dequeue them into our textures array while (fetchedFrames.Count > 0) { Debug.Log("[img-controller] dequeuing frames " + fetchedFrames.Count); Texture2D tex = new Texture2D(320, 180, TextureFormat.ARGB32, false); //To-Do: Figure out why frame RGB data is reversed (across the vertical axis). Maybe texture format is not ARGB32? // Could try using Array.reverse(), but that's probably too slow // See: https://gamedev.stackexchange.com/questions/108444/unity-texture2d-raw-data-textureformat-problem FetchedUIFrame tempUIFrame = fetchedFrames.Dequeue(); tex.LoadRawTextureData(tempUIFrame.argbData_); tex.Apply(); textures.Insert(0, tex); //frameTimestamps.Insert(0, (new DateTime(1970, 1, 1) + TimeSpan.FromMilliseconds(tempUIFrame.timestamp_)).ToLocalTime().ToString("MM/dd/yyyy HH:mm:ss")); frameTimestamps.Insert(0, timeAgo(tempUIFrame.timestamp_)); frameSimLevels.Insert(0, tempUIFrame.simLevel_); //To-Do: Format above to PST (or w/e your regional time is). Right now I think it's about 7 or 8 hours ahead of our time allowNewMemories = true; } while (textures.Count > nFramesToRetain_) { textures.RemoveAt(textures.Count - 1); } while (frameTimestamps.Count > nFramesToRetain_) { frameTimestamps.RemoveAt(frameTimestamps.Count - 1); } while (frameSimLevels.Count > nFramesToRetain_) { frameSimLevels.RemoveAt(frameSimLevels.Count - 1); } if (allowNewMemories) { UpdateMemories(); } // update whatever debug text was there debugPanelText.text = debugText_; fpsLabel.text = currentFpsString_; }
public void enqueueFrame(FetchedUIFrame frameData) { Debug.Log("[img-controller] enqueued frame"); fetchedFrames.Enqueue(frameData); }