Beispiel #1
0
        private void EndRecord()
        {
            Terrain terrain = m_terrain;

            terrain.TerrainColliderWithoutHoles();

            float[,] oldHeightmap = m_oldHeights;
            float[,] newHeightmap = GetHeightmap();

            Vector3[] oldResizerPositions = m_oldResizerPositions;
            Vector3[] newResizerPositions = AreaResizerPositions.ToArray();

            m_oldHeights          = null;
            m_oldResizerPositions = null;

            m_editor.Undo.CreateRecord(record =>
            {
                if (terrain.terrainData != null)
                {
                    terrain.SetHeights(0, 0, newHeightmap);
                    terrain.TerrainColliderWithoutHoles();
                }

                SetAreaResizerPositions(newResizerPositions);
                SetPosition(newResizerPositions.Last());
                Vector3 areaSize, areaCenter;
                GetArea(oldResizerPositions, out areaSize, out areaCenter);
                SetProjector(areaSize, areaCenter);

                return(true);
            },
                                       record =>
            {
                if (terrain.terrainData != null)
                {
                    terrain.SetHeights(0, 0, oldHeightmap);
                    terrain.TerrainColliderWithoutHoles();
                }

                SetAreaResizerPositions(oldResizerPositions);
                SetPosition(oldResizerPositions.Last());
                Vector3 areaSize, areaCenter;
                GetArea(oldResizerPositions, out areaSize, out areaCenter);
                SetProjector(areaSize, areaCenter);

                return(true);
            });
        }
Beispiel #2
0
 private void BeginRecord()
 {
     m_oldHeights          = GetHeightmap();
     m_oldResizerPositions = AreaResizerPositions.ToArray();
 }