private Asset GenerateAssetPatch()

in MREUnityRuntimeLib/Assets/AssetLoader.cs [597:698]


		private Asset GenerateAssetPatch(UnityEngine.Object unityAsset, Guid id)
		{
			if (unityAsset is GameObject go)
			{
				int actorCount = 0;
				MWGOTreeWalker.VisitTree(go, _ =>
				{
					actorCount++;
				});

				return new Asset
				{
					Id = id,
					Prefab = new Prefab()
					{
						ActorCount = actorCount
					}
				};
			}
			else if (unityAsset is UnityEngine.Material mat)
			{
				return new Asset()
				{
					Id = id,
					Material = MREAPI.AppsAPI.MaterialPatcher.GeneratePatch(_app, mat)
				};
			}
			else if (unityAsset is UnityEngine.Texture tex)
			{
				return new Asset()
				{
					Id = id,
					Texture = new MWTexture()
					{
						Resolution = new Vector2Patch()
						{
							X = tex.width,
							Y = tex.height
						},
						WrapModeU = tex.wrapModeU,
						WrapModeV = tex.wrapModeV
					}
				};
			}
			else if (unityAsset is UnityEngine.Mesh mesh)
			{
				return new Asset()
				{
					Id = id,
					Mesh = new MWMesh()
					{
						VertexCount = mesh.vertexCount,
						TriangleCount = mesh.triangles.Length / 3,
						BoundingBoxDimensions = new Vector3Patch()
						{
							X = mesh.bounds.size.x,
							Y = mesh.bounds.size.y,
							Z = mesh.bounds.size.z
						},
						BoundingBoxCenter = new Vector3Patch()
						{
							X = mesh.bounds.center.x,
							Y = mesh.bounds.center.y,
							Z = mesh.bounds.center.z
						}
					}
				};
			}
			else if (unityAsset is AudioClip sound)
			{
				return new Asset()
				{
					Id = id,
					Sound = new MWSound()
					{
						Duration = sound.length
					}
				};
			}
			else if (unityAsset is VideoStreamDescription videoStream)
			{
				return new Asset()
				{
					Id = id,
					VideoStream = new MWVideoStream()
					{
						Duration = videoStream.Duration
					}
				};
			}
			else if (unityAsset is AnimationDataCached animData)
			{
				return new Asset()
				{
					Id = id
				};
			}
			else
			{
				throw new Exception($"Asset {id} is not patchable, or not of the right type!");
			}
		}