Show Posts

This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.


Messages - baustin27

Pages: [1]
1
NGUI 3 Support / Re: Controlling Animations with a slider
« on: April 23, 2014, 01:42:31 AM »
Im also having a problem with linking animation with ui slider, im new to coding all together.

I know using the gui in unity you use this on the object that has the animation, but what would you do for the ngui slider?

  1. public class slidertest : MonoBehaviour {
  2.  
  3.         private AnimationState myanim;
  4.         public float hSliderValue = 0.0F;
  5.  
  6.         // Use this for initialization
  7.         void Start () {
  8.  
  9.                 myanim = animation ["anim"];
  10.        
  11.         }
  12.        
  13.         // Update is called once per frame
  14.         void Update () {
  15.        
  16.         }
  17.  
  18.         void LateUpdate(){
  19.                 myanim.time = hSliderValue;
  20.                 myanim.enabled = true;
  21.  
  22.                 animation.Sample ();
  23.                 myanim.enabled = false;
  24.  
  25.                 }
  26.  
  27.  
  28.         void OnGUI() {
  29.                 hSliderValue = GUI.HorizontalSlider(new Rect(25, 25, 100, 30), hSliderValue, 0.0F, myanim.length);
  30.         }
  31. }
  32.  

Pages: [1]