2

Is there a way to pass a parameter to a running game by starting it again?

For a 'normal' application I could do something like this.

Does Unity have a feature to allow notification of another instance being started with parameters?

Community
  • 1
  • 1
Dawnkeeper
  • 2,844
  • 1
  • 25
  • 41

2 Answers2

2

No "built-in solution" for that. What you can do is:
a) Set up your game so it can run in one instance only (Edit -> Project Settings -> Player)

Forced Single Instance in Unity 5



-or-
b) As soon as you start, read a Player Setting, let's say a bool called "Running". If true, check if your app really is running with GetProcessesByName (if it doesn't, your app hang up before). If it's "false", set it to "true" (and back to false when one quits the game)



As of "passing a value", that works with "b" option only obviously. I would also use Player Settings for that:
if game is already running, write a value (e.g. under an "inputparam" key) and quit. Otherwise run (i.e. keep running) and check this setting's value every now and then, every frame or once a minute, whenever, depending on how critical it is for you to get the input value.


Edit after a long while and some testing:
GetProcessesByName has proven to be quite unreliable with the unity. I ended up writing to the PlayerPref on startup and checking for that value.

Dawnkeeper
  • 2,844
  • 1
  • 25
  • 41
1

People in their review of the Google Sheets game asset say that they can modify a game at runtime.

Great dev, and asset works at runtime! ... Super fast response and documentation update. Couldn't ask for more. Crucially works at runtime...

Chuck Savage
  • 11,775
  • 6
  • 49
  • 69