Skip to content

Instantly share code, notes, and snippets.

@ronyx69
ronyx69 / Flag_Script.cs
Last active August 26, 2020 00:04
Script for saving Flag shader params in props. (Added modless shader parameter saving method by boformer.)
// The script will not work properly if you have no texture imported.
//
// The vertex paint of the mesh controls the amount of movement:
// white means no movement and black means maximum movement.
//
// If you're using multiple "flag" textures in one prop, (like vanilla flags)
// the flag must be entirely black and everything else should be white,
// and you can't use the strength variable, otherwise the UV mapping will break.
// The flag should be UV mapped onto the flag on the bottom right of the texture.
@ronyx69
ronyx69 / ShaderChange_Rotors.cs
Last active August 17, 2020 12:11
Change the shader of a prop, building, or building sub mesh to rotors in asset editor. Also deletes LOD.
// Rotors Shader
// Also deletes LOD.
// Prop
var shader = Shader.Find("Custom/Vehicles/Vehicle/Rotors");
var asset = ToolsModifierControl.toolController.m_editPrefabInfo as PropInfo;
if(asset.m_material != null) asset.m_material.shader = shader;
@ronyx69
ronyx69 / NetworkElevationRenamer.cs
Created December 27, 2019 05:40
Renames elevations based on the name of the loaded asset.
// Renames elevations, to fix the game adding 0 or 1 to the elevation names, so that they can be kept consistent when updating a network multiple times.
// Do not run on a newly created network, it must be saved with the final name it should have, loaded again, and only then run this script.
var asset = ToolsModifierControl.toolController.m_editPrefabInfo as NetInfo;
var ai = (asset.m_netAI as TrainTrackAI); // change this to RoadAI or something else if necessary.
if(ai.m_elevatedInfo != null) ai.m_elevatedInfo.name = ai.m_info.name.Substring(0, ai.m_info.name.Length-6) + " E";
if(ai.m_bridgeInfo != null) ai.m_bridgeInfo.name = ai.m_info.name.Substring(0, ai.m_info.name.Length-6) + " B";
if(ai.m_slopeInfo != null) ai.m_slopeInfo.name = ai.m_info.name.Substring(0, ai.m_info.name.Length-6) + " S";
if(ai.m_tunnelInfo != null) ai.m_tunnelInfo.name = ai.m_info.name.Substring(0, ai.m_info.name.Length-6) + " T";
@ronyx69
ronyx69 / Thirty_Fifteen_Curb.cs
Last active March 31, 2020 10:42
Attempts to find all -30cm roads and lifts them to -15cm. Doesn't work for LOD. Also updates all segments (therefore lanes too) so vehicles jump up to the new height.
var networks = Resources.FindObjectsOfTypeAll<NetInfo>();
for(uint i = 0; i < networks.Length; i++)
{
var network = networks[i];
if(network == null) continue;
if(network.m_netAI == null) continue;
if(network.m_netAI.GetType().Name != "RoadAI" &&
network.m_netAI.GetType().Name != "RoadBridgeAI" &&
network.m_netAI.GetType().Name != "RoadTunnelAI") continue;
{
@ronyx69
ronyx69 / PropRotating_Multiple_Script.cs
Last active June 23, 2019 16:07
Script for saving PropRotating params in props for multiple rotating parts. (Added modless shader parameter saving method by boformer.)
// Prop Rotating Script for multiple rotating parts.
// Control rotation axis, pivot and speed.
// Run in asset editor and see effects in real time.
// Prop Rotating Params Mod is not required for using the scripts and saving the asset.
// It's only needed to load the data in-game.
// The LODs are not rotating, they are like regular props.
@ronyx69
ronyx69 / BuildingBaseMeshDelete.cs
Last active June 18, 2019 00:27
Script for deleting the automatically generated base mesh for buildings or building sub meshes.
// Deletes automatically generated base mesh based on vertex colors.
// Changes shader to NoBase, enables noBase boolean, raises or lowers vertices too close to 0.
var subMesh = -1; // sub mesh id, order as in ui, starting from 0 (-1 means main building mesh)
var asset = ToolsModifierControl.toolController.m_editPrefabInfo as BuildingInfo;
var m = asset.m_mesh; var shader = Shader.Find("Custom/Buildings/Building/NoBase"); var newVertCount = 0;
if(subMesh >= 0) { m = asset.m_subMeshes[subMesh].m_subInfo.m_mesh;
if(asset.m_subMeshes[subMesh].m_subInfo.m_material != null) asset.m_subMeshes[subMesh].m_subInfo.m_material.shader = shader;
if(asset.m_subMeshes[subMesh].m_subInfo.m_lodMaterial != null) asset.m_subMeshes[subMesh].m_subInfo.m_lodMaterial.shader = shader;
@ronyx69
ronyx69 / FlagParams_Vehicle_Script.cs
Last active June 8, 2019 15:24
Script for saving Flag shader params in vehicle sub meshes. Still requires the Flag Params mod.
// for vehicles, vertex colors get generated and overwritten on import
// therefore you need to import the rotors sub mesh as a prop, save, reload
// and then import the vehicle sub mesh,
// and copy the vertex paint from the prop to the vehicle sub mesh using this script:
var subMesh = 1; // vehicle sub mesh id, starting from 1
var asset2 = PrefabCollection<PropInfo>.FindLoaded("filename.Asset Name_Data"); // CHANGE TO PROP NAME
@ronyx69
ronyx69 / Decal_Script.cs
Last active June 8, 2019 14:50
Script for creating decals of any size using a premade mesh you can download here: https://drive.google.com/open?id=1hr6l0HO76g3K7tV3At_Brx29-EHxDVAQ (Based on original script by boformer. Added modless shader parameter saving method by boformer.)
// Decal Script (based on original script by boformer)
// (added modless shader parameter saving method by boformer)
//
// Removes the need for making a mesh, just import the provided decal mesh
// and this script will automatically change the size you set.
//
// Warning: Do not save vehicles after running this script without a game restart!
var size = new Vector2(8.0f, 8.0f); // Size of decal in meters - width and length
@ronyx69
ronyx69 / Vehicle_PropMesh_Copy.cs
Last active May 19, 2019 16:21
Copies mesh from a prop to a vehicle, don't use for vehicles with tyres.
// Copies mesh from a prop to a vehicle, don't use for vehicles with tyres.
var propname = "filename.Asset Name"; // filename.Asset Name
var prop = PrefabCollection<PropInfo>.FindLoaded(propname + "_Data");
var asset = ToolsModifierControl.toolController.m_editPrefabInfo as VehicleInfo;
asset.m_mesh.vertices = prop.m_mesh.vertices; asset.m_mesh.triangles = prop.m_mesh.triangles;
asset.m_mesh.tangents = prop.m_mesh.tangents; asset.m_mesh.normals = prop.m_mesh.normals;
asset.m_mesh.uv = prop.m_mesh.uv; asset.m_mesh.bounds = prop.m_mesh.bounds;
@ronyx69
ronyx69 / BuildingSubMesh_FloorParams.cs
Created May 1, 2019 12:57
Change building floor parameters for a sub-mesh.
var subMesh = 0;
var vec = new Vector4(0.0f, 3.1f, 3.0f, 900.1f);
var asset = (ToolsModifierControl.toolController.m_editPrefabInfo as BuildingInfo).m_subMeshes[subMesh].m_subInfo;
asset.m_material.SetVector("_FloorParams", vec);