To disable a GameObject in C#, you can simply set its active
property to false
. Here's an example:
main.cs147 chars6 lines
In this example, we first find the GameObject we want to disable using the GameObject.Find
method. Then, we call the SetActive
method on the GameObject and pass in false
as the parameter. This will disable the GameObject and make it invisible and inactive in the scene.
gistlibby LogSnag