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 - NineTails

Pages: [1]
1
NGUI 3 Support / Dual Sliders on the one game object
« on: July 31, 2014, 12:10:45 PM »
What I have is one game object with two sliders attached to it. I've wrote code that stops the thumbs from ever going over each other. So each slider shares the same background and foreground but is stopped when the met along the line. Should slider one move .3 along the length, slider two can move .7.

What I have is a cube where each face of it is controlled by one slider (I've 3 total with 2 sliders each for a total of 6 sliders). When the slider moves it moves the corresponding face. When the cubes face is moved, the centre point is recalculated and it simulates I'm pushing out a wall or something.

However, what I need is for this cube to have a value of 0 where ever these points meet based on the sliders values. Thus if I push out one cube face by .3, if I bring in my other slider would travel the rest of way and make my cube extremely skinny (on the x axis).

Code looks like this (only doing X just now):

  1.         private void SliceXPos()
  2.         {
  3.                 xPVal =  xsliderTwo.value * maxX ;
  4.         }
  5.  
  6.         private void SliceXNeg()
  7.         {
  8.                 xNVal = xsliderOne.value * -maxX;
  9.         }

Then in my update method I'm doing the following to the cube:
  1. sliceBox.transform.localScale = new Vector3(xPVal - xNVal, yPVal - yNVal, zPVal - zNVal);
  2.                         sliceBox.transform.localPosition = new Vector3((xPVal - xNVal) / 2 + xNVal, (yPVal - yNVal) / 2 + yNVal, (zPVal - zNVal) / 2 + zNVal);
  3.  

I'm also passing the values along via this code:

  1.         xSliders = xObject.GetComponents<UISlider>();
  2.                 if (xSliders == null || xSliders.Length < 2)
  3.                 {
  4.                         this.enabled = false;
  5.                         Debug.LogWarning("Script Requires 2 UISliders");
  6.                 }
  7.                 else
  8.                 {
  9.                         xsliderOne = xSliders[0];
  10.                         xsliderTwo = xSliders[1];
  11.  
  12.                         EventDelegate.Add(xsliderOne.onChange, Clamp);
  13.                         EventDelegate.Add(xsliderTwo.onChange, Clamp);
  14.  
  15.                         EventDelegate.Add(xsliderOne.onChange, SliceXNeg);
  16.                         EventDelegate.Add(xsliderTwo.onChange, SliceXPos);
  17.                 }

Can someone please tell me where my math is wrong on this as I can't seem to get it working correctly

2
NGUI 3 Support / Resetting Typewriter effect
« on: May 08, 2014, 03:35:36 AM »
I'm having an issue with the type writer effect on my label.

Right now I have my text appearing in a speech bubble. The speech bubble grows in scale from 0 to around 3. When the bubble reaches its maximum size, I'm wanting the type writer effect to begin. Then when the bubbles shrinks and comes back into play, I'm wanting the effect to start again from the beginning.

However, the effect seems to constantly play. If I open and close my bubble, the type writer effect seems to reduce the amount of letters it types.

Could someone please show me the best way to get the typewriter effect to play when my bubble is at full size?   

3
NGUI 3 Support / Controlling Animations with a slider
« on: April 19, 2014, 05:39:57 AM »
I'm trying to tie up my animation to a slider. When I play, the slider length should be that of my animation and when I drag the slider, it should play the appropriate part of the animation.

However, I'm having some real issues doing this.

This is what I have so far

  1.         public AnimationClip animation1;
  2.         public UISlider slider;
  3.  
  4.         // Use this for initialization
  5.         void Start ()
  6.         {
  7.                 anim.clip = animation1;
  8.                 anim.Play();
  9.                 float animationLength = slider.value * animation1.length;
  10.                 slider.value = animationLength;
  11.        
  12.         }

But this is wrong. Could someone please help me out?

4
NGUI 3 Support / Another slider issue
« on: March 21, 2014, 07:03:46 AM »
This is a follow on from my last message which helped. Thank you.

In my scene I have a list of elapsed days between two points created by the DataTime class in C#. This returns a double.

I'm now trying to make it so my slider will return the day in the list as it scrolls along. For example if I have 30 elements in my list, it'll return the 15th element when it hits 0.5 slider value etc etc. The data held in the list comes back like the following:

11/12/2001

This is my code so far:

  1.         // Update is called once per frame
  2.         void Update ()
  3.         {
  4.  
  5.                 sliderElement.value = float.Parse(elapsedString);
  6.         }
  7.  
  8.         void Slider()
  9.         {
  10.                 startTime = new DateTime(startYear, startMonth, startDay);
  11.                 endTime = new DateTime(endYear, endMonth, endDay);
  12.                
  13.                 TimeSpan elapsed = endTime.Subtract(startTime);
  14.                
  15.                 startString = startDay.ToString();
  16.                 elapsedString = elapsed.TotalDays.ToString();
  17.                
  18.  
  19.                 int totalDays = (int)endTime.Subtract(startTime).TotalDays;
  20.                
  21.                 days.Add(startTime);
  22.                
  23.                 for (var i = 1; i < totalDays; i++)
  24.                 {
  25.                         days.Add(startTime.AddDays(i));
  26.                 }
  27.                
  28.                 days.Add(endTime);     
  29.         }

However, when I run the following my slider is permanently stuck at 1 and I can't move it. When I debug out the value, it returns 1 (where I hoped it would return the last date in the list).

Could someone help me out?

5
NGUI 3 Support / Re: 3.5 Slider issues
« on: March 20, 2014, 04:57:58 AM »
Ah ok.

My question still stands though. Is there a way I can set the width of this to equal my list length? I need to the two to sink,.

6
NGUI 3 Support / 3.5 Slider issues
« on: March 19, 2014, 11:52:27 AM »
I'm having an issue getting my around the new slider in 3.5.

I've set up my slider so I can move it up and down but now I want to dynamically alter the slider so that it's length is equal to the length of one of my lists. How ever I know the slider only works on scale of 0-1.

How can I make it so the length of my slider is equal to that of a list with X amount inside it?

7
NGUI 3 Support / Fade out a sprite
« on: January 01, 2014, 12:11:07 PM »
I'm trying to have some of my GUI elements fade out. However, I've spent the day trying to do this and I've gotten no where. I know its a matter of decressing the alpha value to fade the image out, but what I've been doing isn't working.

Has anyone ever managed to make an NGUI object fade out on the screen? If so, could you please inform me as to how you've done it?

Pages: [1]