Skip to content

Instantly share code, notes, and snippets.

@ronyx69
Created September 12, 2018 13:23
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ronyx69/29dfd41933b6735ac3a442455e1ef6ee to your computer and use it in GitHub Desktop.
Save ronyx69/29dfd41933b6735ac3a442455e1ef6ee to your computer and use it in GitHub Desktop.
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