playMaker

Author Topic: Application Open Url  (Read 30189 times)

jeanfabre

  • Administrator
  • Hero Member
  • *****
  • Posts: 15563
  • Official Playmaker Support
Application Open Url
« 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.

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
« Last Edit: February 16, 2013, 02:42:57 AM by jeanfabre »

AlanSmithee

  • Playmaker Newbie
  • *
  • Posts: 18
Re: Application Open Url
« Reply #1 on: April 24, 2012, 08:19:20 AM »
Jean,

You're a Genuine hero, Thanx!!!

i owe you so much beer if i ever meet you in reallife ;)

colpolstudios

  • Sr. Member
  • ****
  • Posts: 368
Re: Application Open Url
« Reply #2 on: February 12, 2013, 12:34:48 PM »
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.

jeanfabre

  • Administrator
  • Hero Member
  • *****
  • Posts: 15563
  • Official Playmaker Support
Re: Application Open Url
« Reply #3 on: February 12, 2013, 02: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

colpolstudios

  • Sr. Member
  • ****
  • Posts: 368
Re: Application Open Url
« Reply #4 on: February 13, 2013, 02:44:21 PM »
Hi Jean,

many thanks for your time and clear instructions.




divertoso

  • Playmaker Newbie
  • *
  • Posts: 15
Re: Application Open Url
« Reply #5 on: February 20, 2013, 12:05:49 PM »
tanks man! i was looking for this.....! ;D

drentek

  • Playmaker Newbie
  • *
  • Posts: 11
Re: Application Open Url
« Reply #6 on: February 25, 2013, 07:39:16 PM »
Thanks Jean, that's a massive help.

Kitsunebi

  • Playmaker Newbie
  • *
  • Posts: 7
Re: Application Open Url
« Reply #7 on: April 04, 2013, 10: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.

Kitsunebi

  • Playmaker Newbie
  • *
  • Posts: 7
Re: Application Open Url
« Reply #8 on: April 05, 2013, 09: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.

LAB618

  • Playmaker Newbie
  • *
  • Posts: 23
Re: Application Open Url
« Reply #9 on: January 31, 2015, 11: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

jeanfabre

  • Administrator
  • Hero Member
  • *****
  • Posts: 15563
  • Official Playmaker Support
Re: Application Open Url
« Reply #10 on: February 18, 2015, 10: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

KozTheBoss

  • Full Member
  • ***
  • Posts: 150
  • You dont fail unless you give up trying to succeed
    • Pixel Life - portfolio
Re: Application Open Url
« Reply #11 on: February 25, 2015, 11:42:00 AM »
Exactly what I was looking for! Thanks Jean!
Remember, you don't fail unless you give up trying to succeed!

Naxic

  • Playmaker Newbie
  • *
  • Posts: 2
Re: Application Open Url
« Reply #12 on: April 07, 2015, 06: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>

jeanfabre

  • Administrator
  • Hero Member
  • *****
  • Posts: 15563
  • Official Playmaker Support
Re: Application Open Url
« Reply #13 on: May 28, 2015, 03: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


miketolsa

  • Playmaker Newbie
  • *
  • Posts: 22
  • Just love playmaker !!!
    • 4Buffs Productions
Re: Application Open Url
« Reply #14 on: September 28, 2016, 12:26:47 PM »
well .......

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

Thanks  8) 8)