Script for saving Traffic Light Shader params in props, for Railway Barriers. (Added modless shader parameter saving method by boformer.)
// Traffic Light Shader - Railway Crossing Barriers | |
// Control rotation axis and pivot. | |
// Run in asset editor. | |
// (This is used to be part of the PropRotating mod but that is no longer necessary) | |
// (added modless shader parameter saving method by boformer) | |
// Rotating parts must be vertex painted black! The rest reimains white. | |
// Google how to do vertex color painting in your 3d software of choice! | |
var axis = new Vector3(0.0f, 0.0f, 1.0f); // Set to 1 to choose rotation axis. | |
var pivot = new Vector3(0.0f, 1.1f, 0.0f); // Pivot point - center of rotation. | |
var asset = ToolsModifierControl.toolController.m_editPrefabInfo as PropInfo; | |
var shader = Shader.Find("Custom/Props/Prop/TrafficLight"); | |
if(asset.m_material != null) asset.m_material.shader = shader; | |
if(asset.m_lodMaterial != null) asset.m_lodMaterial.shader = shader; | |
var vec = new Vector4(axis.x, axis.y, axis.z, 10.0f); asset.m_material.SetVector("_RollParams0", vec); | |
var vec2 = new Vector4(pivot.x, pivot.y, pivot.z, 1.0f); asset.m_material.SetVector("_RollLocation0", vec2); | |
asset.m_mesh.name="PropTrafficLight "+axis.x.ToString("R")+" "+axis.y.ToString("R")+" "+axis.z.ToString("R")+" "+"10"+" "+pivot.x.ToString("R")+" "+pivot.y.ToString("R")+" "+pivot.z.ToString("R")+" "; | |
var vectorProps = Type.GetType("ColossalFramework.Packaging.ShaderUtil, ColossalManaged").GetField("vectorProps").GetValue(null) as string[]; | |
vectorProps[4] = "_RollLocation0"; vectorProps[5] = "_RollParams0"; | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment