| | 1 | | using UnityEngine; |
| | 2 | |
|
| | 3 | | [RequireComponent(typeof(ButtonComponentView))] |
| | 4 | | public class GoToLinkAction : MonoBehaviour |
| | 5 | | { |
| | 6 | | public string urlToGo; |
| | 7 | |
|
| | 8 | | private ButtonComponentView button; |
| | 9 | |
|
| | 10 | | private void Start() |
| | 11 | | { |
| 0 | 12 | | button = GetComponent<ButtonComponentView>(); |
| 0 | 13 | | button.onClick.AddListener(GoToUrl); |
| 0 | 14 | | } |
| | 15 | |
|
| | 16 | | private void OnDestroy() |
| | 17 | | { |
| 6 | 18 | | if (button != null) |
| 0 | 19 | | button.onClick.RemoveAllListeners(); |
| 6 | 20 | | } |
| | 21 | |
|
| | 22 | | internal void GoToUrl() |
| | 23 | | { |
| 0 | 24 | | if (string.IsNullOrEmpty(urlToGo)) |
| 0 | 25 | | return; |
| | 26 | |
|
| 0 | 27 | | Application.OpenURL(urlToGo); |
| 0 | 28 | | } |
| | 29 | | } |