Created
April 12, 2020 11:53
-
-
Save Quickz/306e06514f3293078d19660e543b5e94 to your computer and use it in GitHub Desktop.
A simple pattern for catching Camera.main in Unity.
This file contains hidden or 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 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