mirror of
				https://github.com/maxartz15/VertexAnimation.git
				synced 2025-10-31 08:35:50 +01:00 
			
		
		
		
	Include inactive meshes.
Option to include inactive meshes.
This commit is contained in:
		| @@ -28,9 +28,10 @@ namespace TAO.VertexAnimation.Editor | |||||||
| 		{ | 		{ | ||||||
| 			EditorGUILayout.PropertyField(serializedObject.FindProperty("model")); | 			EditorGUILayout.PropertyField(serializedObject.FindProperty("model")); | ||||||
| 			EditorGUILayout.PropertyField(serializedObject.FindProperty("animationClips")); | 			EditorGUILayout.PropertyField(serializedObject.FindProperty("animationClips")); | ||||||
| 			EditorGUILayout.PropertyField(serializedObject.FindProperty("applyRootMotion")); |  | ||||||
| 			EditorGUILayout.PropertyField(serializedObject.FindProperty("fps")); | 			EditorGUILayout.PropertyField(serializedObject.FindProperty("fps")); | ||||||
| 			EditorGUILayout.PropertyField(serializedObject.FindProperty("textureWidth")); | 			EditorGUILayout.PropertyField(serializedObject.FindProperty("textureWidth")); | ||||||
|  | 			EditorGUILayout.PropertyField(serializedObject.FindProperty("applyRootMotion")); | ||||||
|  | 			EditorGUILayout.PropertyField(serializedObject.FindProperty("includeInactive")); | ||||||
| 		} | 		} | ||||||
|  |  | ||||||
| 		private void BakeGUI() | 		private void BakeGUI() | ||||||
|   | |||||||
| @@ -12,10 +12,11 @@ namespace TAO.VertexAnimation.Editor | |||||||
| 		// Input. | 		// Input. | ||||||
| 		public GameObject model; | 		public GameObject model; | ||||||
| 		public AnimationClip[] animationClips; | 		public AnimationClip[] animationClips; | ||||||
| 		public bool applyRootMotion = false; |  | ||||||
| 		[Range(1, 60)] | 		[Range(1, 60)] | ||||||
| 		public int fps = 24; | 		public int fps = 24; | ||||||
| 		public int textureWidth = 512; | 		public int textureWidth = 512; | ||||||
|  | 		public bool applyRootMotion = false; | ||||||
|  | 		public bool includeInactive = false; | ||||||
| 	 | 	 | ||||||
| 		public LODSettings lodSettings = new LODSettings(); | 		public LODSettings lodSettings = new LODSettings(); | ||||||
| 		public bool generateAnimationBook = true; | 		public bool generateAnimationBook = true; | ||||||
| @@ -97,7 +98,7 @@ namespace TAO.VertexAnimation.Editor | |||||||
| 			var target = Instantiate(model); | 			var target = Instantiate(model); | ||||||
| 			target.name = model.name; | 			target.name = model.name; | ||||||
|  |  | ||||||
| 			target.ConbineAndConvertGameObject(); | 			target.ConbineAndConvertGameObject(includeInactive); | ||||||
| 			AnimationBaker.BakedData bakedData = target.Bake(animationClips, applyRootMotion, fps, textureWidth); | 			AnimationBaker.BakedData bakedData = target.Bake(animationClips, applyRootMotion, fps, textureWidth); | ||||||
|  |  | ||||||
| 			positionMap = VA_Texture2DArrayUtils.CreateTextureArray(bakedData.positionMaps.ToArray(), false, true, TextureWrapMode.Repeat, FilterMode.Point, 1, string.Format("{0}_PositionMap", name), true); | 			positionMap = VA_Texture2DArrayUtils.CreateTextureArray(bakedData.positionMaps.ToArray(), false, true, TextureWrapMode.Repeat, FilterMode.Point, 1, string.Format("{0}_PositionMap", name), true); | ||||||
|   | |||||||
| @@ -225,19 +225,27 @@ namespace TAO.VertexAnimation | |||||||
| 			return target; | 			return target; | ||||||
| 		} | 		} | ||||||
|  |  | ||||||
| 		public static void ConbineAndConvertGameObject(this GameObject gameObject) | 		public static void ConbineAndConvertGameObject(this GameObject gameObject, bool includeInactive = false) | ||||||
| 		{ | 		{ | ||||||
| 			// Get Skinned Meshes. | 			// Get Skinned Meshes. | ||||||
| 			List<SkinnedMeshRenderer> skinnedMeshes = gameObject.GetComponentsInChildren<SkinnedMeshRenderer>(true).ToList(); | 			List<SkinnedMeshRenderer> skinnedMeshes = new List<SkinnedMeshRenderer>(); | ||||||
|  | 			gameObject.GetComponentsInChildren(includeInactive, skinnedMeshes); | ||||||
|  |  | ||||||
|  | 			List<MeshFilter> meshFilters = new List<MeshFilter>(); | ||||||
|  | 			gameObject.GetComponentsInChildren(includeInactive, meshFilters); | ||||||
|  |  | ||||||
| 			// Get Meshes. | 			// Get Meshes. | ||||||
| 			List<(MeshFilter, MeshRenderer)> meshes = new List<(MeshFilter, MeshRenderer)>(); | 			List<(MeshFilter, MeshRenderer)> meshes = new List<(MeshFilter, MeshRenderer)>(); | ||||||
| 			foreach (var mf in gameObject.GetComponentsInChildren<MeshFilter>(true)) | 			foreach (var mf in meshFilters) | ||||||
| 			{ | 			{ | ||||||
| 				if (mf.TryGetComponent(out MeshRenderer mr)) | 				if (mf.TryGetComponent(out MeshRenderer mr)) | ||||||
|  | 				{ | ||||||
|  | 					if (includeInactive || (!includeInactive && mr.enabled)) | ||||||
| 					{ | 					{ | ||||||
| 						meshes.Add((mf, mr)); | 						meshes.Add((mf, mr)); | ||||||
| 					} | 					} | ||||||
| 				} | 				} | ||||||
|  | 			} | ||||||
|  |  | ||||||
| 			// Add target mesh. | 			// Add target mesh. | ||||||
| 			SkinnedMeshRenderer target = gameObject.AddComponent<SkinnedMeshRenderer>(); | 			SkinnedMeshRenderer target = gameObject.AddComponent<SkinnedMeshRenderer>(); | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user