Skip to content

Instantly share code, notes, and snippets.

@ronyx69
Last active March 2, 2019 14:07
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ronyx69/db4e7c41fe80020e31d9bd2e1e1196f8 to your computer and use it in GitHub Desktop.
Save ronyx69/db4e7c41fe80020e31d9bd2e1e1196f8 to your computer and use it in GitHub Desktop.
Script for saving tiling values for network segment and node textures. Visible instantly in road editor, mod not required for saving the asset, only for loading it ingame. If you load a road with tiling applied in the asset editor, the tiling won't be visible but it's still saved, unless a segment/node is reimported.
// Network Tiling Script
//
// Script for saving tiling values for network segment and node textures.
// Visible instantly in road editor, mod not required for saving the asset, only for loading it ingame.
//
// If you load a road with tiling in the asset editor, the tiling won't be visible,
// but it's still saved, unless a segment/node is reimported.
// Don't touch this part, scroll below it.
var asset=ToolsModifierControl.toolController.m_editPrefabInfo as NetInfo;
var basic=0; var elevated=1; var bridge=2; var slope=3; var tunnel=4; var segment=0; var node=1;
NetInfo e=null; NetInfo b=null; NetInfo s=null; NetInfo t=null; NetInfo.Segment seg=null; NetInfo.Node nod=null;
if(asset.m_netAI.GetType().Name == "RoadAI") { var ai = (asset.m_netAI as RoadAI);
e = ai.m_elevatedInfo; b = ai.m_bridgeInfo; s = ai.m_slopeInfo; t = ai.m_tunnelInfo; }
else if(asset.m_netAI.GetType().Name == "TrainTrackAI") { var ai = (asset.m_netAI as TrainTrackAI);
e = ai.m_elevatedInfo; b = ai.m_bridgeInfo; s = ai.m_slopeInfo; t = ai.m_tunnelInfo; }
else if(asset.m_netAI.GetType().Name == "PedestrianPathAI") { var ai = (asset.m_netAI as PedestrianPathAI);
e = ai.m_elevatedInfo; b = ai.m_bridgeInfo; s = ai.m_slopeInfo; t = ai.m_tunnelInfo; }
else if(asset.m_netAI.GetType().Name == "PedestrianWayAI") { var ai = (asset.m_netAI as PedestrianWayAI);
e = ai.m_elevatedInfo; b = ai.m_bridgeInfo; s = ai.m_slopeInfo; t = ai.m_tunnelInfo; }
Action<int, int, int, float> NetworkTiling = (network, type, id, tiling) => { id--;
if(network == 3 || network == 4) { var te = s; if(network == 4) te = t;
if(type == 0) if(te.m_segments[0].m_material.shader.name == "Custom/Net/Metro") id++;
if(type == 1) if(te.m_nodes[0].m_material.shader.name == "Custom/Net/Metro") id++; }
if(type == 0) { if(network == 0) seg = asset.m_segments[id];
else if(network == 1) seg = e.m_segments[id]; else if(network == 2) seg = b.m_segments[id];
else if(network == 3) seg = s.m_segments[id]; else if(network == 4) seg = t.m_segments[id]; }
else if(type == 1) { if(network == 0) nod = asset.m_nodes[id];
else if(network == 1) nod = e.m_nodes[id]; else if(network == 2) nod = b.m_nodes[id];
else if(network == 3) nod = s.m_nodes[id]; else if(network == 4) nod = t.m_nodes[id]; }
if(type == 0) { if(seg.m_material != null) seg.m_material.mainTextureScale = new Vector2(1, tiling);
if(seg.m_segmentMaterial != null) seg.m_segmentMaterial.mainTextureScale = new Vector2(1, tiling);
if(seg.m_lodMaterial != null) seg.m_lodMaterial.mainTextureScale = new Vector2(1, tiling);
seg.m_material.name = "NetworkTiling " + tiling.ToString("R"); }
else if(type == 1) { if(nod.m_material != null) nod.m_material.mainTextureScale = new Vector2(1, tiling);
if(nod.m_nodeMaterial != null) nod.m_nodeMaterial.mainTextureScale = new Vector2(1, tiling);
if(nod.m_lodMaterial != null) nod.m_lodMaterial.mainTextureScale = new Vector2(1, tiling);
nod.m_material.name = "NetworkTiling " + tiling.ToString("R"); } };
// Below add however many lines you need for your network.
//
// Format: NetworkTiling(network, type, id, tiling);
//
// Networks: basic, elevated, bridge, slope, tunnel
// Types: segment, node
// ID: order number starting from 1 as visible in the road editor segment/node list UI
// Tiling: How much the texture tiles vertically, non-round numbers might cause seams.
// A couple examples: (delete and add your own)
NetworkTiling(basic, segment, 1, 2.0f);
NetworkTiling(elevated, node, 4, 3.0f);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment