VoxelFrameAnimationObjectExplosion.cs 2.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  1. using UnityEngine;
  2. using System.Collections;
  3. using System.Collections.Generic;
  4. namespace VoxelImporter
  5. {
  6. [AddComponentMenu("Voxel Importer/Extra/Explosion/Voxel Frame Animation Object Explosion")]
  7. [ExecuteInEditMode, RequireComponent(typeof(VoxelFrameAnimationObject))]
  8. public class VoxelFrameAnimationObjectExplosion : VoxelBaseExplosion
  9. {
  10. protected VoxelFrameAnimationObject voxelObject { get; private set; }
  11. public List<MeshData> meshes;
  12. public List<Material> materials;
  13. protected override void Awake()
  14. {
  15. base.Awake();
  16. voxelObject = GetComponent<VoxelFrameAnimationObject>();
  17. }
  18. public override void DrawMesh()
  19. {
  20. if (materials != null && meshes != null)
  21. {
  22. var world = transformCache.localToWorldMatrix;
  23. for (int i = 0; i < meshes.Count; i++)
  24. {
  25. for (int j = 0; j < meshes[i].materialIndexes.Count; j++)
  26. {
  27. if (meshes[i].mesh != null && j < meshes[i].mesh.subMeshCount)
  28. Graphics.DrawMesh(meshes[i].mesh, world, materials[meshes[i].materialIndexes[j]], 0, null, j, materialPropertyBlock);
  29. }
  30. }
  31. }
  32. }
  33. #if UNITY_EDITOR
  34. #region Asset
  35. public override bool IsUseAssetObject(UnityEngine.Object obj)
  36. {
  37. if (meshes != null)
  38. {
  39. for (int i = 0; i < meshes.Count; i++)
  40. {
  41. if (meshes[i] == null) continue;
  42. if (meshes[i].mesh == obj) return true;
  43. }
  44. }
  45. if (materials != null)
  46. {
  47. for (int i = 0; i < materials.Count; i++)
  48. {
  49. if (materials[i] == obj) return true;
  50. }
  51. }
  52. return false;
  53. }
  54. #endregion
  55. #endif
  56. }
  57. }