The consequences of disabling a gameObject is that it component on it won’t work on it in the game until you make it active again.
If you want the gameObject to still be active and it script and comonent to still work while it invisble ,just turn invisible, in your class put this code
Easy way
public/private SpriteRenderer sr;
public/private bool visible=true/false;
void Start(){
sr=gameObject.GetComponent();
}
void Update(){
if(visible==true){
sr.enabled=true;
}
if(visible==false){
sr.enabled=false;
}
}
Hard way(if you still want to use the sprite renderer in a way);
public/private SpriteRenderer sr;
public/private bool visible=true/false;
void Start(){
sr=gameObject.GetComponent();
}
void Update(){
if(visible==true){
sr.material.color=new Color(sr.material.color.r,sr.material.color.g,sr.material.color.b,255);
}
if(visible==false){
sr.material.color=new Color(sr.material.color.r,sr.material.color.g,sr.material.color.b,0);
}
}
This only check if it visible and set the sprite to be visible or invisible, you would have to make changing the visible variable part depend on how it will work
Hope this help even if you don’t need it.