My search skills must be failing me, or maybe I am asking the wrong question. I have a way in c# to programmatic enforce attached components. For example if I attach a specific script the script will cause an error if a rigid-body is not contented. But I can not seem to remember the syntax.
I think this is what you want. Note the lack of ; .
JScript.Net
@script RequireComponent(Rigidbody)
C#
[RequireComponent (typeof (Rigidbody))]
class PlayerScript : MonoBehaviour {
void FixedUpdate() {
rigidbody.AddForce(Vector3.up);
}
}
Examples from Unity Script Reference.