This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public static class Extensions | |
{ | |
public static int RandomIndex<T>() where T : Enum | |
{ | |
var values = Enum.GetValues(typeof(T)); | |
return new System.Random().Next(values.Length); | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using UnityEngine; | |
public class MonoBehaviourSingletonExample : MonoBehaviour | |
{ | |
public static MonoBehaviourSingletonExample Instance => _instance ?? Initialize(); | |
private static MonoBehaviourSingletonExample _instance; | |
private static MonoBehaviourSingletonExample Initialize() | |
{ | |
var instance = new GameObject(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using UnityEngine; | |
public class ExampleQuit | |
{ | |
public static void Quit() | |
{ | |
#if UNITY_EDITOR | |
UnityEditor.EditorApplication.isPlaying = false; | |
#elif UNITY_WEBGL | |
// Link to the website page where you want to go after clicking the exit button |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System; | |
using System.Collections; | |
using System.Collections.Generic; | |
using System.Threading.Tasks; | |
using UnityEngine; | |
public class UnityMainThreadManager : MonoBehaviour | |
{ | |
private static readonly Queue<Action> executionQueue = new(); | |
private static UnityMainThreadManager _instance; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using UnityEditor; | |
public static class BuildTargetConverter | |
{ | |
public static BuildTarget ToBuildTarget(this BuildTargetGroup buildTargetGroup) | |
{ | |
return buildTargetGroup switch | |
{ | |
BuildTargetGroup.GameCoreXboxOne => BuildTarget.GameCoreXboxOne, | |
BuildTargetGroup.EmbeddedLinux => BuildTarget.EmbeddedLinux, |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
### Unity .gitignore template | |
# This .gitignore file should be placed at the root of your Unity project directory | |
# Unity-specific | |
/[Ll]ibrary/ | |
/[Tt]emp/ | |
/[Oo]bj/ | |
/[Ll]ogs/ | |
/[Uu]ser[Ss]ettings/ |