Last active
July 27, 2017 14:58
-
-
Save ronyx69/1d7b4a596edfa749c4823295ebac9a3a to your computer and use it in GitHub Desktop.
Replaces a network segment/node mesh with a mesh from a prop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// PropMesh To NetworkMesh | |
var propName = "Barrels"; | |
var networkName = "Train Track"; | |
var type = "segment"; // segment or node | |
var id = 1; | |
var replaceTexture = false; // true or false | |
var prop = PrefabCollection<PropInfo>.FindLoaded(propName); // PropInfo, BuildingInfo, VehicleInfo, TreeInfo | |
var net = PrefabCollection<NetInfo>.FindLoaded(networkName); | |
if(type=="segment") net.m_segments[id].m_segmentMesh = prop.m_mesh; | |
else if(type=="node") net.m_nodes[id].m_nodeMesh = prop.m_mesh; | |
if(replaceTexture==true) | |
{ | |
if(type=="segment") net.m_segments[id].m_segmentMaterial.SetTexture("_MainTex", prop.m_material.GetTexture("_MainTex")); | |
else if(type=="node") net.m_nodes[id].m_nodeMaterial.SetTexture("_MainTex", prop.m_material.GetTexture("_MainTex")); | |
} | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment