UnityEngine.WSA.Application.InvokeOnAppThread C# (CSharp) Method

InvokeOnAppThread() public static method

Executes callback item on application thread.

public static InvokeOnAppThread ( AppCallbackItem item, bool waitUntilDone ) : void
item AppCallbackItem Item to execute.
waitUntilDone bool Wait until item is executed.
return void
        public static void InvokeOnAppThread(AppCallbackItem item, bool waitUntilDone)
        {
            item();
        }

Usage Example

コード例 #1
0
    private void trackFilteredObject(ObjectTracker ot, Mat threshold)
    {
        Mat temp = new Mat();

        threshold.copyTo(temp);

        List <MatOfPoint> contours = new List <MatOfPoint>();
        Mat hierarchy = new Mat();

        Imgproc.findContours(temp, contours, hierarchy, Imgproc.RETR_CCOMP, Imgproc.CHAIN_APPROX_SIMPLE);

        if (hierarchy.rows() > 0)
        {
            for (int index = 0; index >= 0; index = (int)hierarchy.get(0, index)[0])
            {
                Moments moment = Imgproc.moments(contours[index]);
                double  area   = moment.m00;

                if (area > 10 * 10)
                {
                    int x = (int)(moment.get_m10() / area);
                    int y = (int)(moment.get_m01() / area);

                    Vector2 point  = new Vector2(x, y);
                    Vector3 dirRay = LocatableCameraUtils.PixelCoordToWorldCoord(_cameraToWorldMatrix, _projectionMatrix, _resolution, point);

                    Application.InvokeOnAppThread(() => {
                        ot.Sphere.transform.position = Camera.main.transform.position + new Vector3(0, ot.offset, 0);
                        SphereCollider collider      = ot.Sphere.GetComponent <SphereCollider>();

                        // We inverse the ray source and dir to make the sphere collider work
                        Vector3 newPosRay = Camera.main.transform.position + dirRay * (collider.radius * 2);

                        Ray ray = new Ray(newPosRay, -dirRay);
                        RaycastHit hit;

                        if (Physics.Raycast(ray, out hit, collider.radius * 3))
                        {
                            Vector3 pos = hit.point;
                            ot.gameObject.transform.position = pos;
                        }
                    }, false);
                }
            }
        }
    }
All Usage Examples Of UnityEngine.WSA.Application::InvokeOnAppThread