Ejemplo n.º 1
0
        static bool GetTextures(ref MeshRenderer renderer)
        {
            if (source.StartsWith("FILEPATH/"))
            {
                Texture texture = Resources.FindObjectsOfTypeAll <Texture>().FirstOrDefault(t => t.name == source.Substring(9));
                if (texture == null)
                {
                    return(false);
                }

                renderer.sharedMaterial.SetTexture("_MainTex", texture);
                return(true);
            }
            else if (source.StartsWith("INTERNAL/"))
            {
                if (source == "INTERNAL/satelliteMap")
                {
                    return(true);
                }

                if (source == "INTERNAL/colorMap")
                {
                    renderer.sharedMaterial.SetTexture("_BumpMap", null);
                    return(true);
                }

                if (body.BiomeMap != null)
                {
                    if (source == "INTERNAL/biomeMap" || source == "INTERNAL/satelliteBiome")
                    {
                        if (source == "INTERNAL/biomeMap")
                        {
                            renderer.sharedMaterial.SetTexture("_BumpMap", null);
                        }

                        renderer.sharedMaterial.SetTexture("_MainTex", body.BiomeMap.CompileToTexture());

                        return(true);
                    }
                }

                return(false);
            }
            else if (settings != null)
            {
                MapGenerator.LoadSettings(settings);
                MapGenerator.GeneratePQSMaps("Render/" + (!string.IsNullOrEmpty(name) ? name + "/" : ""), true);

                // MainTex
                switch (source)
                {
                case "heightMap":
                case "satelliteHeight": renderer.sharedMaterial.SetTexture("_MainTex", MapGenerator.heightMap); break;

                case "normalMap": renderer.sharedMaterial.SetTexture("_MainTex", MapGenerator.normalMap); break;

                case "slopeMap":
                case "satelliteSlope": renderer.sharedMaterial.SetTexture("_MainTex", MapGenerator.slopeMap); break;

                case "colorMap":
                case "satelliteMap": renderer.sharedMaterial.SetTexture("_MainTex", MapGenerator.colorMap); break;

                case "oceanMap": renderer.sharedMaterial.SetTexture("_MainTex", MapGenerator.oceanMap); break;

                case "biomeMap":
                case "satelliteBiome": renderer.sharedMaterial.SetTexture("_MainTex", MapGenerator.biomeMap); break;

                default: return(false);
                }

                // BumpMap
                switch (source)
                {
                case "heightMap":
                case "normalMap":
                case "slopeMap":
                case "colorMap":
                case "oceanMap":
                case "biomeMap": renderer.sharedMaterial.SetTexture("_BumpMap", null); break;

                case "satelliteHeight":
                case "satelliteSlope":
                case "satelliteMap":
                case "satelliteBiome": renderer.sharedMaterial.SetTexture("_BumpMap", MapGenerator.normalMap); break;
                }

                return(true);
            }

            return(false);
        }