Esempio n. 1
0
    public override void OnSelected()
    {
        SomePrefab.GetComponent <MeshFilter>().mesh = MeshGenerator.GenerateCubeMesh(3, new Vector3(20, 10, 20));
        TerrainManager.ApplyTerrainToMesh(SomePrefab.GetComponent <MeshFilter>().mesh, _gridPosition, 0, new IntVector2(1, 1), false);
        SomePrefab.GetComponent <MeshRenderer>().materials = new[] { _mat };

        SomePrefab.GetComponent <MeshRenderer>().enabled = true;
    }
Esempio n. 2
0
 public override void OnMouseOverTile(IntVector2 point)
 {
     if (_gridPosition.x != point.x || _gridPosition.y != point.y)
     {
         _gridPosition = point;
         SomePrefab.transform.position = new Vector3(point.x * TrackManager.TileSize, 5, -1 * point.y * TrackManager.TileSize);
         SomePrefab.GetComponent <MeshFilter>().mesh = MeshGenerator.GenerateCubeMesh(3, new Vector3(20, 10, 20));
         TerrainManager.ApplyTerrainToMesh(SomePrefab.GetComponent <MeshFilter>().mesh, _gridPosition, 0, new IntVector2(1, 1), false);
     }
 }
Esempio n. 3
0
    public void ApplyTerrain()
    {
        if (!GetComponent <MeshFilter>().sharedMesh)
        {
            return;
        }

        if (_currentVertices == null || _currentVertices.Length != _originalVertices.Length)
        {
            _currentVertices = new Vector3[_originalVertices.Length];
        }

        for (int i = 0; i < _originalVertices.Length; i++)
        {
            _currentVertices[i] = _originalVertices[i];
        }

        _terrainManager.ApplyTerrainToMesh(ref _currentVertices, GridPosition, _trackTileSavable.Rotation, Size, _trackTileSavable.IsMirrored > 0);

        GetComponent <MeshFilter>().mesh.vertices = _currentVertices;
        GetComponent <MeshFilter>().mesh.RecalculateBounds();
    }