Instantly share code, notes, and snippets.

Embed
What would you like to do?
Scripts for saving AnimUV params in props.
// Anim UV Scripts
// Create scrolling or multi-frame animations for props.
// 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.
// 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.
// 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);
asset.m_mesh.name="AnimUV "+tx.ToString("R")+" "+ty.ToString("R")+" "+frames.ToString("R")+" "+ cycles.ToString("R");
// 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);
asset.m_mesh.name="AnimUV "+tx.ToString("R")+" "+ty.ToString("R")+" "+frames.ToString("R")+" "+ cycles.ToString("R");
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment