The meshes in my game are generated at runtime, and I need to add scripts to them when they’re generated. I know how to do this, BUT, I need only ONE of each script to be attached! I don’t know how…It’s probably SO simple…Forgive me…But, Here’s my code:
using UnityEngine;
using System.Collections;
public class GetMapChildren : MonoBehaviour {
public GameObject Map = GameObject.Find("Map");
public ArrayList MapChidren;
//Attach this script to the, "Map", GameObject!!!
//This script gathers all of the Children of GameObject, "Map", and gives them the components required to save their data.
void Update(){
foreach(Transform child in transform){
child.gameObject.AddComponent<StoreMesh>();
child.gameObject.AddComponent<StoreInformation>();
child.gameObject.AddComponent<StoreMaterials>();
}
}
}