Пример #1
0
    public static MapMeshChunk CreateEmpty()
    {
        GameObject   resultObj  = new GameObject("Map Mesh Chunk");
        MapMeshChunk resultMono = resultObj.AddComponent <MapMeshChunk>();

        resultMono.Hexes = new Hex[
            HexMeshConstants.CHUNK_SIZE_X *
            HexMeshConstants.CHUNK_SIZE_Z
                           ];

        GameObject resultCanvasObj = new GameObject(
            "World Space UI Canvas"
            );

        Canvas resultCanvasMono =
            resultCanvasObj.AddComponent <Canvas>();

        CanvasScaler resultCanvasScalerMono =
            resultCanvasObj.AddComponent <CanvasScaler>();

        resultCanvasObj.transform.SetParent(
            resultObj.transform,
            false
            );

        resultMono.WorldSpaceUICanvas = resultCanvasMono;
        resultCanvasScalerMono.dynamicPixelsPerUnit = 10f;

        resultCanvasObj.transform.rotation = Quaternion.Euler(
            90,
            0,
            0
            );

        resultCanvasObj.transform.position += Vector3.up * .005f;

        resultMono._terrainLayer = TerrainChunkLayer.CreateEmpty(
            Resources.Load <Material>("Terrain"),
            true,
            true,
            false,
            false
            );

        resultMono._terrainLayer.transform.SetParent(
            resultObj.transform,
            false
            );

        resultMono._riversLayer = RiversChunkLayer.CreateEmpty(
            Resources.Load <Material>("River"),
            false,
            true,
            true,
            false
            );

        resultMono._riversLayer.transform.SetParent(
            resultObj.transform,
            false
            );

        resultMono._roadsLayer = RoadsChunkLayer.CreateEmpty(
            Resources.Load <Material>("Road"),
            false,
            true,
            true,
            false
            );

        resultMono._roadsLayer.transform.SetParent(
            resultObj.transform,
            false
            );

        resultMono._openWaterLayer =
            OpenWaterChunkLayer.CreateEmpty(
                Resources.Load <Material>("Water"),
                false,
                true,
                false,
                false
                );

        resultMono._openWaterLayer.transform.SetParent(
            resultObj.transform,
            false
            );

        resultMono._waterShoreLayer =
            WaterShoreChunkLayer.CreateEmpty(
                Resources.Load <Material>("WaterShore"),
                false,
                true,
                true,
                false
                );

        resultMono._waterShoreLayer.transform.SetParent(
            resultObj.transform,
            false
            );

        resultMono._estuariesLayer = EstuariesChunkLayer.CreateEmpty(
            Resources.Load <Material>("Estuary"),
            false,
            true,
            true,
            true
            );

        resultMono._estuariesLayer.transform.SetParent(
            resultObj.transform,
            false
            );

        MapMeshChunkLayer walls = MapMeshChunkLayer.CreateEmpty(
            Resources.Load <Material>("Urban"),
            false,
            false,
            false,
            false
            );

        walls.name = "Walls Layer";
        walls.transform.SetParent(resultObj.transform, false);

        resultMono._features = FeatureContainer.GetFeatureContainer(
            walls
            );

        resultMono._features.transform.SetParent(
            resultObj.transform,
            false
            );

        resultMono._features.name = "Features Layer";

        return(resultMono);
    }