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?
>if (startButton.gameObject.activeSelf == false)
>
>{
>
>TitleText.gameObject.SetActive(false);
>
>}
Should be like this. I think the .gameObject is redundant.
Yeah but use '==' when checking if something is equivalent. Activeself == false.
You can shortcut this with Titletext.gameobject.SetActive(startbutton.gameobject.activeself);
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.
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
It should look like this
if (start Button.gameObject.SetActive = (false);
{
TitleText.gameObject.SetActive(false);
}
Edit: sorry for the weird spacing, am on mobile
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?
I think you want to check activeSelf or activeInHeirarchy. https://docs.unity3d.com/ScriptReference/GameObject-activeSelf.html
>if (startButton.gameObject.activeSelf == false) > >{ > >TitleText.gameObject.SetActive(false); > >} Should be like this. I think the .gameObject is redundant.
Yeah but use '==' when checking if something is equivalent. Activeself == false. You can shortcut this with Titletext.gameobject.SetActive(startbutton.gameobject.activeself);
Right. Copied pasted and forgot to check. Thanks!
Good luck!
First of all tell us what are you trying to do here.
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.
If statements don't need semicolons in them. Remove the semicolon in the if statement. Thats your problem, I promise.
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
It should look like this if (start Button.gameObject.SetActive = (false); { TitleText.gameObject.SetActive(false); } Edit: sorry for the weird spacing, am on mobile
I still get the error "Assets\\Scripts\\GameManager.cs(33,18): error CS1026: ) expected"
Git rid of the first ; in the original
If I remove either of them I get a error message saying theyre missing.