Created
February 26, 2019 21:38
-
-
Save pinkas/b2f63084375a5a16e88c8d4df68972bd to your computer and use it in GitHub Desktop.
The class name should self explanatory enough
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 System; | |
using UnityEngine; | |
public class MonoBehaviourCachedRectTransform : MonoBehaviour | |
{ | |
[HideInInspector, NonSerialized] | |
private RectTransform rectTransform; | |
public RectTransform RectTransform | |
{ | |
get { return rectTransform != null ? rectTransform : (rectTransform = GetComponent<RectTransform>()); } | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment