Playmaker Forum
PlayMaker Updates & Downloads => Share New Actions => Topic started by: jeanfabre on April 24, 2012, 01:26:00 AM
-
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.
// (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
-
Jean,
You're a Genuine hero, Thanx!!!
i owe you so much beer if i ever meet you in reallife ;)
-
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.
-
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
-
Hi Jean,
many thanks for your time and clear instructions.
-
tanks man! i was looking for this.....! ;D
-
Thanks Jean, that's a massive help.
-
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.
-
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.
-
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
-
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
-
Exactly what I was looking for! Thanks Jean!
-
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>
-
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
-
well .......
thanks this really made my life easier in our upcoming project !!!
Thanks 8) 8)
-
Any idea of how to get this working for Mac? :)
-craigz
-
Hi,
What url are you trying to reach?
Bye,
Jean
-
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
-
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
-
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
-
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
-
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.
-
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
-
Hi, the action "application open url" doesn't open a new tab in a webgl game.
Any solution to this one? I am using unity 2017.1
thanks
Updated
Fixed it by replacing the last line of code with 'Application.ExternalEval' but this only works in the build version. If you tested it inside the editor, nothing happens.
-
Hi,
It's tricky, but I think this could work: https://github.com/valyard/UnityWebGLOpenLink
Let me know if this work, I'll do a custom action to make easier.
Else, I would actually try to implement a javascript method inside the webpage that hosts the Unity webgl game and from Unity you can talk to that page, then within javascript you can open a new tab. But you need to know how to code for this...
Bye,
Jean
-
Hi,
It's tricky, but I think this could work: https://github.com/valyard/UnityWebGLOpenLink
Let me know if this work, I'll do a custom action to make easier.
Else, I would actually try to implement a javascript method inside the webpage that hosts the Unity webgl game and from Unity you can talk to that page, then within javascript you can open a new tab. But you need to know how to code for this...
Bye,
Jean
My coding skills aren't good, it's quite difficult for me to implement nor understand.
If a custom action is possible, it will be very nice ;D
-
Hi,
ok, I'll work on this. can you bump me early next week? I won't have time this week.
Bye
Jean
-
Bump