Last active
May 29, 2022 16:00
-
-
Save ronyx69/55f2201f2d1f2d8f6c81042c7a47e47d to your computer and use it in GitHub Desktop.
Script for saving PropRotating params in props. (Added modless shader parameter saving method by boformer.)
This file contains 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
// Prop Rotating Script | |
// Control rotation axis, pivot and speed. | |
// Run in asset editor and see effects in real time. | |
// Animated faces must be vertex painted black! The rest reimains white. | |
// Google how to do vertex color painting in your 3d software of choice! | |
// The LODs are not rotating, they are like regular props. | |
// (added modless shader parameter saving method by boformer) | |
var axis = new Vector3(1.0f, 0.0f, 0.0f); // Set to 1 to choose rotation axis. | |
var pivot = new Vector3(0.0f, 5.0f, 0.0f); // Pivot point - center of rotation. | |
var speed = 60.0f; // rotations per minute | |
var asset = ToolsModifierControl.toolController.m_editPrefabInfo as PropInfo; | |
if(asset.m_rollParams==null) Array.Resize(ref asset.m_rollParams, 4); | |
var vec = new Vector4(axis.x, axis.y, axis.z, speed); asset.m_rollParams[0]=vec; | |
if(asset.m_rollLocation==null) Array.Resize(ref asset.m_rollLocation, 4); | |
var vec2 = new Vector4(pivot.x, pivot.y, pivot.z, 1.0f); asset.m_rollLocation[0]=vec2; | |
var veca = new Vector4(0, 0, 0, 1); asset.m_rollLocation[1]=veca; asset.m_rollLocation[2]=veca; asset.m_rollLocation[3]=veca; | |
var vecb = new Vector4(0, 1, 0, 10); asset.m_rollParams[1]=vecb; asset.m_rollParams[2]=vecb; asset.m_rollParams[3]=vecb; | |
for (int i = 0; i < 4; i++) { | |
asset.m_material.SetVector("_RollParams" + i, asset.m_rollParams[i]); | |
asset.m_material.SetVector("_RollLocation" + i, asset.m_rollLocation[i]); } | |
var shader = Shader.Find("Custom/Props/Prop/Rotating"); if(asset.m_material != null) asset.m_material.shader = shader; | |
shader = Shader.Find("Custom/Props/Prop/Default"); if(asset.m_lodMaterial != null) asset.m_lodMaterial.shader = shader; | |
asset.m_lodHasDifferentShader=true; | |
var vectorProps = Type.GetType("ColossalFramework.Packaging.ShaderUtil, ColossalManaged").GetField("vectorProps").GetValue(null) as string[]; | |
vectorProps[4] = "_RollLocation0"; vectorProps[5] = "_RollParams0"; vectorProps[6] = "_RollLocation1"; vectorProps[7] = "_RollParams1"; | |
vectorProps[8] = "_RollLocation2"; vectorProps[9] = "_RollParams2"; vectorProps[10] = "_RollLocation3"; vectorProps[11] = "_RollParams3"; | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment