Unity/.net: cry for help

HI there,
(be gentle - relative newbie)…

I was wondering if anyone could help me get the Unity SDK up and running. I’m encountering the problem described here : https://github.com/parse-community/Parse-SDK-dotNET/issues/307

I think that the solution described in the main .net sdk readme describes steps that will mitigate against this, but I’m really struggling to understand exactly how to implement them.

Specifically this section :

new ParseClient(/* Parameters */,
    new LateInitializedMutableServiceHub { },
    new MetadataMutator
    {
        EnvironmentData = new EnvironmentData { OSVersion = SystemInfo.operatingSystem, Platform = $"Unity {Application.unityVersion} on {SystemInfo.operatingSystemFamily}", TimeZone = TimeZoneInfo.Local.StandardName },
        HostManifestData = new HostManifestData { Name = Application.productName, Identifier = Application.productName, ShortVersion = Application.version, Version = Application.version }
    },
    new AbsoluteCacheLocationMutator
    {
        CustomAbsoluteCacheFilePath = $"{Application.persistentDataPath.Replace('/', Path.DirectorySeparatorChar)}{Path.DirectorySeparatorChar}Parse.cache"
    }
    ).Publicize();

If anyone is able to help, perhaps sharing sample code that does connect that I can learn from, I’d hugely appreciate it!

Many thanks in advance!

Hi @iainsimons,
seeing the mutator classes I assume you are using the 2.0.0 develop version of the SDK?
Which Unity version are you using, what platform are us targeting and running on and what exactly is your problem you have?

I doubt that your issue is related to the linked issue on the github repo, as that issue refers to an older SDK version which used a different approach to support Unity (using additional plugin assembly files).

You may take a look at https://github.com/TheFanatr/Parse-SDK-Demonstrations where alex has posted some example/demonstration projects based on the 2.0.0 develop version. They include a Unity project too.

Can you elaborate what you are already trying and what your code looks like?
The quoted code is incomplete and does not do anything beside initialising the ParseSDK on your local device (or Unity editor) it does not perform any communication with a server yet.

You need to provide the parameters for your parse server (e.g. hosted on heroku, back4app or other backend-as-a-service-providers) and perform some call to the server (e.g. login user, logout, save object etc.) to actually determine if its working or not and what problems might exist.

As you asked for kindness, don’t take anything personally =).
You simply provided very little information about what you already did or tried and what prerequisites you already covered (e.g. having a parse server instance up and running somewhere).
It is good you asked and I’m happy to help you getting started (I used up quite some time to get it running inside Unity when I first used Parse ;D)

Kind regards
Tobias

Hi Tobias!

Thanks for the generous reply, and thanks for the support.
Apologies for not giving some more useful context - I’ll try and do so now :slight_smile:

As mentioned, I’m right at the starting gate with Parse, having been experimenting a little with Firebase and Backendless - with varying results - Parse looked like a great option for our project.

I’ve actually made a little progress since the first post, having identified a fork of the SDK here : https://github.com/fayezsalka/Parse-for-Unity-2018 which appears to connect fine. Following through the parse unity docs (https://docs.parseplatform.org/unity/guide/#the-parseobject) I’m able to add a class, but already seem to be unable to retrieve.

I’m using Unity 2019.04.0f1 , building to iOS.
and parse server 3.1.3 hosted on Sashido.

I was using the 1.70 SDK at the time of writing, should I actually be using 2.0.0? That might explain a lot… :slight_smile: Following the onboarding process from Sashido, that directs to 1.70 so I just assumed that was the one to use…

Ultimately what I’m trying to achieve is to connect to Parse, to be able to send out push notifications to trigger the client to download a JSON string used to update the live game. I had this all running fine in Backendless, but Parse appears to scale slightly more economically for I want to do and I’d drawn to a more open solution.

Thanks so much again for your patience!

-I

OKAY! PROGRESS :slight_smile:

ahem - I am embarrassed to report that now I’m using the 2.0.0 SDK, it all works (mostly) fine…

using this code to connect in the Start method

new ParseClient(<credentials>, new LateInitializedMutableServiceHub { }, new MetadataMutator { EnvironmentData = new EnvironmentData { OSVersion = SystemInfo.operatingSystem, Platform = $"Unity {Application.unityVersion} on {SystemInfo.operatingSystemFamily}", TimeZone = TimeZoneInfo.Local.StandardName }, HostManifestData = new HostManifestData { Name = Application.productName, Identifier = Application.productName, ShortVersion = Application.version, Version = Application.version } }, new AbsoluteCacheLocationMutator { CustomAbsoluteCacheFilePath = $"{Application.persistentDataPath.Replace('/', Path.DirectorySeparatorChar)}{Path.DirectorySeparatorChar}Parse.cache" }).Publicize();

I’m than able to add objects using code from the documentation :

public void addScore(){

ParseObject gameScore = new ParseObject("gameScore");

gameScore["score"] = 1337;

gameScore["playerName"] = "Sean";

Task saveTask = gameScore.SaveAsync();

}

But then I find that the retrieve code throws up this error :

‘ParseObject’ does not contain a definition for ‘GetQuery’

from this -

 public void getScore(){

ParseQuery<ParseObject> query = ParseObject.GetQuery("gameScore");

query.GetAsync("iMUH1bfpN8").ContinueWith(t =>

{

ParseObject gameResult = t.Result;

});

}

Am I missing something obvious again…?

ahem…

another update :

So, I now have the retrieve working, but I’m not 100% sure why

This code works :

public async void getScore(){

ParseQuery<ParseObject> query = ParseClient.Instance.GetQuery("gameScore");
query.GetAsync("PR2cDGzxrG").ContinueWith(t =>
{
    ParseObject gameResult = t.Result;
    string playerName = gameResult.Get<string>("playerName");
    Debug.Log(playerName);
});

}

If you have a moment to point me as to why, I’d be further indebted :slight_smile:

Hi @iainsimons,

I’m sorry that you encountered a confusing situation.
Unfortunately we have a little few people working on the repository and we haven’t updated the guides for the new version.
Several methods and constructors and where to find them have changed and most of them now relate to the ParseClient class and the instance you are using in your app (e.g. the one you’ve created above in your Start method and registered by calling the “Publicize()” method on).
This may seem confusing at first, especially in contrast to the older version and the guide (which refers to 1.7.0) but allows the new version alex (TheFanatr on GitHub) has implemented to provide more than one ParseClient instance and thus your app to utilise either multiple Parse server instances or multiple connections to the same one to perform different tasks or receive different/separated data.
All of this may not be required when getting started but make it a bit cumbersome to adopt the old guide to the new SDK.

Back to your question: The ParseClient.Instance.GetQuery("YourClassName") is the same as the previously using ParseObject.GetQuery(..)or new ParseQuery(..) it only is relocated as the underlying code requires an instance of ParseClient to work (now that there can be more than one and it is not clear which it should or can use for your queries).

So to be more precise, you actually converted the example from the guide to it’s counterpart for version 2.0.0, all by yourself =) Nothing wrong with it and exactly what is required to perform the query.

If you are somewhat familiar with inheritance or writing your own classes you may want to try to use your own classes derived from ParseObject (the guide on that should be helpful on how to do it). Doing so should allow you to avoid using those nasty plain-strings for accessing your data and prevent you from errors due to typos and such =).

I’m happy you got it working by yourself and glad to help you with any further questions you may have.
Feel free to ask (or create an issue on the repo or a new thread here on the forums if necessary).

Cheers
Tobias