Skip to content

Instantly share code, notes, and snippets.

@alchemycs
Last active August 29, 2015 14:08
Show Gist options
  • Save alchemycs/67623a82a50e7eef2b9b to your computer and use it in GitHub Desktop.
Save alchemycs/67623a82a50e7eef2b9b to your computer and use it in GitHub Desktop.
Unity 3D Touchable/Clickable Hyperlinked Objects with 'guiText' Components
/*
* For use with Unity 4.6
*/
using UnityEngine;
using UnityEngine.EventSystems;
using System.Collections;
public class OpenWebLink : MonoBehaviour, IPointerClickHandler {
public string url;
public void Start() {
if (string.IsNullOrEmpty(url)) {
Debug.LogWarning("No URL has been set in the OpenWebLink component, disabling component");
enabled = false;
}
}
public void OnPointerClick(PointerEventData eventData) {
OpenURL();
}
public void OpenURL() {
Application.OpenURL(url);
}
public void OpenURL(string aUrl) {
Application.OpenURL(aUrl);
}
}
@alchemycs
Copy link
Author

The updated class for Unity 4.6 is smaller and also works on any of the new GUI components.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment