简体   繁体   中英

Parse & PubNub in Unity

I am having the problem that Parse and PubNub SDK cannot work in the same project.

The problem I have is both SDKs seems to have System.Threading in their DLL file. So I will get the following error

error CS0433: The imported type System.Threading.Tasks.Task 1' is defined multiple times

I use the latest Parse Unity SDK and PubNub example project here https://github.com/pubnub/c-sharp/tree/master/unity

Anyone has the same issue and how could you resolve it?

Parse has their own "Task" class which clashes with the "Task" class in System.Threading.dll.

There are 2 ways to resolve the issue:

  • You can either use the beta version of PubNub's Unity SDK from here (link to beta is in the read me). This version removes the dependency on System.Threading.dll.

  • Or use var saveTask = gameScore.SaveAsync (); instead of: Task saveTask = gameScore.SaveAsync (); in the version you are using.

Another Example:

using UnityEngine;
using System.Collections;
using Parse;
using System.Threading;
using System.Collections.Generic;
using System;
using PubNubMessaging.Core;
using System.Threading.Tasks;
public class NewBehaviourScript : MonoBehaviour {
    public void OnGUI (){
        SignUpNewUser ();
    }
    public void SignUpNewUser (){
        var returnTask = ParseUser.LogInAsync  ( login, password    ).ContinueWith (t => {
            return ParseUser.Query.FindAsync ();
        });
        returnTask.Unwrap();
    }
}

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM