Exemple #1
0
        override public void Preprocess()
        {
            terrain     = unityComponent as Terrain;
            terrainData = terrain.terrainData;
            if (terrainData == null)
            {
                return;
            }

            SplatPrototype[] splats = terrainData.splatPrototypes;
            for (int i = 0; i < splats.Length; ++i)
            {
                textures.Add(BundleTexture.RegisterTexture(splats[i].texture, "SplatTex"));
                textureSizes.Add(splats[i].tileSize);
                textureOffsets.Add(splats[i].tileOffset);
            }
        }
Exemple #2
0
        private BundleMaterial(Material material)
        {
            this.unityMaterial     = material;
            this.index             = allMaterials.Count;
            this.name              = material.name;
            allMaterials[material] = this;
            shader = BundleShader.RegisterShader(material.shader);

            for (int i = 0; i < ShaderUtil.GetPropertyCount(material.shader); ++i)
            {
                // Find and record all textures used by current shader
                if (ShaderUtil.GetPropertyType(material.shader, i) == ShaderUtil.ShaderPropertyType.TexEnv)
                {
                    string  propName   = ShaderUtil.GetPropertyName(material.shader, i);
                    Texture subtexture = material.GetTexture(propName);
                    if (subtexture == null)
                    {
                        Debug.LogWarning("Material " + material.name + " can't load texture for " + propName);
                        continue;
                    }

                    textures.Add(BundleTexture.RegisterTexture(subtexture, propName));
                    textureUnits.Add(BundleTexture.GetSuggestedUnit(propName));
                    textureScales.Add(material.GetTextureScale(propName));
                    textureOffsets.Add(material.GetTextureOffset(propName));
                }
            }

            // If no shader textures used, try to record the main texture
            if (textures.Count == 0 && material.mainTexture != null)
            {
                textures.Add(BundleTexture.RegisterTexture(material.mainTexture, "_MainTex"));
                textureUnits.Add(BundleTexture.GetSuggestedUnit("_MainTex"));
                textureScales.Add(unityMaterial.mainTextureScale);
                textureOffsets.Add(unityMaterial.mainTextureOffset);
            }
        }