Exemplo n.º 1
0
        Color GetMeshTerrainSourceTypeColor(TerrainSourceID terrainSourceID)
        {
            switch (terrainSourceID)
            {
            case TerrainSourceID.TerrainSourceID1:
                return(Color.green);

            case TerrainSourceID.TerrainSourceID2:
                return(Color.red);

            case TerrainSourceID.TerrainSourceID3:
                return(Color.blue);

            case TerrainSourceID.TerrainSourceID4:
                return(Color.yellow);

            case TerrainSourceID.TerrainSourceID5:
                return(Color.grey);

            case TerrainSourceID.TerrainSourceID6:
                return(Color.magenta);

            case TerrainSourceID.TerrainSourceID7:
                return(Color.cyan);

            case TerrainSourceID.TerrainSourceID8:
                return(Color.white);
            }

            return(Color.green);
        }
Exemplo n.º 2
0
        public void AddMeshRenderer(GameObject go, TerrainSourceID terrainSourceID)
        {
            MeshRenderer[] meshRenderers = go.GetComponentsInChildren <MeshRenderer>();

            for (int i = 0; i <= meshRenderers.Length - 1; i++)
            {
                if (Filterlods)
                {
                    if (meshRenderers[i].name.ToUpper().Contains("LOD1"))
                    {
                        continue;
                    }
                    if (meshRenderers[i].name.ToUpper().Contains("LOD2"))
                    {
                        continue;
                    }
                    if (meshRenderers[i].name.ToUpper().Contains("LOD3"))
                    {
                        continue;
                    }
                }

                var newMeshTerrainTerrainSource = new MeshTerrainMeshSource()
                {
                    MeshRenderer          = meshRenderers[i],
                    TerrainSourceID       = terrainSourceID,
                    MaterialPropertyBlock = new MaterialPropertyBlock()
                };
                MeshTerrainMeshSourceList.Add(newMeshTerrainTerrainSource);
            }
            NeedGeneration = true;
        }
Exemplo n.º 3
0
        public void AddTerrain(GameObject go, TerrainSourceID terrainSourceID)
        {
            Terrain[] terrains = go.GetComponentsInChildren <Terrain>();

            for (int i = 0; i <= terrains.Length - 1; i++)
            {
                var newMeshTerrainTerrainSource = new MeshTerrainTerrainSource
                {
                    Terrain               = terrains[i],
                    TerrainSourceID       = terrainSourceID,
                    MaterialPropertyBlock = new MaterialPropertyBlock()
                };

                MeshTerrainTerrainSourceList.Add(newMeshTerrainTerrainSource);
                NeedGeneration = true;
            }
        }
Exemplo n.º 4
0
        void DrawMeshRenderer(MeshRenderer meshRenderer, MaterialPropertyBlock materialPropertyBlock, TerrainSourceID terrainSourceID)
        {
            if (!meshRenderer)
            {
                return;
            }
            MeshFilter meshFilter = meshRenderer.gameObject.GetComponent <MeshFilter>();

            if (!meshFilter)
            {
                return;
            }
            if (!meshFilter.sharedMesh)
            {
                return;
            }
            Matrix4x4 matrix = Matrix4x4.TRS(meshRenderer.transform.position, meshRenderer.transform.rotation, meshRenderer.transform.lossyScale);

            materialPropertyBlock.SetColor("_Color", GetMeshTerrainSourceTypeColor(terrainSourceID));

            for (int i = 0; i <= meshFilter.sharedMesh.subMeshCount - 1; i++)
            {
                Graphics.DrawMesh(meshFilter.sharedMesh, matrix, _debugMaterial, 0, null, i, materialPropertyBlock);
            }
        }