Skip to content

Instantly share code, notes, and snippets.

@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);
@ronyx69
ronyx69 / Building_PlacementMode_AssetEditor.cs
Created March 24, 2019 13:56
Script for changing the placement mode for buildings.
var asset = ToolsModifierControl.toolController.m_editPrefabInfo as BuildingInfo;
// Possible placement modes:
// Roadside
// Shoreline
// OnWater
// OnGround
// OnSurface
// OnTerrain
@ronyx69
ronyx69 / Vehicle_CustomWheels.cs
Created March 18, 2019 02:03
Copy vertex paint from prop to vehicle, set tire parameters.
// Copy vertex paint from prop to vehicle and set tire parameters.
var asset2 = PrefabCollection<PropInfo>.FindLoaded("filename.Asset Name_Data"); // CHANGE TO PROP NAME
Vector4[] tyres = new Vector4[] { // Tire parameter vectors (X, Y, Z, diameter), add/remove lines if necessary.
new Vector4(-0.739f, 0.328f, 1.421f, 0.328f),
new Vector4(0.739f, 0.328f, 1.421f, 0.328f),
new Vector4(-0.739f, 0.331f, -1.93f, 0.331f),
@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 / Network_SegmentNode_Reorder.cs
Last active September 13, 2020 21:13
Network segment and node reorder scripts. Refreshes UI automatically.
// Network segment and node reorder scripts. Refreshes UI automatically.
// SEGMENTS
var asset = ToolsModifierControl.toolController.m_editPrefabInfo as NetInfo;
@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 / ConvertTextureDump.cs
Created January 15, 2019 13:44
Converts a texture to a different format for dumping with mod tools, for cases where some textures can't be dumped normally. Puts the converted texture in Sunny Properties > Sunny Net > NetProperties >m_downwardDiffuse
// map theme texture
var source = UnityEngine.Object.FindObjectOfType<TerrainProperties>().m_grassDiffuse;
var target = new Texture2D(source.width, source.height, TextureFormat.RGBAFloat, true);
target.SetPixels(source.GetPixels());
target.anisoLevel = source.anisoLevel; target.filterMode = source.filterMode;
target.wrapMode = source.wrapMode; target.Apply();
UnityEngine.Object.FindObjectOfType<NetProperties>().m_downwardDiffuse = target;
@ronyx69
ronyx69 / UpdateBuildingColors_Ingame.cs
Created January 15, 2019 12:14
Refreshes building color variations ingame.
BuildingManager.instance.UpdateBuildingColors();
@ronyx69
ronyx69 / FlagParams_Mod.cs
Last active January 21, 2019 12:24
Source code for the Flag Params mod.
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using ICities;
using UnityEngine;
namespace FlagParams
{
public class FlagParamsMod : LoadingExtensionBase, IUserMod
@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.