NeoLightMapExport

From Unify Community Wiki
Revision as of 22:52, 10 January 2012 by NCarter (Talk | contribs)

(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to: navigation, search

Author: Neodrop

Description

This is editor script for export lightmap from selected terrain and save it as image in Asset folder. Based on LightmapExport.cs from Island Demo.

Usage

Place this script in YourProject/Assets/Editor and the "Export LightMap" menu items will appear in the NeoTools/Terrain menu once it is compiled.

Javascript - NeoLightmapExport.js

import System.IO;
class NeoLightmapExport extends ScriptableWizard
{
	var terrain : Terrain;
	private var terrainData : TerrainData;
 
	@MenuItem("NeoTools/Terrain/Export Lightmap...")
	static function CreateWizard ()
	{
		ScriptableWizard.DisplayWizard("Export Lightmap", NeoLightmapExport, "Export"); 
	}
 
	function OnWizardUpdate ()
	{
		helpString = "Well, let's go Rock!";
		if(!terrain) {
            helpString = "I need a terrain!";
        } else {
            terrainData = terrain.terrainData;
        }
	}
 
	function OnWizardCreate ()
    {
		var lightmapTexture : Texture2D = terrainData.lightmap;
		var myBytes : byte[] = lightmapTexture.EncodeToPNG();
		var filename : String = terrain.name + "Duplicate.png";
		File.WriteAllBytes(Application.dataPath + "/"+filename, myBytes);
		EditorUtility.DisplayDialog("Texture Duplicated", "Selected Texture2D saved in Assets/ as: " + filename, "See You Again!");
	}
}
Personal tools
Namespaces

Variants
Actions
Navigation
Extras
Toolbox