Skip to content

Instantly share code, notes, and snippets.

@ronyx69
Last active April 10, 2023 12:33
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save ronyx69/558a2adbe7557da62ea7a7153b86e74c to your computer and use it in GitHub Desktop.
Save ronyx69/558a2adbe7557da62ea7a7153b86e74c to your computer and use it in GitHub Desktop.
Scripts for saving AnimUV params in props. (Added modless shader parameter saving method by boformer.)
// Anim UV Scripts
// Create scrolling or multi-frame animations for props.
// Run in asset editor and see effects in real time.
// Animated faces must be vertex painted black! The rest reimains white.
// Shades of gray animate slower, don't use unless you know what you're doing.
// Google how to do vertex color painting in your 3d software of choice!
// The LODs are not UV animated, they are like regular props.
// (added modless shader parameter saving method by boformer)
// AnimUV Simplified Script
// Simple UV scrolling animation
var time = 2; // Length of animation loop in seconds.
var fps = 30; // Frames per second, more than 60 not recommended.
var sideways = false; // Set to true if you want horizontal UV scroll.
var reverse = false; // Set to true to reverse the scrolling direction.
var asset = ToolsModifierControl.toolController.m_editPrefabInfo as PropInfo;
var shader = Shader.Find("Custom/Props/Prop/AnimUV");
asset.m_material.shader = shader;
shader = Shader.Find("Custom/Props/Prop/Default");
asset.m_lodMaterial.shader = shader;
var tx=0f; var ty=0f;
if(sideways==true) tx=1f/(fps*time); else ty=1f/(fps*time);
if(reverse==true) { tx=0-tx; ty=0-ty; }
var frames = 1f*fps*time;
var cycles = 60f/time;
var vec = new Vector4(tx, ty, frames, cycles);
asset.m_material.SetVector("_RollParams0", vec);
var vectorProps = Type.GetType("ColossalFramework.Packaging.ShaderUtil, ColossalManaged").GetField("vectorProps").GetValue(null) as string[];
vectorProps[5] = "_RollParams0";
// AnimUV Advanced Script
// Full control over AnimUV paramaters
var tx = 1f; // X coordinate transform amount, 1f = full width of image
var ty = 1f; // Y coordinate transform amount, 1f = full height of image
var frames = 30f; // Amount of transforms per cycle. Amount of animation frames.
var cycles = 60f; // Animation cycles per minute.
var asset = ToolsModifierControl.toolController.m_editPrefabInfo as PropInfo;
var shader = Shader.Find("Custom/Props/Prop/AnimUV");
asset.m_material.shader = shader;
shader = Shader.Find("Custom/Props/Prop/Default");
asset.m_lodMaterial.shader = shader;
var vec = new Vector4(tx, ty, frames, cycles);
asset.m_material.SetVector("_RollParams0", vec);
var vectorProps = Type.GetType("ColossalFramework.Packaging.ShaderUtil, ColossalManaged").GetField("vectorProps").GetValue(null) as string[];
vectorProps[5] = "_RollParams0";
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment