Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using UnityEngine;
- public class CachedMonoBehaviour : MonoBehaviour
- {
- protected Rigidbody cachedRigidbody;
- public Rigidbody CachedRigidbody {
- get {
- if (cachedRigidbody == null)
- cachedRigidbody = rigidbody;
- return cachedRigidbody;
- }
- }
- protected Collider cachedCollider;
- public Collider CachedCollider {
- get {
- if (cachedCollider == null)
- cachedCollider = collider;
- return cachedCollider;
- }
- }
- protected Transform cachedTransform;
- public Transform CachedTransform {
- get {
- if (cachedTransform == null)
- cachedTransform = transform;
- return cachedTransform;
- }
- }
- public Transform ParentCachedTransform {
- get { return CachedTransform.parent; }
- set { CachedTransform.parent = value; }
- }
- public Vector3 LocalPosition {
- get { return CachedTransform.localPosition; }
- set { CachedTransform.localPosition = value; }
- }
- public Vector3 Position {
- get { return CachedTransform.position; }
- set { CachedTransform.position = value; }
- }
- public Quaternion Rotation {
- get { return CachedTransform.rotation; }
- set { CachedTransform.rotation = value; }
- }
- public Vector3 LocalScale {
- get { return CachedTransform.localScale; }
- set { CachedTransform.localScale = value; }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement