0

I wanted to use pop-up type of notification in my project. It was supposed to be hidden on the start, but show up when button is clicked.

So at first I tried .SetActive(bool) method, then .enabled = bool. Both times it turned out to delete/destroy my raw image at the very beginning of the project run. Below I provide you a snippet of my code:

void Start()
{
    Notif.enabled = false;
}
private void Outcome()
{
    Notif.enabled = true;
}
KiynL
  • 4,097
  • 2
  • 16
  • 34
  • what type is `Notif`? Does it still happen if you remove your `Start` method (=> not related to this code at all but happening somewhere else) – derHugo Mar 13 '23 at 11:34
  • @derHugo well, it was raw image but I decided to change it to just image. The issues still occur – InProgress GameDev Mar 13 '23 at 16:13
  • I suggest you put a component like the following on your object `public class DestroyLog : MonoBehaviour { pivate void OnDestroy() { Debug.LogError("OH NO!", this); } }` .. click on the logged error message and check the stack trace .. it will tell you what exactly caused the deletion of that object – derHugo Mar 13 '23 at 17:15
  • If "Notif" is an Image component and you set the 'enabled = false' that means the image component will be disabled and not the whole gameobject. – Pavlos Mavris Mar 14 '23 at 08:01

0 Answers0