logo
  • 教程列表
  • SO官方文檔
  • 查詢和收集 GameObjects
    • 按 GameObjects 名稱搜尋
    • 按 GameObjects 標籤搜尋
    • 通過 MonoBehaviour 指令碼查詢 GameObjects
    • 在編輯模式下插入指令碼
    • 從子物件中按名稱查詢 GameObjects
  1. StackOverflow 文件
  2. unity3d 教程
  3. 查詢和收集 GameObjects
  4. 從子物件中按名稱查詢 GameObjects

從子物件中按名稱查詢 GameObjects

Created: November-22, 2018

Transform tr = GetComponent<Transform>().Find("NameOfTheObject");
GameObject go = tr.gameObject;

如果沒有找到,Find 將返回 null

優點 缺點
搜尋範圍有限,定義明確 字串是弱引用
  • 在編輯模式下插入指令碼

Copyright © 2018. All right reserved

tastones.com 备案号:鲁ICP备18045372号-1

  • 關於本站
  • 免責聲明