/// <summary> /// Initialize component /// </summary> public void Initialize() { m_instance = this; if (!m_gameObject) { m_gameObject = GetComponent <GameObject>(); } if (!m_transform) { m_transform = GetComponent <Transform>(); } m_terrain = GetComponent <Terrain>(); if (Terrain == null) { return; } // { throw new NullReferenceException(Settings.ErrorMessages.NO_TERRAIN_COMPONENT); } m_terrainData = m_terrain.terrainData; if (TerrainData == null) { return; } // { throw new NullReferenceException(Settings.ErrorMessages.NO_TERRAIN_DATA_COMPONENT); } if (m_alpha == null) { m_alpha = new tp_Alpha(); } if (m_heights == null) { m_heights = new tp_Heights(); } if (m_history == null) { m_history = new tp_History(); } if (m_ramp == null) { m_ramp = new tp_MinMax(45.0f, 65.0f); } if (m_textures == null) { m_textures = new tp_Textures(); } if (m_foliages == null) { m_foliages = new tp_Foliages(); } SafeTextureSelect(); if (m_noise == null) { m_noise = new tp_Noise(); m_noise.Generate(new Point(TerrainData.alphamapWidth, TerrainData.alphamapHeight)); } }
/// <summary> /// Constructor /// </summary> /// <param name="index"></param> /// <param name="heights"></param> public tp_Height(int index, tp_Heights heights) { m_index = index; if (heights.Count < 1) { // First range Range = new Vector2(0.0f, TP.Instance.TerrainData.heightmapScale.y); return; } // Create Range tp_Height last = heights[heights.Count - 1]; float max = last.y; float v = last.y - last.x; v /= 3.0f; last.y -= 2.0f * v; // Set range Range = new Vector2(last.y + v, max); }
/// <summary> /// Initialize component /// </summary> public void Initialize() { m_instance = this; if (!m_gameObject) { m_gameObject = GetComponent<GameObject>(); } if (!m_transform) { m_transform = GetComponent<Transform>(); } m_terrain = GetComponent<Terrain>(); if (Terrain == null) { return; } // { throw new NullReferenceException(Settings.ErrorMessages.NO_TERRAIN_COMPONENT); } m_terrainData = m_terrain.terrainData; if (TerrainData == null) { return; } // { throw new NullReferenceException(Settings.ErrorMessages.NO_TERRAIN_DATA_COMPONENT); } if (m_alpha == null) { m_alpha = new tp_Alpha(); } if (m_heights == null) { m_heights = new tp_Heights(); } if (m_history == null) { m_history = new tp_History(); } if (m_ramp == null) { m_ramp = new tp_MinMax(45.0f, 65.0f); } if (m_textures == null) { m_textures = new tp_Textures(); } if (m_foliages == null) { m_foliages = new tp_Foliages(); } SafeTextureSelect(); if (m_noise == null) { m_noise = new tp_Noise(); m_noise.Generate(new Point(TerrainData.alphamapWidth, TerrainData.alphamapHeight)); } }