/// <summary>
		/// Copy material overrides from sourceOutputData to destOutputData, skipping over materials that weren't overridden.
		/// </summary>
		/// <param name="sourceOutputData">Source output data to get the materials from</param>
		/// <param name="destOutputData">Destination output data to assign materials to</param>
		public static void CopyMaterialOverrides(HEU_GeneratedOutputData sourceOutputData, HEU_GeneratedOutputData destOutputData)
		{
			MeshRenderer srcMeshRenderer = sourceOutputData._gameObject != null ? sourceOutputData._gameObject.GetComponent<MeshRenderer>() : null;
			MeshRenderer destMeshRenderer = destOutputData._gameObject != null ? destOutputData._gameObject.GetComponent<MeshRenderer>() : null;
			if (srcMeshRenderer != null && destMeshRenderer != null)
			{
				Material[] srcAssignedMaterials = srcMeshRenderer.sharedMaterials;
				int numSrcAssignedMaterials = srcAssignedMaterials.Length;

				Material[] destAssignedMaterials = destMeshRenderer.sharedMaterials;
				int numDestAssignedMaterials = destAssignedMaterials.Length;

				for (int j = 0; j < numSrcAssignedMaterials; ++j)
				{
					if ((j < sourceOutputData._renderMaterials.Length) && (j < numDestAssignedMaterials))
					{
						if (srcAssignedMaterials[j] != sourceOutputData._renderMaterials[j])
						{
							// Material has been overriden on the source, so assign same material to destination
							destAssignedMaterials[j] = srcAssignedMaterials[j];
						}
					}
				}

				destMeshRenderer.sharedMaterials = destAssignedMaterials;
			}
		}
		/// <summary>
		/// Returns true if checkMaterial is being used by outputData.
		/// </summary>
		/// <param name="checkMaterial">Material to check</param>
		/// <param name="outputData">Output  datato check</param>
		/// <returns>True if output is using checkMaterial</returns>
		public static bool IsOutputDataUsingMaterial(Material checkMaterial, HEU_GeneratedOutputData outputData)
		{
			if(outputData._renderMaterials != null)
			{
				foreach(Material mat in outputData._renderMaterials)
				{
					if(mat == checkMaterial)
					{
						return true;
					}
				}
			}

			if (outputData._gameObject != null)
			{
				MeshRenderer meshRenderer = outputData._gameObject.GetComponent<MeshRenderer>();
				if (meshRenderer != null)
				{
					Material[] inUseMaterials = meshRenderer.sharedMaterials;
					foreach (Material material in inUseMaterials)
					{
						if (checkMaterial == material)
						{
							return true;
						}
					}
				}
			}

			return false;
		}
		/// <summary>
		/// Remove material overrides on given output data, replacing
		/// with the generated materials.
		/// </summary>
		public static void ResetMaterialOverrides(HEU_GeneratedOutputData outputData)
		{
			if(outputData._gameObject == null)
			{
				return;
			}

			MeshRenderer meshRenderer = outputData._gameObject.GetComponent<MeshRenderer>();
			meshRenderer.sharedMaterials = outputData._renderMaterials;
		}
		public static void DestroyGeneratedOutputData(HEU_GeneratedOutputData generatedOutputData, bool bDontDeletePersistantResources)
		{
			// Generated Material references
			HEU_GeneratedOutput.ClearGeneratedMaterialReferences(generatedOutputData);
			
			// Components
			HEU_GeneralUtility.DestroyGeneratedMeshMaterialsLODGroups(generatedOutputData._gameObject, bDontDeletePersistantResources);

			// Gameobject
			HEU_GeneralUtility.DestroyImmediate(generatedOutputData._gameObject);
		}
		/// <summary>
		/// Destroys the Collider components that were generated and stored in outputData.
		/// Specially handles MeshColliders for the contained mesh.
		/// </summary>
		/// <param name="outputData">Contains the generated list of Colliders</param>
		public static void DestroyAllGeneratedColliders(HEU_GeneratedOutputData outputData)
		{
			if (outputData._colliders != null)
			{
				int numExisting = outputData._colliders.Count;
				for (int i = 0; i < numExisting; ++i)
				{
					if (outputData._colliders[i] != null)
					{
						if (outputData._colliders[i].GetType() == typeof(MeshCollider))
						{
							HEU_GeneralUtility.DestroyMeshCollider(outputData._colliders[i] as MeshCollider, true);
						}
						else
						{
							HEU_GeneralUtility.DestroyImmediate(outputData._colliders[i], true);
						}
					}
				}
				outputData._colliders.Clear();
			}
		}
		public static void ClearGeneratedMaterialReferences(HEU_GeneratedOutputData generatedOutputData)
		{
			generatedOutputData._renderMaterials = null;
		}