Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System.Collections;
- using System.Collections.Generic;
- using UnityEngine;
- /// <summary>
- /// Utilidades básicas para poder manejar eventos de manera sencilla.
- /// Solamente arrastre el componente al objeto que desea utilizar y llame la
- /// función de la clase que necesite desde un UnityEvent, para mas información
- /// ver (https://docs.unity3d.com/ScriptReference/Events.UnityEvent.html)
- /// </summary>
- public class UtilidadesUI : MonoBehaviour {
- /// <summary>
- /// Al llamar a este evento automaticamente se abre un link en el navegador
- /// del dispositivo.
- /// Puede usarse para mostrar videos de youtube, links de google o del mapa de
- /// google.
- /// </summary>
- /// <param name="url">url a convocar</param>
- public void AbrirLink(string url)
- {
- Application.OpenURL(url);
- }
- /// <summary>
- /// Automaticamente busca un AudioSource en el GameObject y reproduce sonido
- /// en caso de encontrar un AudioSource.
- /// </summary>
- public void ReproducirSonido()
- {
- AudioSource audio = GetComponent<AudioSource>();
- // Si no hay audio entonces no hay nada que hacer.
- if (audio == null)
- return;
- audio.Play();
- }
- /// <summary>
- /// Al convovarlo detiene detiene cualquier sonido que el audio source del
- /// objeto esté reproduciendo.
- /// </summary>
- public void DetenerSonido()
- {
- AudioSource audio = GetComponent<AudioSource>();
- if (audio == null)
- return;
- audio.Stop();
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement