Beispiel #1
0
    static void OnInitialized(ref PNCallbackResultUnity result, IntPtr context)
    {
        bool success = result.success;

        if (success)
        {
            Debug.Log("Initialized SDK!");
            Instance.mInitialized = true;
        }
        else
        {
            Debug.Log("Failed to initialize SDK!");
            Debug.Log("error message: " + result.msg);
        }
    }
Beispiel #2
0
    private static void OnMapDeleted(ref PNCallbackResultUnity result, IntPtr context)
    {
        GCHandle handle = GCHandle.FromIntPtr(context);
        Action <bool, string> deletedCb = handle.Target as Action <bool, string>;

        bool   deleted  = result.success;
        string errorMsg = result.msg;

        MainThreadTaskQueue.InvokeOnMainThread(() => {
            if (deleted)
            {
                deletedCb(true, "Success");
            }
            else
            {
                deletedCb(true, "Failed to delete, error: " + errorMsg);
            }

            handle.Free();
        });
    }
Beispiel #3
0
    static void OnMapList(ref PNCallbackResultUnity result, IntPtr context)
    {
        GCHandle           handle = GCHandle.FromIntPtr(context);
        Action <MapInfo[]> listCb = handle.Target as Action <MapInfo[]>;

        PNCallbackResultUnity resultClone = result;

        MainThreadTaskQueue.InvokeOnMainThread(() => {
            if (resultClone.success)
            {
                String listJson   = resultClone.msg;
                MapList mapIdList = JsonConvert.DeserializeObject <MapList> (listJson);
                listCb(mapIdList.places);
            }
            else
            {
                Debug.LogError("Failed to fetch map list, error: " + resultClone.msg);
                listCb(null);
            }

            handle.Free();
        });
    }
Beispiel #4
0
    static void OnMapSaved(ref PNCallbackResultUnity result, IntPtr contextPtr)
    {
        GCHandle        handle  = GCHandle.FromIntPtr(contextPtr);
        SaveLoadContext context = handle.Target as SaveLoadContext;
        Action <String> savedCb = context.savedCb;

        PNCallbackResultUnity resultClone = result;

        MainThreadTaskQueue.InvokeOnMainThread(() => {
            if (resultClone.success)
            {
                String mapId = resultClone.msg;
                Debug.Log("Added a record to map db with id " + mapId);
                PNSaveMap(mapId, OnMapUploaded, contextPtr);
                savedCb(mapId);
            }
            else
            {
                Debug.Log(String.Format("Failed to add the map! Error msg: %s", resultClone.msg));
                savedCb(null);
                handle.Free();
            }
        });
    }