Unity SDK play & compile errors

HI Dario,

Those NullPointerException messages can be ignored, they are harmless. If you would like to get rid of them completely, make a change in BackendlessPlugin.cs by commenting out the following two lines:

httpEngine.SendRequest<Boolean>(null, null, null, null, null);
httpEngine.SendRequest<Int64>(null, null, null, null, null);

As for this error:

Could you please provide an example of the code that results in the error?

Regards,
Mark

Hi Mark,

Probably I wrote something wrong, I can call methods from AsyncCallback. That’s what I need,

The message only apears when I try to change an GameObject referenced in the code:

But I can resolve calling methods from the class

Thanks again.

Hi Dario,

How about using the Async methods in Backendless with the await keyword? Are you familiar with the syntax?

Regards,
Mark

Hi Mark,

To be honest, no with .NET, Can you provide me a little example?

I’ve used await and async in Javascript, but something tells me that .NET handles this a little bit different.

Thanks

Hi Dario,

Here’s how it works:

  1. Declare the method where you use await with a keyword async.
private async void Start()
  1. When you use Backendless API, every single method has an xxxAsync() version. For example, the Login method you use has this variation: Backendless.UserService.LoginAsync. Here’s how you use it:
var user = await Backendless.UserService.LoginAsync( "user", "wrongPassword" );

Notice, there is no AsyncCallback and the invocation looks like it is blocking. The compiler does some magic when it compiles the code and your code looks a lot simpler.
3. Any code you had in AsyncCallback now can go after the LoginAsync line:

executeSomeFunction( user );

To put it all together, it will look like this:

private async void Start()
{
  var user = await Backendless.UserService.LoginAsync( "user", "wrongPassword" );
  executeSomeFunction( user );
}

I hope this helps.

Mark

Yes it’s very helpful,

Thanks a lot!

Hi Mark

I have another issue: When I use Login with stayLoggedIn = true, I get the error:

UnauthorizedAccessException: Access to the path "/.config" is denied.
06-25 12:35:45.648 25773 25813 E Unity   :   at System.IO.Directory.CreateDirectoriesInternal (System.String path) [0x0004b] in <c79628fadf574d3a8feae0871fad28ef>:0 
06-25 12:35:45.648 25773 25813 E Unity   :   at System.IO.Directory.CreateDirectory (System.String path) [0x00094] in <c79628fadf574d3a8feae0871fad28ef>:0 
06-25 12:35:45.648 25773 25813 E Unity   :   at System.IO.DirectoryInfo.Create () [0x00000] in <c79628fadf574d3a8feae0871fad28ef>:0 
06-25 12:35:45.648 25773 25813 E Unity   :   at (wrapper remoting-invoke-with-check) System.IO.DirectoryInfo.Create()
06-25 12:35:45.648 25773 25813 E Unity   :   at System.IO.Directory.CreateDirectoriesInternal (System.String path) [0x00023] in <c79628fadf574d3a8feae0871fad28ef>:0 
06-25 12:35:45.648 25773 25813 E Unity   :   at System.IO.Directory.CreateDirectory (System.String path) [0x00094] in <c79628fadf574d3a8feae0871fad28ef>:0 
06-25 12:35:45.648 25773 25813 E Unity   :   at System.IO.DirectoryInfo.Create () [0x00000] in <c79628fadf574d3a8feae0871fad28ef>:0 
06-25 12:35:45.648 25773 25813 E Unity   :   at (wrapper remoting-invoke-with-check) System.IO.DirectoryInfo.Create()
06-25 12:35:45.648 25773 25813 E Unity   :   at System.IO.IsolatedStorage.IsolatedStorageFile.PostInit () [0x00035] in <c79628fadf574d3a8feae0871fad28ef>:0 
06-25 12:35:45.648 25773 25813 E Unity   :   at (wrapper remoting-invoke-with-ch

The app have write permissions, I made some test downloading other files, and have no problem:

pathFileSaved :/storage/emulated/0/Android/data/com.xxio.xxio/files/catalogs.wtc

For mobile app, Unity uses:

string fileName = "";
#if UNITY_IPHONE			
	string fileNameBase = Application.dataPath.Substring(0, Application.dataPath.LastIndexOf('/'));
	fileName = fileNameBase.Substring(0, fileNameBase.LastIndexOf('/')) + "/Documents/" + FILE_NAME;
#elif UNITY_ANDROID
	fileName = Application.persistentDataPath + "/" + FILE_NAME ;
#else
	fileName = Application.dataPath + "/" + FILE_NAME;
#endif

fileWriter = File.CreateText(fileName);
fileWriter.WriteLine("Hello world");
fileWriter.Close();

I think this may be help …

Hi Dario,

Could you please create a new support topic for each issue? It makes it easier for us to track it and also helps other users find solutions for similar problems.

Thanks!
Mark

Done!