Skip to content

Instantly share code, notes, and snippets.

@TimTheTerribleCS
Last active October 4, 2016 18:10
Show Gist options
  • Save TimTheTerribleCS/d87130f87608d04c311dbca086f2e8c1 to your computer and use it in GitHub Desktop.
Save TimTheTerribleCS/d87130f87608d04c311dbca086f2e8c1 to your computer and use it in GitHub Desktop.
var net = "Train Track";
var original = "RailwayPowerline";
var replacement = "NL_Powerline_2TB.NL_Powerline_2TB_Data";
var netInfo = PrefabCollection<NetInfo>.FindLoaded(net);
if (netInfo == null)
{
Debug.LogWarning("The name '" + net + "' you entered does not belong to a loaded net!");
return;
}
var replacementProp = PrefabCollection<PropInfo>.FindLoaded(replacement);
if (replacementProp == null)
{
Debug.LogWarning("The name '" + replacement + "' you entered does not belong to a loaded prop!");
return;
}
if (netInfo.m_lanes != null)
{
foreach (var lane in netInfo.m_lanes)
{
if (lane != null && lane.m_laneProps != null && lane.m_laneProps.m_props != null)
{
foreach (var laneProp in lane.m_laneProps.m_props)
{
if (laneProp != null && laneProp.m_prop != null && laneProp.m_prop.name == original)
{
laneProp.m_prop = replacementProp;
laneProp.m_finalProp = replacementProp;
}
}
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment