Unity-获取同一个脚本下的不同对象

1,同一个脚本挂载在不同的对象上

 1 public class Lesson1 : MonoBehaviour
 2 {
 3     // Start is called before the first frame update
 4 
 5 
 6     //public GameObject Obj1;
 7     public Lesson1 ls1;
 8 
 9     void Start()
10     {
11 
12         print(ls1.gameObject.name);
13 
14     }
15 
16     // Update is called once per frame
17     void Update()
18     {
19         
20     }
21 }

 

posted @ 2021-07-25 19:08  青梨  阅读(243)  评论(0编辑  收藏  举报