TerrainDetail.cs 2.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  1. using UnityEngine;
  2. using System.Collections;
  3. using System;
  4. namespace WorldComposer
  5. {
  6. [Serializable]
  7. public class TerrainDetail : MonoBehaviour
  8. {
  9. public int heightmapMaximumLOD;
  10. public float heightmapPixelError;
  11. public float basemapDistance;
  12. public bool castShadows;
  13. public bool draw;
  14. public float treeDistance;
  15. public float detailObjectDistance;
  16. public float detailObjectDensity;
  17. public float treeBillboardDistance;
  18. public float treeCrossFadeLength;
  19. public int treeMaximumFullLODCount;
  20. public TerrainDetail()
  21. {
  22. heightmapPixelError = 5;
  23. basemapDistance = 50000;
  24. draw = true;
  25. treeDistance = 20000;
  26. detailObjectDistance = 250;
  27. detailObjectDensity = 1;
  28. treeBillboardDistance = 200;
  29. treeCrossFadeLength = 50;
  30. treeMaximumFullLODCount = 50;
  31. }
  32. void Start()
  33. {
  34. Terrain terrain = (Terrain)GetComponent(typeof(Terrain));
  35. terrain.heightmapPixelError = heightmapPixelError;
  36. terrain.heightmapMaximumLOD = heightmapMaximumLOD;
  37. if (terrain.GetComponent("ReliefTerrain") == null)
  38. {
  39. terrain.basemapDistance = basemapDistance;
  40. }
  41. //terrain.castShadows = castShadows;
  42. if (draw)
  43. {
  44. terrain.treeDistance = treeDistance;
  45. terrain.detailObjectDistance = detailObjectDistance;
  46. }
  47. else
  48. {
  49. terrain.treeDistance = 0;
  50. terrain.detailObjectDistance = 0;
  51. }
  52. terrain.detailObjectDensity = detailObjectDensity;
  53. terrain.treeMaximumFullLODCount = treeMaximumFullLODCount;
  54. terrain.treeBillboardDistance = treeBillboardDistance;
  55. terrain.treeCrossFadeLength = treeCrossFadeLength;
  56. terrain.treeMaximumFullLODCount = treeMaximumFullLODCount;
  57. }
  58. }
  59. }