Skip to content

Instantly share code, notes, and snippets.

@tsubaki
Last active August 29, 2015 14:23
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save tsubaki/32b120d73c0777387492 to your computer and use it in GitHub Desktop.
Save tsubaki/32b120d73c0777387492 to your computer and use it in GitHub Desktop.
コンポーネントをエディタ側で取得してしまう
using UnityEngine;
[RequireComponent(typeof(Rigidbody))]
[RequireComponent(typeof(SphereCollider))]
public class GetRigidbody : MonoBehaviour {
[SerializeField]
protected Rigidbody rigidbody = null;
[SerializeField]
protected Transform transform = null;
[SerializeField]
protected Collider collider = null;
[SerializeField]
protected Renderer renderer = null;
// Use this for initialization
void Reset () {
rigidbody = GetComponent<Rigidbody>();
transform = GetComponent<Transform>();
collider = GetComponent<Collider>();
renderer = GetComponent<Renderer>();
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment