Skip to content

Instantly share code, notes, and snippets.

@ronyx69
Created January 10, 2020 21:12
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save ronyx69/e022dca5bda6edaec40d4d835358d313 to your computer and use it in GitHub Desktop.
Save ronyx69/e022dca5bda6edaec40d4d835358d313 to your computer and use it in GitHub Desktop.
Replace lane props on networks in the asset editor.
Action<string, string> ReplaceProp = (search, replace) =>
{
var replacementProp = PrefabCollection<PropInfo>.FindLoaded(replace);
for (uint i = 0; i < PrefabCollection<NetInfo>.LoadedCount(); i++)
{
var prefab = PrefabCollection<NetInfo>.GetLoaded(i);
if (prefab == null) continue;
if(prefab.m_lanes != null) foreach (var Lane in prefab.m_lanes)
{
if(Lane.m_laneProps != null)
{
if(Lane.m_laneProps.m_props != null) foreach (var LaneProp in Lane.m_laneProps.m_props)
{
if(LaneProp.m_prop != null)
{
if(LaneProp.m_prop.name == search)
{
LaneProp.m_prop = replacementProp;
LaneProp.m_finalProp = replacementProp;
Debug.Log("Replaced");
}
}
}
}
}
}
};
// Usage: ReplaceProp("replace this", "with that");
ReplaceProp("darktun.darktun_Data", "1530239308.R69Railway Tunnel Darkener_Data");
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment