Example #1
0
    public void Update()
    {
        EUNITY_CALLBACK_EVENT eventID = (EUNITY_CALLBACK_EVENT)MetaioSDKUnity.getUnityCallbackEventID();

        if (eventID != EUNITY_CALLBACK_EVENT.EUCE_NONE)
        {
            IntPtr eventValuePtr = MetaioSDKUnity.getUnityCallbackEventValue();
            String eventValue    = Marshal.PtrToStringAnsi(eventValuePtr);

//			Debug.Log("Callback event: "+eventID+", "+eventValue);

            switch (eventID)
            {
            case EUNITY_CALLBACK_EVENT.EUCE_LOG:
                onLog(eventValue);
                break;

            case EUNITY_CALLBACK_EVENT.EUCE_LOG_WARNING:
                onLogWarning(eventValue);
                break;

            case EUNITY_CALLBACK_EVENT.EUCE_LOG_ERROR:
                onLogError(eventValue);
                break;

            case EUNITY_CALLBACK_EVENT.EUCE_SDK_READY:
                onSDKReady();
                break;

            case EUNITY_CALLBACK_EVENT.EUCE_TRACKING_EVENT:
                uint   length    = MetaioSDKUnity.getUnityCallbackEventValueLength();
                byte[] pbAsBytes = new byte[length];
                Marshal.Copy(eventValuePtr, pbAsBytes, 0, (int)length);
                metaio.unitycommunication.OnTrackingEventProtocol prot = metaio.unitycommunication.OnTrackingEventProtocol.ParseFrom(pbAsBytes);
                List <TrackingValues> listTV = new List <TrackingValues>();
                for (int i = 0; i < prot.TrackingValuesCount; ++i)
                {
                    listTV.Add(TrackingValues.FromPB(prot.TrackingValuesList[i]));
                }
                onTrackingEvent(listTV);
                break;

            case EUNITY_CALLBACK_EVENT.EUCE_INSTANT_TRACKING_EVENT:
                onInstantTrackingEvent(eventValue);
                break;

            case EUNITY_CALLBACK_EVENT.EUCE_CAMERA_IMAGE_SAVED:
                onCameraImageSaved(eventValue);
                break;

            case EUNITY_CALLBACK_EVENT.EUCE_VISUAL_SEARCH_RESULT:
                parseVisualSearchResponse(eventValue);
                break;

            case EUNITY_CALLBACK_EVENT.EUCE_VISUAL_SEARCH_STATUS:
                onVisualSearchStatusChanged(eventValue);
                break;

            case EUNITY_CALLBACK_EVENT.EUCE_MOVIE_END:
                IntPtr movieTextureGeometryPtr = new IntPtr(int.Parse(eventValue));
                onMovieEnd(metaioMovieTexture.getGameObjectNameForMovieTextureGeometryPtr(movieTextureGeometryPtr));
                break;
            }

            // remove the callback event from queue
            MetaioSDKUnity.removeUnityCallbackEvent();
        }
    }