unity 禁用\啟用\添加\刪除組件的方法


//關閉組件 skills.transform.GetComponent<Rigidbody>().enabled = false;

//禁用與變灰 skills[3].GetComponent<Rigidbody>().interactable = false;

// 動態給對象添加剛體組件 obj.AddComponent<Rigidbody>();

//通過 GetComponent方法獲取組件 obj.GetComponent<Rigidbody>().useGravity = false;

// 銷毀對象綁定的組件或腳本 Destroy(obj.GetComponent<Rigidbody>());

 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM