hey guys texture switch script for an texture animation

hey guys im looking for a script some guys are talking aboute thay say thare is a script that allows you to put more textures on a model and yoy can play tham a a animation on the object

if possible please ad a frame per second time(); so i can tweak the frame rate when i wanted to thanks by the way

This should be incredibly simple to do. I’ll tell you how to do it, but you can code it yourself.

Create a script with these public variables:

  • Array of a material datatype
  • Starting Frame as float
  • Frames per second as float

You’ll also want a private variable:

  • Current frame as float

During the script’s start, put this in it:

CurrentFrame = StartingFrame

During the Update, this is the code you’ll want to put into it

CurrentFrame += (Time.deltaTime * FramesPerSecond)

rem error checking code so we can play animation forwards (positive fps)
if (int(currentFrame) > MaterialArray.Count)
           currentFrame = currentFrame - MaterialArray.Count

rem error checking code so we can play animation backwards (negative fps)
if (int(currentFrame) < 0)
           currentFrame += MaterialArray.Count

rem apply the material to the gameobject

This is all pseudocode, but it’ll work once you get it properly tailored towards the Unity workspace. I haven’t done this specifically in Unity, but this is how I always programmed my animations in my 2D projects and 3D projects in other engines.