VoxelStructure.cs 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. using UnityEngine;
  2. using System;
  3. using System.Collections;
  4. using System.Collections.Generic;
  5. namespace VoxelImporter
  6. {
  7. public class VoxelStructure : ScriptableObject
  8. {
  9. [Serializable, System.Diagnostics.DebuggerDisplay("Position({x}, {y}, {z}), Palette({palette})")]
  10. public struct Voxel
  11. {
  12. #if UNITY_EDITOR
  13. public Voxel(VoxelData.Voxel voxel)
  14. {
  15. this.x = voxel.x;
  16. this.y = voxel.y;
  17. this.z = voxel.z;
  18. this.palette = voxel.palette;
  19. this.visible = voxel.visible;
  20. }
  21. #endif
  22. public Vector3 position { get { return new Vector3(x, y, z); } }
  23. public int x;
  24. public int y;
  25. public int z;
  26. public int palette;
  27. public VoxelBase.Face visible;
  28. }
  29. #if UNITY_EDITOR
  30. public void Set(VoxelData voxelData)
  31. {
  32. voxels = new Voxel[voxelData.voxels.Length];
  33. for (int i = 0; i < voxelData.voxels.Length; i++)
  34. {
  35. voxels[i] = new Voxel(voxelData.voxels[i]);
  36. }
  37. palettes = new Color[voxelData.palettes.Length];
  38. voxelData.palettes.CopyTo(palettes, 0);
  39. voxelSize = voxelData.voxelSize;
  40. }
  41. #endif
  42. public Voxel[] voxels;
  43. public Color[] palettes;
  44. public IntVector3 voxelSize;
  45. }
  46. }