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

Pages: [1]
1
NGUI 3 Support / Re: Change sprite on click
« on: July 27, 2014, 09:55:41 AM »
I managed to fix it like this:

  1. IEnumerator ButtonClick()
  2.     {
  3.         if (PlayerPrefs.GetInt("music") == 1)
  4.         {
  5.             //disable music
  6.             gameObject.GetComponent<UIButton>().normalSprite = "music-off";
  7.             PlayerPrefs.SetInt("music", 0);
  8.             player.mute = true;
  9.         }
  10.         else if (PlayerPrefs.GetInt("music") == 0)
  11.         {
  12.             //enable music
  13.             gameObject.GetComponent<UIButton>().normalSprite = "music";
  14.             PlayerPrefs.SetInt("music", 1);
  15.             player.mute = false;
  16.         }
  17.         pressAnimation.PlayQueued("Button");
  18.         yield return new WaitForSeconds(0.3f);
  19.         //gameObject.transform.localScale = new Vector3(1, 1, 1);
  20.     }

I just noticed in the new version of NGUI, the button component also has a Sprite section.
So switch the sprite in the UIButton component instead, works correctly :)

2
NGUI 3 Support / Re: Change sprite on click
« on: July 27, 2014, 09:33:18 AM »
The thing is, it worked perfectly fine with NGUI 3.4.9
No code was modified and I have no OnHover calls anywhere in my game.
I noticed that I can move the mouse on the button, but as soon as the mouse leaves the button, the sprite changes back.

  1. IEnumerator ButtonClick()
  2.     {
  3.         if (PlayerPrefs.GetInt("music") == 1)
  4.         {
  5.             //disable music
  6.             gameObject.GetComponent<UISprite>().spriteName = "music-off";
  7.             PlayerPrefs.SetInt("music", 0);
  8.             player.mute = true;
  9.         }
  10.         else if (PlayerPrefs.GetInt("music") == 0)
  11.         {
  12.             //enable music
  13.             gameObject.GetComponent<UISprite>().spriteName = "music";
  14.             PlayerPrefs.SetInt("music", 1);
  15.             player.mute = false;
  16.         }
  17.         pressAnimation.PlayQueued("Button");
  18.         yield return new WaitForSeconds(0.3f);
  19.         //gameObject.transform.localScale = new Vector3(1, 1, 1);
  20.     }

3
NGUI 3 Support / Change sprite on click
« on: July 27, 2014, 09:19:37 AM »
I was using NGUI 3.4.9 before, so I upgraded to 3.6.8 now.
I have a small script where on click I toggle between 2 sprites.

It worked fine in 3.4.9, but now when I click the button, the sprite changes, but as soon as I move the mouse
the sprite changes back to the first one.

I'm changing the sprite with this code:
  1. gameObject.GetComponent<UISprite>().spriteName = "music-off";

Any ideas? Something changed between these versions?
Thanks!

4
NGUI 3 Support / How to detect current item in Grid?
« on: May 14, 2014, 09:56:03 AM »
So I have a grid with 4 items. each item is in fullscreen and I can scroll between them.
What I want to do, is when I scroll to the last item in my grid, that load up a scene.
How can I detect which item I currently have in view?
I am also using UICenterOnChild. Is there a way to detect from there?

5
NGUI 3 Support / Moving anchored button from code
« on: May 09, 2014, 10:09:01 AM »
I have a button that I want to be able to control his position vertically from code, but I want the button to also stick to right side of the screen for all resolutions.
If I set the anchor to stick for all resolutions, my button cannot be moved vertically from code.

How could I accomplish this, to look good on all resolutions and be able to move the button vertically from script?

6
NGUI 3 Support / Re: UIScroll View problems
« on: May 09, 2014, 07:16:27 AM »
never mind my last question :)
I managed to make it work :) thanks for your help Aren!

7
NGUI 3 Support / Re: UIScroll View problems
« on: May 09, 2014, 06:50:19 AM »
I looked at it but it has a parameter also:
protected override void OnDragDropRelease (GameObject surface)

If I do: protected override void OnClick(GameObject surface)
I get an error: Assets/NGUI/Examples/Scripts/Other/ExampleDragDropItem.cs(50,29): error CS0115: `ExampleDragDropItem.OnClick(UnityEngine.GameObject)' is marked as an override but no suitable method found to override

8
NGUI 3 Support / Re: UIScroll View problems
« on: May 09, 2014, 06:26:06 AM »
thanks for the reply, sounds good.
1 more question. if I have an Item which is not yet in the inventory, I can go ahead and drag it into the inventory, but how could I make it to go to the inventory by clicking it?
I tried to tween it to the inventory, but I think I would need to call some function in order to register it into the scroll view.

9
NGUI 3 Support / UIScroll View problems
« on: May 09, 2014, 05:16:25 AM »
As you can see in the bellow images, I have an inventory list on the side of the screen which is scrollable vertically.
At the bottom of the list I also have a button which collapses and expands the inventory list.
The way I have it setup now is that the collapse button is part of the Grid so it goes up and down with the scrolling list, which is fine until I scroll down, then my button disappears.
Is there a way do a check on that button if it hits the edge of the ScrollView, to stop going further down?

I also tried to put the button separate, out of the Grid list, so it doesn't move with the buttons, but the problem is if I remove items from my list, when my list shrinks the button remains on the bottom.
Again, is it possible to check if the list is shrinked and somehow move the button further up?






10
NGUI 3 Support / Re: HUDText How to clear the label text?
« on: February 09, 2014, 09:52:42 AM »
well I just fixed it in a totally different way :)
I just used the UI follow script on a cube, and referenced a UILabel to it.
That way I just manipulate the UILabel normally.

11
NGUI 3 Support / HUDText How to clear the label text?
« on: February 09, 2014, 08:11:35 AM »
hey I'm working on a game and I'm using HUDText right now to make a countdown timer when a ball hits a trigger.
For example, the ball hits a trigger and the countdown starts from 8.
But if the ball hits the trigger again, the countdown should start from 8 again.
It starts a new label with the number 8 counting down, but the problem is that the previous label is also under this new label and it seems like 2 numbers on top of each other.

I tried to disable and re-enable the HUDText but the countdown continues anyway...
Is there a way to force reset the label?
Or is there a way I can modify HUDText?

Thanks for the help.

Pages: [1]