Last active
April 10, 2021 13:21
-
-
Save ronyx69/b14b6da14529f3b5c43c95031a2101eb to your computer and use it in GitHub Desktop.
Script for saving Traffic Light Shader params in props, for Railway Barriers. (Added modless shader parameter saving method by boformer.)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Traffic Light Shader - Railway Crossing Barriers | |
// Control rotation axis and pivot. | |
// Run in asset editor. | |
// (This used to require 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); | |
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