Instantly share code, notes, and snippets.

Embed
What would you like to do?
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