Skip to content

Instantly share code, notes, and snippets.

@ronyx69
ronyx69 / DetailScripts.cs
Last active July 16, 2018 15:34
Scripts for props and trees for the Detail mod. Mod is not required for creating and saving the asset.
// Detail Script
// Tags a prop as detail prop for custom render distance and optional color matching.
var lod = 100f; // Distance at which LOD appears.
var max = 200f; // Distance at which the prop disappears.
var vegetation = true; // Set to true for color variations override according to Detail mod settings.
@ronyx69
ronyx69 / FlipXZ_Script.cs
Last active July 6, 2018 08:21
Tags a rotors shader vehicle sub mesh for Rotors FlipXZ mod.
// FlipXZ Script
// Tags a rotors shader vehicle sub mesh for Rotors FlipXZ mod.
var subMesh = 1; // vehicle sub mesh id, starting from 1
var asset = ToolsModifierControl.toolController.m_editPrefabInfo as VehicleInfo;
asset.m_subMeshes[subMesh].m_subInfo.m_UIPriority = 120122;
@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 / AdditiveShader_mod.cs
Last active August 4, 2018 13:10
Source code for the Additive Shader mod.
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using ICities;
using UnityEngine;
using System.Reflection;
using System.Runtime.InteropServices;
using System.Threading;
using System.Xml.Serialization;
@ronyx69
ronyx69 / CitizenWalkSpeed.cs
Created June 5, 2018 17:31
Change walk speed of all citizens.
for (uint i = 0; i < PrefabCollection<CitizenInfo>.LoadedCount(); i++) {
var prefab = PrefabCollection<CitizenInfo>.GetLoaded(i);
if (prefab == null) continue; prefab.m_walkSpeed = 0.5f; }
@ronyx69
ronyx69 / AnimUV_VehicleSubMesh.cs
Created June 5, 2018 14:36
Copy vertex paint from a prop to a vehicle sub mesh. Apply and save AnimUV params.
// Anim UV Scripts
// Create scrolling or multi-frame animations for vehicle sub meshes.
// Run in asset editor and see effects in real time.
// AnimUV Params Mod is not required for using the scripts and saving the asset.
// It's only needed to load the data in-game.
// Animated faces must be vertex painted black! The rest reimains white.
@ronyx69
ronyx69 / Rotors_VehicleSubMesh.cs
Last active January 9, 2019 12:46
Copy vertex paint from prop to vehicle sub mesh, use rotors shader on a vehicle sub mesh, adjust shader and tyre parameters.
// reminder: the y axis ingame represents height
// (as opposed to z, usually used in 3d software)
// copy vertex paint from prop to vehicle sub mesh
// vertex color explanation
// RED for blimps(visibility): 0 visible when spinning, 255 visible when stopped
// IDK what red will do on other vehicles
@ronyx69
ronyx69 / Flags_VehicleSubMesh.cs
Created May 29, 2018 17:28
Change the flags of a vehicle sub mesh in asset editor.
var subMesh = 0; // sub mesh id, order as in ui, starting from 1 (0 is main mesh)
var asset = ToolsModifierControl.toolController.m_editPrefabInfo as VehicleInfo;
// required and forbidden flags, use | to set multiple flags
asset.m_subMeshes[subMesh].m_vehicleFlagsRequired = Vehicle.Flags.Created | Vehicle.Flags.Flying;
asset.m_subMeshes[subMesh].m_vehicleFlagsForbidden = Vehicle.Flags.Reversed;
// parked flags
asset.m_subMeshes[subMesh].m_parkedFlagsRequired = VehicleParked.Flags.CustomName;
@ronyx69
ronyx69 / Flags_BuildingSubMesh.cs
Created May 29, 2018 17:17
Change the flags of a building sub mesh in asset editor.
var subMesh = 0; // sub mesh id, order as in ui, starting from 0
var asset = ToolsModifierControl.toolController.m_editPrefabInfo as BuildingInfo;
// required and forbidden flags, use | to set multiple flags
asset.m_subMeshes[subMesh].m_flagsRequired = Building.Flags.Created | Building.Flags.Active;
asset.m_subMeshes[subMesh].m_flagsForbidden = Building.Flags.Abandoned;
// all building flags:
/*
@ronyx69
ronyx69 / ShaderChange_VehicleSubMesh_PropDefault.cs
Created May 29, 2018 17:03
Change the shader of a vehicle sub mesh to prop default in asset editor.
var subMesh = 1; // sub mesh id, order as in ui, starting from 1
var shader = Shader.Find("Custom/Props/Prop/Default"); // the shader to use
var asset = ToolsModifierControl.toolController.m_editPrefabInfo as VehicleInfo;
asset.m_subMeshes[subMesh].m_subInfo.m_material.shader = shader;
asset.m_subMeshes[subMesh].m_subInfo.m_lodMaterial.shader = shader;