예제 #1
0
		/// <summary>
		/// Returns HEU_UploadMeshData with mesh data found on meshGameObject.
		/// </summary>
		/// <param name="meshGameObject">The GameObject to query mesh data from</param>
		/// <returns>A valid HEU_UploadMeshData if mesh data found or null</returns>
		public static HEU_UploadMeshData CreateSingleMeshData(GameObject meshGameObject)
		{
			HEU_UploadMeshData meshData = new HEU_UploadMeshData();

			MeshFilter meshfilter = meshGameObject.GetComponent<MeshFilter>();
			if (meshfilter == null)
			{
				return null;
			}

			if (meshfilter.sharedMesh == null)
			{
				return null;
			}
			meshData._mesh = meshfilter.sharedMesh;
			meshData._numVertices = meshData._mesh.vertexCount;
			meshData._numSubMeshes = meshData._mesh.subMeshCount;

			meshData._meshName = meshGameObject.name;

			meshData._meshPath = HEU_AssetDatabase.GetAssetOrScenePath(meshGameObject);
			if (string.IsNullOrEmpty(meshData._meshPath))
			{
				meshData._meshPath = meshGameObject.name;
			}

			MeshRenderer meshRenderer = meshGameObject.GetComponent<MeshRenderer>();
			if (meshRenderer != null)
			{
				meshData._materials = meshRenderer.sharedMaterials;
			}

			return meshData;
		}
예제 #2
0
		/// <summary>
		/// Generate list of HEU_UploadMeshData with data from meshes found on and under inputObject.
		/// If inputObject is a LODGroup, this will create mesh data for each LOD mesh under it.
		/// Otherwise a single HEU_UploadMeshData is returned in the list.
		/// </summary>
		/// <param name="inputObject">The GameObject to query mesh data from</param>
		/// <param name="bHasLODGroup">Set whether LOD group was found</param>
		/// <returns>List of HEU_UploadMeshData</returns>
		public static List<HEU_UploadMeshData> GenerateMeshDatasFromInputObject(GameObject inputObject, out bool bHasLODGroup)
		{
			List<HEU_UploadMeshData> meshDatas = new List<HEU_UploadMeshData>();

			bHasLODGroup = false;

			LODGroup lodGroup = inputObject.GetComponent<LODGroup>();
			if (lodGroup != null)
			{
				bHasLODGroup = true;

				LOD[] lods = lodGroup.GetLODs();
				for (int i = 0; i < lods.Length; ++i)
				{
					if (lods[i].renderers != null && lods[i].renderers.Length > 0)
					{
						GameObject childGO = lods[i].renderers[0].gameObject;
						HEU_UploadMeshData meshData = CreateSingleMeshData(childGO);
						if (meshData != null)
						{
							meshData._LODScreenTransition = lods[i].screenRelativeTransitionHeight;
							meshDatas.Add(meshData);
						}
					}
				}
			}
			else
			{
				HEU_UploadMeshData meshData = CreateSingleMeshData(inputObject);
				if (meshData != null)
				{
					meshDatas.Add(meshData);
				}
			}

			return meshDatas;
		}