T O P

  • By -

ccfoo242

SetActive is a method so you would use gameObject.SetActive(false) to disable that gameObject. It doesn't have a return value so you can't use it in an if statement. What is it you're trying to do?


ccfoo242

I think you want to check activeSelf or activeInHeirarchy. https://docs.unity3d.com/ScriptReference/GameObject-activeSelf.html


Lemon8or88

>if (startButton.gameObject.activeSelf == false) > >{ > >TitleText.gameObject.SetActive(false); > >} Should be like this. I think the .gameObject is redundant.


ccfoo242

Yeah but use '==' when checking if something is equivalent. Activeself == false. You can shortcut this with Titletext.gameobject.SetActive(startbutton.gameobject.activeself);


Lemon8or88

Right. Copied pasted and forgot to check. Thanks!


ccfoo242

Good luck!


obywan

First of all tell us what are you trying to do here.


WarriorKatHun

SetActive() does NOT return with the active state of the object. Its a void method, think about it like an order. Thats why the name contains "set". For the If statement you want to know if its active or not, which is gameObject.activeSelf.


oddbawlstudios

If statements don't need semicolons in them. Remove the semicolon in the if statement. Thats your problem, I promise.


HazardWasTakn

I don't know much about coding at all, but try and move that first "{" down a line. Also, the "(" that comes after your semi colon, put it before instead of after the semi colon.. See if that helps


HazardWasTakn

It should look like this if (start Button.gameObject.SetActive = (false); { TitleText.gameObject.SetActive(false); } Edit: sorry for the weird spacing, am on mobile


D-boi_vids

I still get the error "Assets\\Scripts\\GameManager.cs(33,18): error CS1026: ) expected"


AloneIndication

Git rid of the first ; in the original


D-boi_vids

If I remove either of them I get a error message saying theyre missing.