Last active
October 4, 2016 18:10
-
-
Save TimTheTerribleCS/d87130f87608d04c311dbca086f2e8c1 to your computer and use it in GitHub Desktop.
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
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