PlayMaker Updates & Downloads > Share New Actions
Application Open Url Mailto
(1/1)
klvo:
Hi,
This is a modified version of Application Open Url, so that it will only generate a mailto link, with the option to add a Subject and Body text.
It will get rid of the formatting problems that sometimes happen when adding text to fields in Application.OpenURL
I tested only on iOS and the editor, but it should work in any platform where Application.OpenURL is supported.
--- Code: ---// (c) Copyright HutongGames, LLC 2010-2014. All rights reserved.
using UnityEngine;
namespace HutongGames.PlayMaker.Actions
{
[ActionCategory(ActionCategory.Application)]
[Tooltip("Open a Mailto Url link in the browser or email client")]
public class ApplicationOpenUrlMailto : FsmStateAction
{
[Tooltip("Email Address")]
public FsmString inputEmail;
[Tooltip("Subject")]
public FsmString inputSubject;
[Tooltip("Body")]
public FsmString inputBody;
public override void OnEnter()
{
string email = inputEmail.Value;
string theSubject = inputSubject.Value;
string theBody = inputBody.Value;
string subject = MyEscapeURL(theSubject);
string body = MyEscapeURL(theBody);
Application.OpenURL("mailto:" + email + "?subject=" + subject + "&body=" + body);
Finish();
}
string MyEscapeURL (string url)
{
return WWW.EscapeURL(url).Replace("+","%20");
}
}
}
--- End code ---
I hope someone else finds it useful.
Cheers
Dakk:
Jean,
This is really old, but should be added to the EcoSystem- with the small update to UnityWebRequest instead of WWW. Very nice and saved me issues with formatting for mobile.
Thanks,
Dakk
jeanfabre:
Hi,
WWW usage here would still be valid right? it's only to escape chars. or do you hit problem with that?
Bye,
Jean
Navigation
[0] Message Index
Go to full version