Posts

Showing posts with the label GameObject

GameObject.SetActive() v.s. GameObject.active

 GameObject.SetActive() v.s. GameObject.active usage: attribute active of a GameObject checks whether  the GameObject is active or not. method SetActive(bool b) of GameObject  is a method that sets the attribute of GameObject active is b. When you use GameObject.SetActive (false) or GameObject.active=false to deactivate the GameObject, then OnDisable() event will be triggered. After that, the GameObject.active will set to be false and  GameObject will be deactive. When you use GameObject.SetActive(true) or GameObject.active=true to activate the GameObject, then OnEnable() event will be triggered. After that, the GameObject.active will set to be true and  GameObject will be active. I prove it on my script. Unity Version: 2020.3.12f1.590.2 Personal NOTE:  When the GameObject is deactive, you can  NOT  acess it and its compoent including its  BoxCollider , Script which is attcahed to GameObject and transform etc. When the GameObject is deactiv...