- Home /
scrolling through animation with sliders
Hi I am wondering if there is a way to scroll backwards and forwards through an animation with the use of a slider. I tried approaching it the following way but it doesnt work. In this case a,b,c ... are 5 frame sections of one animation
var hSliderValue : int = 0.0; var style : GUIStyle;
var level : int ; var testanims = new Array("a","b","c","d","e","f","g","h","i");
function OnGUI () { GUI.skin.horizontalSlider = style; hSliderValue = GUILayout.HorizontalSlider (hSliderValue, 0,9);
if (hSliderValue == 1) { animation.CrossFade(testanims[a]); } if (hSliderValue == 2) { animation.CrossFade(testanims[b]); } if (hSliderValue == 3) { animation.CrossFade(testanims[c]); }
if (hSliderValue == 4) { animation.CrossFade(testanims[d]); } if (hSliderValue == 5) { animation.CrossFade(testanims[e]); } if (hSliderValue == 6) { animation.CrossFade(testanims[f]); } if (hSliderValue == 7) { animation.CrossFade(testanims[g]); } if (hSliderValue == 8) { animation.CrossFade(testanims[h]); } if (hSliderValue == 9) { animation.CrossFade(testanims[i]); }
}