Reputation: 461
I need to migrate from Parse.com to my own Parse-server. How could I initialize the Parse SDK on my Unity Project passing my server URL? The only editable variables on Unity Editor are ApplicationId
and DotNetKey
. I saw a .Net example where I could pass the serverUrl
on application initialization (see below), but on Unity I could not find this option:
ParseClient.initialize(new ParseClient.Configuration {
ApplicationId = "YOUR_APP_ID",
ClientKey = "YOUR_APP_CLIENT_KEY",
Server = "http://localhost:1337/parse"
});
I found that the Parse.ParseClient
class has a internal HostName
variable. How can I access that by reflection? I tried:
typeOf(ParseClient)
But this returns
unknown type: Parse.ParseClient
Upvotes: 3
Views: 1165
Reputation: 1
The documentation you referenced has a typo. Its ParseClient.Initialize with an upper-case I. If you have the proper #using Parse; in your code, it should not flag an error.
Upvotes: 0
Reputation: 461
************** SOLUTION *****************
public class ParseInitializer : ParseInitializeBehaviour {
[SerializeField] public string hostURL;
public override void Awake() {
var assembly = Assembly.GetAssembly(typeof(ParseInitializeBehaviour));
var type = assembly.GetType("Parse.ParseClient");
var prop = type.GetProperty("HostName", BindingFlags.Static
| BindingFlags.NonPublic);
Uri uri = new Uri(hostURL;);
prop.SetValue(type, uri, null);
var s = (Uri)prop.GetValue(type, null);
base.Awake();
}
}
Upvotes: 1