public void CopyLayersTagsComponents(Terrain terrain) /// Copies assigned layers, tags and components from MapMagic object to terrain { //getting MapMagic game object GameObject go = terrain.gameObject; GameObject mmGo = go.transform.parent.parent.gameObject; //copy layer, tag, scripts from mm to terrains if (copyLayersTags) { go.layer = mmGo.layer; go.isStatic = mmGo.isStatic; try { go.tag = mmGo.tag; } catch { Debug.LogError("MapMagic: could not copy object tag"); } } if (copyComponents) { MonoBehaviour[] components = mmGo.GetComponents <MonoBehaviour>(); for (int i = 0; i < components.Length; i++) { if (components[i] is MapMagicObject || components[i] == null) { continue; //if MapMagic itself or script not assigned } if (terrain.gameObject.GetComponent(components[i].GetType()) == null) { ReflectionExtensions.CopyComponent(components[i], go); } } } }