- Home /
Can't assign SetActive because it's a "method group".
So I'm trying to make a script that toggles an object on/off based on a trigger. The problem is, when I try to assign the object's default state as SetActive = false, Unity tells me that I can't assign because it's a method group. The weird thing is, I do this very same thing other times in my script with no issue whatsoever. It's just this first instance of SetActive that Unity won't allow. Why is that? And how can I fix it? (To clarify, the issue is in "void Start" with that first SetActive. The other's are all working out.)
using UnityEngine;
using System.Collections;
public class DoorV3 : MonoBehaviour {
private bool IsDisplay = false;
public GameObject DisplayText;
public string Scene;
// Use this for initialization
void Start () {
DisplayText.SetActive = false;
collider.isTrigger = true;
}
// Update is called once per frame
void Update () {
if (IsDisplay == true){
DisplayText.SetActive (true);
if (IsDisplay == false){
DisplayText.SetActive (false);
}
// this makes it so that if you press enter while in the trigger area, you load the level called "AlecsLevel" if there is one.
if (Input.GetKey (KeyCode.Return)){
Application.LoadLevel ("Scene");
}
}
}
void OnTriggerEnter (Collider other) {
if (other.transform.tag == "Player") {
IsDisplay = true;
}
}
void OnTriggerExit (Collider other){
if (other.transform.tag == "Player") {
IsDisplay = false;
}
}
}
Answer by dorpeleg · Feb 01, 2015 at 08:03 AM
You did
DisplayText.SetActive = false;
Instead of
DisplayText.SetActive(false);
Haha yeah, that'd do it! I'm not sure how I didn't catch that. Thanks!
Your answer
Follow this Question
Related Questions
Multiple Cars not working 1 Answer
Distribute terrain in zones 3 Answers
My function doesn't appears in the OnClick button script 5 Answers
Changing enum values with int label 1 Answer