Skip to content

Instantly share code, notes, and snippets.

@farukcan
Created February 8, 2022 07:50
Show Gist options
  • Save farukcan/c2e9104d7802d9d3fc72fb8b9333c93a to your computer and use it in GitHub Desktop.
Save farukcan/c2e9104d7802d9d3fc72fb8b9333c93a to your computer and use it in GitHub Desktop.
Run static function when unity game is loaded
// Create a non-MonoBehaviour class which displays
// messages when a game is loaded.
using UnityEngine;
class MyClass
{
[RuntimeInitializeOnLoadMethod]
static void OnRuntimeMethodLoad()
{
Debug.Log("After Scene is loaded and game is running");
}
[RuntimeInitializeOnLoadMethod]
static void OnSecondRuntimeMethodLoad()
{
Debug.Log("SecondMethod After Scene is loaded and game is running.");
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment