コード例 #1
0
        // TODO: we also want to copy the exr data in case user wants it
        new public static void Preprocess()
        {
            LightmapData[] lightmaps = LightmapSettings.lightmaps;

            for (int i = 0; i < lightmaps.Length; i++)
            {
                var lightmap = lightmaps[i].lightmapDir;

                if (lightmap == null)
                {
                    lightmap = lightmaps[i].lightmapColor;
                }

                string          path            = AssetDatabase.GetAssetPath(lightmap);
                TextureImporter textureImporter = AssetImporter.GetAtPath(path) as TextureImporter;

                TextureImporterSettings settings = new TextureImporterSettings();
                textureImporter.ReadTextureSettings(settings);

                bool setReadable = false;
                if (!settings.readable)
                {
                    setReadable = true;
                }

                settings.readable = true;
                settings.lightmap = true;
                textureImporter.SetTextureSettings(settings);
                AssetDatabase.ImportAsset(path, ImportAssetOptions.ForceUpdate);

                var pixels = lightmap.GetPixels32();


                Texture2D ntexture = new Texture2D(lightmap.width, lightmap.height, TextureFormat.ARGB32, false);
                ntexture.SetPixels32(pixels);
                ntexture.Apply();

                var bytes = ntexture.EncodeToPNG();

                UnityEngine.Object.DestroyImmediate(ntexture);

                if (setReadable)
                {
                    settings.readable = false;
                }

                settings.lightmap = true;
                textureImporter.SetTextureSettings(settings);
                AssetDatabase.ImportAsset(path, ImportAssetOptions.ForceUpdate);

                JELightmap lm = new JELightmap();

                lm.filename        = JEScene.sceneName + "_Lightmap_" + i;
                lm.base64PNGLength = bytes.Length;
                lm.base64PNG       = System.Convert.ToBase64String(bytes, 0, bytes.Length);

                allLightmaps.Add(lm);
            }
        }
コード例 #2
0
 public static void PostProcess()
 {
     JETexture.PostProcess();
     JEShader.PostProcess();
     JEMaterial.PostProcess();
     JELightmap.PostProcess();
     JEMesh.PostProcess();
 }
コード例 #3
0
 public static void Reset()
 {
     JEMesh.Reset();
     JEMaterial.Reset();
     JETexture.Reset();
     JEShader.Reset();
     JELightmap.Reset();
 }
コード例 #4
0
 public static void Process()
 {
     JETexture.Process();
     JEShader.Process();
     JEMaterial.Process();
     JELightmap.Process();
     JEMesh.Process();
     JESprite.Process();
     JEParticle.Process();
 }
コード例 #5
0
        public static JSONResources GenerateJSONResources()
        {
            var json = new JSONResources();

            json.textures  = JETexture.GenerateJSONTextureList();
            json.lightmaps = JELightmap.GenerateJSONLightmapList();
            json.shaders   = JEShader.GenerateJSONShaderList();
            json.materials = JEMaterial.GenerateJSONMaterialList();
            json.meshes    = JEMesh.GenerateJSONMeshList();

            return(json);
        }
コード例 #6
0
        public static List <JSONLightmap> GenerateJSONLightmapList()
        {
            List <JSONLightmap> lightmaps = new List <JSONLightmap>();

            for (int i = 0; i < allLightmaps.Count; i++)
            {
                JELightmap   lightmap  = allLightmaps[i];
                JSONLightmap jlightmap = new JSONLightmap();

                jlightmap.filename        = lightmap.filename;
                jlightmap.base64PNG       = lightmap.base64PNG;
                jlightmap.base64PNGLength = lightmap.base64PNGLength;

                lightmaps.Add(jlightmap);
            }

            return(lightmaps);
        }