Advertisement
Guest User

CachedMonoBehaviour

a guest
Sep 16th, 2013
574
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.27 KB | None | 0 0
  1. using UnityEngine;
  2.  
  3. public class CachedMonoBehaviour : MonoBehaviour
  4. {
  5.     protected Rigidbody cachedRigidbody;
  6.  
  7.     public Rigidbody CachedRigidbody {
  8.         get {
  9.             if (cachedRigidbody == null)
  10.                 cachedRigidbody = rigidbody;
  11.             return cachedRigidbody;
  12.         }
  13.     }
  14.  
  15.     protected Collider cachedCollider;
  16.     public Collider CachedCollider {
  17.         get {
  18.             if (cachedCollider == null)
  19.                 cachedCollider = collider;
  20.             return cachedCollider;
  21.         }
  22.     }
  23.    
  24.     protected Transform cachedTransform;
  25.  
  26.     public Transform CachedTransform {
  27.         get {
  28.             if (cachedTransform == null)
  29.                 cachedTransform = transform;
  30.             return cachedTransform;
  31.         }
  32.     }
  33.  
  34.     public Transform ParentCachedTransform {
  35.         get { return CachedTransform.parent; }
  36.         set { CachedTransform.parent = value; }
  37.     }
  38.  
  39.     public Vector3 LocalPosition {
  40.         get { return CachedTransform.localPosition; }
  41.         set { CachedTransform.localPosition = value; }
  42.     }
  43.  
  44.     public Vector3 Position {
  45.         get { return CachedTransform.position; }
  46.         set { CachedTransform.position = value; }
  47.     }
  48.  
  49.     public Quaternion Rotation {
  50.         get { return CachedTransform.rotation; }
  51.         set { CachedTransform.rotation = value; }
  52.     }
  53.  
  54.     public Vector3 LocalScale {
  55.         get { return CachedTransform.localScale; }
  56.         set { CachedTransform.localScale = value; }
  57.     }
  58. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement