Instantly share code, notes, and snippets.

Embed
What would you like to do?
Recalculates tangents for mesh and lod mesh, necessary if you used the mesh rotation feature in the importer, since that results in broken tangents which makes the normal map behave incorrectly. The normal map must +X +Y which means you DO NOT need to flip any channels.
// prop
var asset = ToolsModifierControl.toolController.m_editPrefabInfo as PropInfo;
if(asset.m_mesh != null) asset.m_mesh.RecalculateTangents();
if(asset.m_lodMesh != null) asset.m_lodMesh.RecalculateTangents();
// building
var asset = ToolsModifierControl.toolController.m_editPrefabInfo as BuildingInfo;
if(asset.m_mesh != null) asset.m_mesh.RecalculateTangents();
if(asset.m_lodMesh != null) asset.m_lodMesh.RecalculateTangents();
// vehicle
var asset = ToolsModifierControl.toolController.m_editPrefabInfo as VehicleInfo;
if(asset.m_mesh != null) asset.m_mesh.RecalculateTangents();
if(asset.m_lodMesh != null) asset.m_lodMesh.RecalculateTangents();
// tree
var asset = ToolsModifierControl.toolController.m_editPrefabInfo as TreeInfo;
if(asset.m_mesh != null) asset.m_mesh.RecalculateTangents();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment