VoxelChunksObjectChunk.cs 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  1. using UnityEngine;
  2. using UnityEngine.Assertions;
  3. using System;
  4. using System.Collections;
  5. using System.Collections.Generic;
  6. namespace VoxelImporter
  7. {
  8. [RequireComponent(typeof(MeshFilter)), RequireComponent(typeof(MeshRenderer))]
  9. public class VoxelChunksObjectChunk : MonoBehaviour
  10. {
  11. #if !UNITY_EDITOR
  12. void Awake()
  13. {
  14. Destroy(this);
  15. }
  16. #else
  17. public bool EditorInitialize()
  18. {
  19. bool result = false;
  20. //ver1.021 -> ver1.0.3
  21. if (material != null)
  22. {
  23. materials = new List<Material>();
  24. materials.Add(material);
  25. materialIndexes = new List<int>();
  26. materialIndexes.Add(0);
  27. material = null;
  28. result = true;
  29. }
  30. //ver1.0.4
  31. if(basicOffset.sqrMagnitude <= 0f)
  32. {
  33. basicOffset = transform.localPosition;
  34. }
  35. return result;
  36. }
  37. public IntVector3 position;
  38. public string chunkName;
  39. public Vector3 basicOffset;
  40. public Mesh mesh;
  41. [SerializeField]
  42. protected Material material; //ver1.021 old
  43. public List<Material> materials; //ver1.0.3 new
  44. public Texture2D atlasTexture;
  45. public List<int> materialIndexes;
  46. #region Editor
  47. public bool edit_objectFoldout = true;
  48. #endregion
  49. #endif
  50. }
  51. }