Instantly share code, notes, and snippets.

Embed
What would you like to do?
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.
// Network Tiling Script
// Allows using any tiling value for network segment and node textures.
// Visible instantly in road editor, mod not required for saving the asset, only for loading it ingame.
// For networks using alpha maps - the shadows cast by alpha cutouts will appear as if it's not tiled.
// Don't touch this part, scroll below it... unless you are setting it for train track elevations.
// If you are setting tiling values for train track or pedestrian path elevations,
// you must change RoadAI (3 lines below this) to TrainTrackAI or PedestrianPathAI.
var basic=0; var elevated=1; var bridge=2; var slope=3; var tunnel=4; var segment=0; var node=1;
var asset=ToolsModifierControl.toolController.m_editPrefabInfo as NetInfo;
NetInfo.Segment seg = null; NetInfo.Node nod = null; var ai = (asset.m_netAI as RoadAI);
Action<int, int, int, float> NetworkTiling = (network, type, id, tiling) => { id--;
if (type == 0) {
if (network == 0) seg = asset.m_segments[id];
else if (network == 1) seg = ai.m_elevatedInfo.m_segments[id];
else if (network == 2) seg = ai.m_bridgeInfo.m_segments[id];
else if (network == 3) seg = ai.m_slopeInfo.m_segments[id];
else if (network == 4) seg = ai.m_tunnelInfo.m_segments[id]; }
else if (type == 1) {
if (network == 0) nod = asset.m_nodes[id];
else if (network == 1) nod = ai.m_elevatedInfo.m_nodes[id];
else if (network == 2) nod = ai.m_bridgeInfo.m_nodes[id];
else if (network == 3) nod = ai.m_slopeInfo.m_nodes[id];
else if (network == 4) nod = ai.m_tunnelInfo.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 in the road editor segment/node UI
// A couple examples: (delete and add your own)
NetworkTiling(basic, segment, 1, 2.0f);
NetworkTiling(elevated, node, 1, 3.0f);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment