Forum General Running PlayerIO in a Unity Editor script

Any issues or discussions relating to Unity development are welcome here.

Running PlayerIO in a Unity Editor script

Postby pressplayer » March 13th, 2013, 12:27 pm

For our game I am making tools for our designers to store things in PlayerIO that can be read back into the game when run. I want to do this in a Unity editor script because this is where our designers work and have access to the things that are stored. But it seems that I cannot use the normal Unity3D Player IO client to do this. When I try to initialize and log in nothing happens. I reckon this is because I need to initialize with a MonoBehaviour - which has to run in a scene that is currently not running as it is in the editor.

I have tried using the normal .NET client in the editor script, but including that will give me a namespace clash as Unity insists on importing both the Unity client and the .NET client for the editor project and both have the same classes.

Any ideas how to approach this?
pressplayer
Paid Member
 
Posts: 6
Joined: March 11th, 2013, 11:14 am

Re: Running PlayerIO in a Unity Editor script

Postby Sumizome » March 13th, 2013, 4:26 pm

You could use a MonoBehaviour - derived class (that contains some functionality) and just create an instance of it and initialize playerIO with it (you could use a button, editor window initialization or whatever to do so).
Sumizome
 
Posts: 10
Joined: February 22nd, 2012, 10:10 pm

Re: Running PlayerIO in a Unity Editor script

Postby pressplayer » March 13th, 2013, 4:38 pm

As stated in the original post, I have tried this. But when I do that and initialize PlayerIO with it and try to connect, I get no callback from the connect call.
pressplayer
Paid Member
 
Posts: 6
Joined: March 11th, 2013, 11:14 am

Re: Running PlayerIO in a Unity Editor script

Postby Sumizome » March 13th, 2013, 4:54 pm

Oh, sorry, my ability to focus is kinda impaired at the moment...
Anyway, I seem to be getting the callback (actually, I just realized I don't get it all the time)

Edit: It seems to fire them off on certain events (mostly if you do anything with the objects in the scene). A hacky method would be to create and immediately destroy a primitive or something at regular intervals and it should fire the delegates.
Sumizome
 
Posts: 10
Joined: February 22nd, 2012, 10:10 pm

Re: Running PlayerIO in a Unity Editor script

Postby pressplayer » March 14th, 2013, 9:12 am

I think it is because the scene is not actually running in the editor, so whatever keeps the PlayerIO code ticking does not run either. What you are saying implies that messing with the scene activates the code for a short while before going dornamt again. Constantly messing with the scene to pump the action is too fragile for my taste unfortunately.

ATM I require my designers to start the scene and copy/paste a key. A brittle process, but it works for now. I have been considering making a console program that I can run from the editor to fire the data up to PlayerIO as this is my best idea for a workaround.
pressplayer
Paid Member
 
Posts: 6
Joined: March 11th, 2013, 11:14 am

Re: Running PlayerIO in a Unity Editor script

Postby Sumizome » March 14th, 2013, 2:24 pm

A console program seems like the best solution. It would be ideal to have it all working from the editor, though.
You mentioned using the .NET client... Did you try using an alias for a dll's namespace? A quick search shows it doesn't really work in Unity as it throws an internal compiler error. There might be some workarounds, though.
Sumizome
 
Posts: 10
Joined: February 22nd, 2012, 10:10 pm


Return to General