Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
public class GenerateMolecule : MonoBehaviour {
public GameObject moleculeParent;
public GameObject moleculeCounter;
public List<GameObject> type = new List<GameObject>();
Text moleculeCounterText;
float intervalTime = 0.5f;
float time;
void Start(){
moleculeCounterText = moleculeCounter.GetComponent<Text>();
void Update(){
void InstantiateMolecules(){
time += Time.deltaTime;
if (time >= intervalTime){
int index = Random.Range(0, type.Count);
GameObject molecule = Instantiate(type[index], moleculeParent.transform.position, Quaternion.identity);
time = 0f;
void SetMoleculeCounterText(){
int moleculeCount = moleculeParent.transform.childCount;
moleculeCounterText.text = "Molecule Count : " + moleculeCount.ToString();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.