I got it working! Thanks @vfxjex
For anybody thats looking for how I got it to work, I put a step-by-step tutorial (Im still a noob to Unity so my explanation is very basic!!)
Lets use a simple example to demonstrate how to use a slider to control a simple animated object that has been exported (fbx)
Im using a model of fingers pinching a skin anatomical figure that I built and animated called 'handAnimationsv002'. I’ve exported the model, joints and blend shape (animated from frame 0-24). I will refer to the names I used in the project, but substitute whatever you may have. Use these images to reference the figuresImport your fbx into your Unity project (Im using the 2D option)
Figure 1. Select your model. Go into the ‘Rig’ tab. Change Animation type to Legacy and hit Apply.
Figure 2 Create your Canvas (this will add an EventSystem to your project). Drag your fbx over the canvas to create a child of Canvas.
I adjusted the scale and rotation for this just because my export came out too small. Ive also put in a directional light (default) to light this model.
Expand the fbx icon in your project folder to reveal all the parts of the model.
Ive changed name of the icon with the play button to ‘animateHand’ for the script later.
Drag the ‘animateHand’ icon into the value of Animation and make sure your size is set to 1.
Hit Play. You may not see anything. In this case. Ive adjusted both my canvas and main camera settings. I also switched over to 3D view temporarily to see how things are aligned.
Figure 3 Take note of your Pos X and Pos Y to use on your Main Camera Settings. Change the render mode to ‘World Space’ .
Figure 4 Select the Main Camera and Plug in the X and Y position to match the canvas.
Using your 3D scene, move the camera in Z-Axis to get your models in view.
Adjust the Size and Clipping Planes accordingly.
Hit Play now and the scene should be in place. If you notice the object animates, turn off ‘Play Automatically’ on ‘handAnimationsv002’ setting
Figure 5 Create the script ‘AnimControl’ and copy paste this script (courtesy of @vfxjex )
using UnityEngine; using UnityEngine.UI; using System.Collections;
public class AnimControl : MonoBehaviour { Animation anim;
//Drag and drop your Slider into this variable.
public Slider slider;
// Use this for initialization
void Start () {
anim = GetComponent<Animation> ();
//Make sure you have attached your animation in the Animations attribute
anim.Play ("animateHand");
anim ["animateHand"].speed = 0;
}
void Update (){
anim ["animateHand"].normalizedTime = slider.value;
}
}
Select ‘handAnimationsv002’ in the hierarchy and drag the AnimControl script into the components area Then drag ‘Slider’ into the ‘slider value’
Figure 6 Select Slider in the hierarchy and drag Slider to the On Value Changed (Single) value
Figure 7 Select value for the Function
Press Play and try it!!