Answer the question
In order to leave comments, you need to log in
Accidentally activating a GameObject in Unity?
Good day!
I can not understand where the script activation error is made.
There are 6 GO (GameObject) one of which should become active (initially all are inactive) by pressing the button.
Script
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
public class RNDElem : MonoBehaviour
{
public GameObject Air;
public GameObject Water;
public GameObject Ligth;
public GameObject Fire;
public GameObject Earth;
public GameObject Darkness;
public void ActivateRandomObject(GameObject[] arrayOfGameObjects)
{
arrayOfGameObjects[Random.Range(0, arrayOfGameObjects.Length - 1)].SetActive(true);
}
}
Answer the question
In order to leave comments, you need to log in
Well, and the method is called somewhere? It is necessary to debug - the script is correct at first glance
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question