Playmaker Forum

Playmaker Updates & Downloads => Share New Actions => Topic started by: jeanfabre on April 23, 2012, 10:26:00 PM

Title: Application Open Url
Post by: jeanfabre on April 23, 2012, 10:26:00 PM
Hi,

 Following a post, please find below and also attached to this post a custom action to open a url,

[EDIT] now open a new window when in webplayer.

Code: [Select]
// (c) Copyright HutongGames, LLC 2010-2012. All rights reserved.

using UnityEngine;

namespace HutongGames.PlayMaker.Actions
{
[ActionCategory(ActionCategory.Application)]
[Tooltip("Open a Url link in the browser")]
public class ApplicationOpenUrl : FsmStateAction
{

[RequiredField]
public FsmString url;

[Tooltip("When in webPlayer, will open a new window, define the name of that window here.")]
public FsmString WebWindowTitle;

public override void Reset()
{
url ="";
}

public override void OnEnter()
{
if (Application.isWebPlayer)
{
Application.ExternalEval("window.open('"+url+"','"+WebWindowTitle.Value+"')");
}else{
Application.OpenURL(url.Value);
}
Finish();
}
}
}

Bye,

 Jean
Title: Re: Application Open Url
Post by: AlanSmithee on April 24, 2012, 05:19:20 AM
Jean,

You're a Genuine hero, Thanx!!!

i owe you so much beer if i ever meet you in reallife ;)
Title: Re: Application Open Url
Post by: colpolstudios on February 12, 2013, 10:34:48 AM
Hi jean, what do i do with this c# script ?

Where does it go.

Sorry to be a pain but I require this custom action.
Title: Re: Application Open Url
Post by: jeanfabre on February 12, 2013, 12:54:06 PM
Hi,

 No worries, we are here to help each other :)

basically, you download the cs file attached to this post ( I always copy the content so that you can can quickly learn and study the content, for the ones who are curious).

 you save the file anywhere in the asset folder of your project. Tho I strongly recommand you create a special folder like "PlayMaker Custom Actions" or something, and put all your custom actions in there.

 when a custom action is added to the assets, it's automatically referenced in PlayMaker list of actions, just as if it was an official action, so you simply go and find that new action you added in the actions browser of PlayMaker, and you add it and work with it as usual.

 does that make sense?

Bye,

 Jean
Title: Re: Application Open Url
Post by: colpolstudios on February 13, 2013, 12:44:21 PM
Hi Jean,

many thanks for your time and clear instructions.



Title: Re: Application Open Url
Post by: divertoso on February 20, 2013, 10:05:49 AM
tanks man! i was looking for this.....! ;D
Title: Re: Application Open Url
Post by: drentek on February 25, 2013, 05:39:16 PM
Thanks Jean, that's a massive help.
Title: Re: Application Open Url
Post by: Kitsunebi on April 04, 2013, 07:24:23 PM
Jean,
Great script. It totally worked and opened URL in new window. :)
But it opened as soon as the web player loaded.
I want to be able to click on a game object to have it activate
Is that possible?  Perhaps I forgot to add something extra in fsm beside that script?
Any advice greatly appreciated.
Best
K.
Title: Re: Application Open Url
Post by: Kitsunebi on April 05, 2013, 06:34:28 AM
I figured it out.  In my excitement about the awesome script I put it on the first state rather than the 2nd.  no wonder it opened right away.
Again thanks, Jean for great script!

Best
K.
Title: Re: Application Open Url
Post by: LAB618 on January 31, 2015, 09:01:47 AM
Hello,

I've just updated to Unity 4.6.2 for iOS 64bit compatibility and I now get a complier error from this script, saying:

 error CS 0117: 'UnityEngine.Application' does not contain a definition for 'ExternalEval'

How do I go about fixing this please?

Many thanks
Steve
Title: Re: Application Open Url
Post by: jeanfabre on February 18, 2015, 08:46:54 AM
Hi,

 I have updated the action on the ecosystem. Get it again from there, or simply delete this offensive line, since it only applies when deploying for the WebPlayer.

 Bye,

 Jean
Title: Re: Application Open Url
Post by: KozTheBoss on February 25, 2015, 09:42:00 AM
Exactly what I was looking for! Thanks Jean!
Title: Re: Application Open Url
Post by: Naxic on April 07, 2015, 03:50:19 AM
Is there a version of this that works with Android to open the play store? I was directed from here http://hutonggames.com/playmakerforum/index.php?topic=4003.0 but this says it's Web player only and I get a 404 error when using it. I'm trying to link directly to my app with market://details?id=<com.Zhugs.LavaHop>
Title: Re: Application Open Url
Post by: jeanfabre on May 28, 2015, 12:48:43 AM
Hi,

 I am not sure, I don't own a android device yet. Have you asked on the Unity forum  dedicated section or UA? you'll have good chance to get an answer there

Bye,

 Jean

Title: Re: Application Open Url
Post by: miketolsa on September 28, 2016, 09:26:47 AM
well .......

thanks this really made my life easier in our upcoming project !!!

Thanks  8) 8)
Title: Re: Application Open Url
Post by: craigz on May 01, 2017, 03:50:19 AM
Any idea of how to get this working for Mac? :)

-craigz
Title: Re: Application Open Url
Post by: jeanfabre on May 02, 2017, 01:53:56 AM
Hi,

 What url are you trying to reach?

 Bye,

 Jean
Title: Re: Application Open Url
Post by: craigz on May 02, 2017, 02:34:41 PM
Ah! Clarification!

I've been using this primarily for its application navigation (works fine in windows). I'm trying to open up a specific folder path in Finder. Not sure if it's a OSX limitation though after doing some thread digging?

thanks,

craigz
Title: Re: Application Open Url
Post by: jeanfabre on May 02, 2017, 10:18:13 PM
Hi,

 Windows and mac path use a different delimiter, that's why I think. but really if you are using a url scheme delimiter it should be fine, the other thing is that the url doesn't resolve to a file or folder, and that's likely what's happening I guess.

So what is the exact URL you are inputing?

 Bye,

 Jean
Title: Re: Application Open Url
Post by: craigz on May 02, 2017, 11:10:03 PM
Hmm... so I just ran a test for the delimiter issue, I'm grabbing a custom path on windows and the persistent data path for OSX and it looks like it's using the proper forward slash and does finish past the Application Open Url action, but doesnt actually open the folder in finder at all :/

Working Windows Path:
C:\Users\User\Documents\My Games\warcube\gifs

Failing OSX Path:
/Users/User/Library/Application Support/Haven Made/Warcube/gifs

Any other thoughts? :/

-craigz
Title: Re: Application Open Url
Post by: jeanfabre on May 03, 2017, 01:18:16 AM
Hi,

 yep, that doesn't work for me neither, likely because it's inside the Library folder.

On windows you are on an open folder ( documents), but here you are trying to reach internal stuff, maybe that's the problem.

 Bye,

 Jean
 
Title: Re: Application Open Url
Post by: strongarm27 on October 19, 2018, 12:16:56 PM
I have used this script for years but with the changes to unity in 2017 it no longer works.
Since the web player is no longer supported it gives a error. I always used it in my apps to link to my website. It worked perfectly for that. I never used the web builds I only used it in android and iOS.  Seems OpenUrl should still function if it didn't reference the web build.  Any chance of a update to work with unity 2018.  I am struggling to find a replacement for this.  Thanks for any help you can give.
Title: Re: Application Open Url
Post by: jeanfabre on October 29, 2018, 02:41:23 AM
Hi,

 I just tested and the version available on the ecosystem works for me in 2018.3

 can you get it again? else, what error do you have exactly?

Bye,

 Jean