Skip to content

Instantly share code, notes, and snippets.

@ronyx69
Last active August 17, 2020 12:11
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ronyx69/20070de77a0dc02fb669be0ff5365eb4 to your computer and use it in GitHub Desktop.
Save ronyx69/20070de77a0dc02fb669be0ff5365eb4 to your computer and use it in GitHub Desktop.
Change the shader of a prop, building, or building sub mesh to rotors in asset editor. Also deletes LOD.
// Rotors Shader
// Also deletes LOD.
// Prop
var shader = Shader.Find("Custom/Vehicles/Vehicle/Rotors");
var asset = ToolsModifierControl.toolController.m_editPrefabInfo as PropInfo;
if(asset.m_material != null) asset.m_material.shader = shader;
asset.m_lodMesh = null; asset.m_lodMaterial = null;
asset.m_lodMaterialCombined = null; asset.m_lodObject = null;
// Building
var shader = Shader.Find("Custom/Vehicles/Vehicle/Rotors");
var asset = ToolsModifierControl.toolController.m_editPrefabInfo as BuildingInfo;
if(asset.m_material != null) asset.m_material.shader = shader;
asset.m_lodMesh = null; asset.m_lodMaterial = null;
asset.m_lodMaterialCombined = null; asset.m_lodObject = null;
// Building Sub Mesh
var subMesh = 0; // sub mesh id, order as in ui, starting from 0
var shader = Shader.Find("Custom/Vehicles/Vehicle/Rotors");
var asset = ToolsModifierControl.toolController.m_editPrefabInfo as BuildingInfo;
asset.m_subMeshes[subMesh].m_subInfo.m_material.shader = shader;
asset.m_subMeshes[subMesh].m_subInfo.m_lodMaterial.shader = shader;
asset.m_subMeshes[subMesh].m_subInfo.m_lodMesh = null;
asset.m_subMeshes[subMesh].m_subInfo.m_lodMaterial = null;
asset.m_subMeshes[subMesh].m_subInfo.m_lodMaterialCombined = null;
asset.m_subMeshes[subMesh].m_subInfo.m_lodObject = null;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment