Skip to content

Instantly share code, notes, and snippets.

@ronyx69
Last active July 27, 2017 14:58
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/1d7b4a596edfa749c4823295ebac9a3a to your computer and use it in GitHub Desktop.
Save ronyx69/1d7b4a596edfa749c4823295ebac9a3a to your computer and use it in GitHub Desktop.
Replaces a network segment/node mesh with a mesh from a prop.
// 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