- Home /
Question by
unity_UOSiyNV4ixLDIg · May 15, 2018 at 06:14 AM ·
script.image
Image dont show up in the screen
Hello i have made my second level and i use a copy of my first level. In both level i use coins and images the sinalize that coin was taked. In the first level it works fine but in the second level the image dont show up. Everything else works fine menus this. Follow the code:
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
//put a image on screen
public class ImagemKey : MonoBehaviour {
private Collider[] Colisores;
public float TempoDaImagem = 2;
public Image imagem;
// Use this for initialization
void Start () {
imagem.enabled = false;
Colisores = transform.GetComponentsInChildren<Collider>();
}
void OnTriggerEnter()
{
StartCoroutine(EsperarTempo(TempoDaImagem));
}
IEnumerator EsperarTempo(float TempoDaImagem)
{
imagem.enabled = true;
foreach(Collider coll in Colisores)
{
coll.enabled = false;
}
yield return new WaitForSeconds(TempoDaImagem);
imagem.enabled = false;
Destroy(gameObject,TempoDaImagem);
}
}
Comment
Hello there! The code you posted is correct, I don't see any reason why it wouldn't work in a copy of the scene, so the error must be somewhere else.
Are you sure you copied your scene correctly? Have you changed anything else, for example, are the colliders of the coins still marked as trigger, are the scripts still added to the coin objects? It would also be helpful if you described how you made the copy of your first scene.
Your answer
![](https://koobas.hobune.stream/wayback/20220612162700im_/https://answers.unity.com/themes/thub/images/avi.jpg)