[Unity] Useful Functions

Keyboard Shortcuts

Double click + drag: Move camera in parallel directions

Enable GameObject/Component

GameObject someObject;

someObject.SetActive(true);
someObject.GetComponent<Rigidbody>().enabled(true);

Display Text Using TextMeshPro

using TMPro;
using 

public TextMeshProUGUI dialogueBox;
dialogueBox.text = “Hello World”;

Play AudioSource

public AudioSource audioSource;

audioSource.Play();
audioSource.Pause();
audioSource.PlayOneShot(audioSource.clip);

Load Scene

UnityEngine.SceneManagement;

SceneManager.LoadScene(0);

Use Coroutine

StartCoroutine(“MyCoroutine”);
IEnumerator MyCoroutine() 
{
    Debug.Log(“Hello”);
    yield return new WaitForSecond(2f);
    Debug.Log(“World”);
}

Scroll to Top