I need to handle a URI protocol in my game.
I thought i was doing everything correct. However i got feedback that if my game has not already been started the game just hangs at the splash screen.
I figure i must not be starting Unity properly in my onactivated call. Actually i figured that i would get an Onlaunch before the onactivated and unity would be started but this does not appear to be the case.
how can i properly start my game from a non-executing state when i receive the OnActivated message?
Thank you kindly.
I think that’s a known bug and was fixed in upcomming 4.5.
Aurimas Cernius,
Any relief for me prior to 4.5? as i need to pass MS certification. And i really don’t mind passing the buck on to your team and linking to this thread where you say it is a unity bug, however MS might not accept that.
Well, the good news are that the fix for this bug is in template, so you have to modify the App.xaml.cs file (or App.xaml.cpp, if you’re using C++ project). Here is excerpt from out current template:
/// <summary>
/// Invoked when application is launched through protocol.
/// Read more - [url]http://msdn.microsoft.com/library/windows/apps/br224742[/url]
/// </summary>
/// <param name="args"></param>
protected override void OnActivated(IActivatedEventArgs args)
{
string appArgs = "";
Windows.ApplicationModel.Activation.SplashScreen splashScreen = null;
switch (args.Kind)
{
case ActivationKind.Protocol:
ProtocolActivatedEventArgs eventArgs = args as ProtocolActivatedEventArgs;
splashScreen = eventArgs.SplashScreen;
appArgs += string.Format("Uri={0}", eventArgs.Uri.AbsoluteUri);
break;
}
InitializeUnity(appArgs, splashScreen);
}
/// <summary>
/// Invoked when application is launched via file
/// Read more - [url]http://msdn.microsoft.com/library/windows/apps/br224742[/url]
/// </summary>
/// <param name="args"></param>
protected override void OnFileActivated(FileActivatedEventArgs args)
{
string appArgs = "";
Windows.ApplicationModel.Activation.SplashScreen splashScreen = null;
splashScreen = args.SplashScreen;
appArgs += "File=";
bool firstFileAdded = false;
foreach (var file in args.Files)
{
if (firstFileAdded) appArgs += ";";
appArgs += file.Path;
firstFileAdded = true;
}
InitializeUnity(appArgs, splashScreen);
}
/// <summary>
/// Invoked when the application is launched normally by the end user. Other entry points
/// will be used when the application is launched to open a specific file, to display
/// search results, and so forth.
/// </summary>
/// <param name="args">Details about the launch request and process.</param>
protected override void OnLaunched(LaunchActivatedEventArgs args)
{
InitializeUnity(args.Arguments, args.SplashScreen);
}
Aurimas Cernius,
god bless you. you are my savior.