예제 #1
0
        /*
         * Private methods
         */

        private static void DrawBox(ExtendedPropertyDrawer drawer)
        {
            var backgroundRect = drawer.Area;

            backgroundRect.y      -= 2;
            backgroundRect.width  += 2;
            backgroundRect.height += 2;

            backgroundRect.y      += space;
            backgroundRect.height -= space;

            var shadowRect = backgroundRect;

            shadowRect.x      -= 1;
            shadowRect.y      -= 1;
            shadowRect.width  += 2;
            shadowRect.height += 2;

            GUI.DrawTexture(shadowRect, ColourTexture.Get(0, 0, 0, 255));
            GUI.DrawTexture(backgroundRect, ColourTexture.Get(180, 180, 180, 255));
        }
 private void ReleaseTextures()
 {
     // Release the textures object.
     ColourTexture?.ShutDown();
     ColourTexture = null;
 }
예제 #3
0
        void Update()
        {
            // If the sensor reference does not exist or it is not ready, ensure that the frame
            // arrived flags are reset and then cancel the update
            if (!DoesSensorExist() || !IsSensorReady())
            {
                // If the frame handler is not already subscribed to the frame arrived event, do
                // this and then flip the flag
                if (!subscribedFrameHandler)
                {
                    multiSourceReader.MultiSourceFrameArrived += FirstFrameArrivedHandler;
                    subscribedFrameHandler = true;
                }

                if (firstFrameArrived)
                {
                    firstFrameArrived = false;
                }

                return;
            }

            // Otherwise, if the sensor is available and ready but the first frame is yet to arrive,
            // simply return until it has arrived
            if (!firstFrameArrived)
            {
                return;
            }

            // If all above checks have passed, the current frame of incoming data can be processed and
            // made available to other classes
            MultiSourceFrame newMultiFrame = multiSourceReader.AcquireLatestFrame();

            if (newMultiFrame != null)
            {
                ColorFrame colourFrame = newMultiFrame.ColorFrameReference.AcquireFrame();
                if (colourFrame != null)
                {
                    DepthFrame depthFrame = newMultiFrame.DepthFrameReference.AcquireFrame();
                    if (depthFrame != null)
                    {
                        // If all frame references are valid, first generate the 2D texture from the current
                        // colour image by copying the frame pixel data into the byte array. Then, load
                        // this into the texture and apply the changes to render them
                        colourFrame.CopyConvertedFrameDataToArray(colourData, ColorImageFormat.Rgba);
                        ColourTexture.LoadRawTextureData(colourData);
                        ColourTexture.Apply();

                        // Copy the current depth frame data into the ushort array
                        depthFrame.CopyFrameDataToArray(DepthData);

                        // Finally, once all data has been copied, dispose of all frames and dereference
                        // them to free resources for the next incoming frame
                        depthFrame.Dispose();
                        depthFrame = null;
                    }

                    colourFrame.Dispose();
                    colourFrame = null;
                }

                newMultiFrame = null;
            }
        }