My game can be played as both online and offline. when i add GameSparksUnity script to my scene it tries to connect automatically. is there any way to control this script to connect when i call a function of this script? is it the only way to add remove script?
Best Answer
J
Jeff Amiel
said
over 6 years ago
Here is what we do.
GameSparksSettings.ApiKey = "whatever";
GameSparksSettings.ApiSecret = "whateverwhatever";
GameSparksSettings.DebugBuild = true;
GameSparksSettings.PreviewBuild = true;
GameObject g = new GameObject("GameSparksService");
var gameSparksComponent = g.AddComponent<GameSparksUnity>();
gameSparksComponent.settings = ScriptableObject.CreateInstance<GameSparksSettings>();
Once that gameobject is created (next frame) - it will start connecting...
GameSparksSettings.ApiKey = "whatever";
GameSparksSettings.ApiSecret = "whateverwhatever";
GameSparksSettings.DebugBuild = true;
GameSparksSettings.PreviewBuild = true;
GameObject g = new GameObject("GameSparksService");
var gameSparksComponent = g.AddComponent<GameSparksUnity>();
gameSparksComponent.settings = ScriptableObject.CreateInstance<GameSparksSettings>();
Once that gameobject is created (next frame) - it will start connecting...
R
Ryan Fuller
said
over 6 years ago
I override the start method in GameSparksUnity, and manually call base.Start() when I want to connect. This method is annoying because every time the API is updated, I have to re-add "protected virtual" to the start method.
I think they should add a checkbox like "Connect on Start" to the class that we can uncheck in the inspector, and add a connect/initialize method we can call manually.
1 person likes this
D
Dylan Hunt
said
over 4 years ago
I just ran into the same issue -- that would definitely be nice to have. Although 2 years old, it's the only search result that came up.
D
Dylan Hunt
said
over 4 years ago
I replaced the Start() contents with public void GSInit() that I can call from a 3rd party script when ready. This seemingly HAS to be done to work with a nonce-style auth system.
Ufuk Coban
My game can be played as both online and offline. when i add GameSparksUnity script to my scene it tries to connect automatically. is there any way to control this script to connect when i call a function of this script? is it the only way to add remove script?
Here is what we do.
Once that gameobject is created (next frame) - it will start connecting...
- Oldest First
- Popular
- Newest First
Sorted by Oldest FirstJeff Amiel
Here is what we do.
Once that gameobject is created (next frame) - it will start connecting...
Ryan Fuller
I override the start method in GameSparksUnity, and manually call base.Start() when I want to connect. This method is annoying because every time the API is updated, I have to re-add "protected virtual" to the start method.
I think they should add a checkbox like "Connect on Start" to the class that we can uncheck in the inspector, and add a connect/initialize method we can call manually.
1 person likes this
Dylan Hunt
I just ran into the same issue -- that would definitely be nice to have. Although 2 years old, it's the only search result that came up.
Dylan Hunt
I replaced the Start() contents with public void GSInit() that I can call from a 3rd party script when ready. This seemingly HAS to be done to work with a nonce-style auth system.
-
Documentation Notes
-
Design issues with user events
-
Using NoSQL
-
Runtime Collections vs Metadata Collections
-
Anonymous authentication from browser app
-
Modules
-
Movement With Unity
-
Problem with url parameters for downloadables
-
Querying NoSql GameSparks database
-
Challenge accesType
See all 2487 topics