Beispiel #1
0
        public void Load(LayerData layer)
        {
            gridSize = layer.gridSize;
            parallaxComp.zPosition      = layer.zPosition;
            parallaxComp.parallaxWeight = layer.parallaxWeight;
            triangleBlocks = new TriangleBlock[gridSize.x, gridSize.y];
            GenerateGrid();

            for (var y = 0; y < gridSize.y; y++)
            {
                for (var x = 0; x < gridSize.x; x++)
                {
                    triangleBlocks[x, y].Load(layer.triangleDataBlocks[y * gridSize.x + x], material);
                }
            }
        }
Beispiel #2
0
        public LayerData ToData()
        {
            var parallaxComp = GetComponent <ParallaxLayer>();
            var layerData    = new LayerData();

            layerData.name               = name;
            layerData.zPosition          = parallaxComp.zPosition;
            layerData.parallaxWeight     = parallaxComp.parallaxWeight;
            layerData.gridSize           = gridSize;
            layerData.triangleDataBlocks = new TriangleBlockData[gridSize.x * gridSize.y];
            for (var y = 0; y < gridSize.y; y++)
            {
                for (var x = 0; x < gridSize.x; x++)
                {
                    layerData.triangleDataBlocks[y * gridSize.x + x] = triangleBlocks[x, y].ToData();
                }
            }
            return(layerData);
        }
Beispiel #3
0
        CombineInstance[] CreateCombinedMeshes(LayerData layerData, GameObject root)
        {
            List <CombineInstance> combines = new List <CombineInstance>();

            for (var i = 0; i < layerData.triangleDataBlocks.Length; i++)
            {
                var triangleBlockData = layerData.triangleDataBlocks[i];
                for (var j = 0; j < triangleBlockData.triangles.Length; j++)
                {
                    if (triangleBlockData.triangles[j])
                    {
                        CombineInstance combine = new CombineInstance();
                        combine.mesh      = triangleMeshes[j];
                        combine.transform = Create2DTransformMatrix(triangleBlockData.position);
                        combines.Add(combine);
                    }
                }
            }
            return(combines.ToArray());
        }