Skip to content

Instantly share code, notes, and snippets.

@Quickz
Created April 12, 2020 11:53
Show Gist options
  • Save Quickz/306e06514f3293078d19660e543b5e94 to your computer and use it in GitHub Desktop.
Save Quickz/306e06514f3293078d19660e543b5e94 to your computer and use it in GitHub Desktop.
A simple pattern for catching Camera.main in Unity.
using UnityEngine;
public static class CameraUtility
{
public static Camera MainCamera
{
get
{
if (_mainCamera == null)
{
_mainCamera = Camera.main;
}
return _mainCamera;
}
}
private static Camera _mainCamera;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment