Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR CSHARP

unity enable gameobject


 // Drag & Drop the gameobject in the inspector
 public GameObject targetGameObject ;

 public void DisableGameObject()
 {
      targetGameObject.SetActive( false ) ;
 }

 public void EnableGameObject()
 {
      targetGameObject.SetActive( true ) ;
 }

 public void ToggleGameObject()
 {
      if( targetGameObject.activeSelf )
           DisableGameObject() ;
      else
           EnableGameObject();
 }

Source by coders911.org #
 
PREVIOUS NEXT
Tagged: #unity #enable #gameobject
ADD COMMENT
Topic
Name
5+3 =