GetComponent

GetComponent 的几种写法:
1、AutoRotation cmp1=(AutoRotation) GetComponent(typeof(AutoRotation));

2、AutoRotation cmp2=(AutoRotation) GetComponent("AutoRotation");

3、AutoRotation cmp3= GetComponent<AutoRotation>();
原文地址:https://www.cnblogs.com/zhaoqingqing/p/3553224.html