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

Pages: 1 2 3 [4] 5 6 ... 9
46
NGUI 3 Support / Re: Scrollview makes FPS drop
« on: January 24, 2014, 10:47:37 AM »
It's not simple text but also "Buttons", all these Labels have colliders and when any of them is clicked all labels fade out, a PageFlip-Animation is played, and the clicked "Quest" appears (UISprite and other UILabels).
If this still is possible to manage with UITextList AND will give me a better perfomance I'll check it out.

47
NGUI 3 Support / Re: Scrollview makes FPS drop
« on: January 24, 2014, 10:36:37 AM »
I see, mhm.

Would it make sense to try something like this:

- I save the reference to the Labels in a seperate Array
- only 5 labels are displayed at a time (for example)
- when the Scrollview is dragged, the label which goes offscreen gets removed from the grid completely, but only temporarily
- when I drag it back, I get the reference and add it back to the grid to it's former position

48
NGUI 3 Support / Re: Scrollview makes FPS drop
« on: January 24, 2014, 09:34:22 AM »
Ah I see.

So beside this "solution" there is nothing I can do?

49
NGUI 3 Support / Re: Scrollview makes FPS drop
« on: January 24, 2014, 09:24:11 AM »
Hm, I don't have Unity Pro.

But I found this topic here: http://www.tasharen.com/forum/index.php?topic=7348.msg34657#msg34657

Would "Plan A" be the solution I'm looking for? If so, how exactly can I recycle the items?

Edit:

In another topic you stated this:

Quote
Culling on panels does not improve performance. It forces the panel to re-evaluate what's visible every singe update, and then re-create draw buffers, which is very slow. It's better to leave it off so that the panel does not do any evaluation, and the draw buffers don't change as you drag the content around.

So why did you suggest it? Does the "Cull"-Setting in the latest version of NGUI make the performance better, indeed?

50
NGUI 3 Support / Re: Scrollview makes FPS drop
« on: January 24, 2014, 09:10:26 AM »
Ah yes, I already tried that yesterday and it is a little bit better, but still, the more Items the Grid has, the lower the framerate gets when the view is dragged/scrolled.

Why does that hit the perfomance at all, when all the widgets are bundled into one DrawCall?

51
NGUI 3 Support / Scrollview makes FPS drop
« on: January 23, 2014, 12:54:26 PM »
Hey there.

Using the latest NGUI Version.

So I have a ScrollView (set to Alpha Clip, I read that's faster than Soft Clip, so I used this instead) with a Childobject: A UIGrid.
This UIGrid holds Labels like this:



So when I fill this grid with Labels on my mobile device (iPhone 4) at first the framerate is fine, but when I fill the ScrollView/Grid with a lot of Labels (let's say around 40++) the FPS drops to 30fps, when I get more then it drops again.
The fun thing is, as long as I don't scroll with my fingers, the FPS stays at 50~FPS, as soon as the finger touches the display and moves the View the fps drops.

Is there a way to prevent that? Did I miss something in the settings?

52
NGUI 3 Support / Re: UISprite Offscreen - Tris Count still goes up
« on: January 23, 2014, 02:48:04 AM »
Ah alright, thanks for the clarification.

53
NGUI 3 Support / UISprite Offscreen - Tris Count still goes up
« on: January 22, 2014, 01:26:36 PM »
Hey there.

So, I noticed something. I don't know if I just set things up the wrong way or this is just the "NGUI way".

Have a look at these stats. As you see I have some UI-Elements. The MenuBook is enabled but offscreen.
The Triscount is 244


Now, when I TriggerEnter the left blue cube I get some Items into my Inventory:


4 new Items = 8 Tris

The TrisCount goes up to 252. Why is that? I mean the Book isn't even "displayed" by the UI-Camera. Shouldn't it only go up to 252 Tris when Camera renders the whole book, meaning when the Book is in the middle of the screen?

So if hit my BookButton which tweens the Book down, the count stays the same.

54
Have a look at your collider! If I'm not mistaken, since the last updates the alpha value influences the collider!
If the Alpha value is 0 the Collider automatically disables.

55
Allright, I got the error, of course only the next child will be faded in since I only check the next child. So I managed to get that work, but now I got another problem.

I editet my script and added another Function, which tweens another Menu:

  1. IEnumerator ShowQuests()
  2.         {
  3.                 spriteComp = questMenu.GetComponentsInChildren<UISprite>();
  4.                 labelComp = questMenu.GetComponentsInChildren<UILabel>();
  5.                 children = questMenu.GetComponentsInChildren<Transform>();
  6.  
  7.  
  8.                 inventoryBtn.isEnabled = false;
  9.                 questsBtn.isEnabled = false;
  10.                 diaryBtn.isEnabled = false;
  11.                 pageFlipper.renderer.enabled = true;
  12.                
  13.                 if(!pageFlipper.IsPlaying("PageForward"))
  14.                 {
  15.                         pageFlipper.Play("PageForward");
  16.                         pageFlipper.AnimationCompleted = HitCompleteDelegate;
  17.                 }
  18.  
  19.                 foreach(UISprite s in spriteComp)
  20.                 {
  21.                         s.alpha = 0.0f;
  22.                         s.enabled = true;
  23.                 }
  24.                 foreach(UILabel l in labelComp)
  25.                 {
  26.                         l.alpha = 0.0f;
  27.                         l.enabled = true;
  28.                 }
  29.                 foreach(Transform c in children)
  30.                 {
  31.                         TweenAlpha twA = TweenAlpha.Begin(c.gameObject, 1.0f, 1.0f);
  32.                         EventDelegate.Add(twA.onFinished, ShowQuestmenu_Finished);
  33.                 }
  34.  
  35.  
  36.                 yield return new WaitForSeconds(1.0f);
  37.  
  38.  
  39.  
  40.         }

So, when the menu is up and I click my InventoryButton, the InventoryMenu fades in.
When I click the Quest-Button the QuestMenu fades in but it also throws this error a couple of times:

Quote
NullReferenceException: Object reference not set to an instance of an object
TweenAlpha.set_value (Single value) (at Assets/NGUI/Scripts/Tweening/TweenAlpha.cs:45)
TweenAlpha.OnUpdate (Single factor, Boolean isFinished) (at Assets/NGUI/Scripts/Tweening/TweenAlpha.cs:51)
UITweener.Sample (Single factor, Boolean isFinished) (at Assets/NGUI/Scripts/Tweening/UITweener.cs:282)
UITweener.Update () (at Assets/NGUI/Scripts/Tweening/UITweener.cs:208)

I don't get this. I use the exact same code on this, just other references/names. When the Inventory is tweened no Errors, when the Questmenu is tweened, errors :/




Edit:


Alright, I'll never post again before I have not made some research. After looking up this topic here: http://www.tasharen.com/forum/index.php?topic=7235.msg34119#msg34119
Stuff is clearer now.
Just added an if-Statement this line of code:

Quote
if(c.GetComponent<UILabel>() != null)
         {
            TweenAlpha twB = TweenAlpha.Begin(c.gameObject, 1.0f, 1.0f);
            EventDelegate.Add(twB.onFinished, ShowQuestmenu_Finished);
         }

And the errors are gone, of course.

56
NGUI 3 Support / TweenAlpha doesn't tween all children / Nullreference
« on: January 13, 2014, 09:54:03 AM »
Hey there.

So do I miss something or why does TweenAlpha not tween all of my GameObjects Children?

Here's my setup.

This is my Hierarchy:



So my "01INVENTORYMENU" is an empty GameObject.
The Objects: "ITEMGRID", "Sticker", "Textbox" are simple Sprites:



The Objects "SLOT1" to "SLOT4" are empty UI-Widgets. "Itemlabel" is a simple label:



All the Sprite- and Label-Components are disabled by default.

So, what do I want to achieve:

I have an InventoryButton, when clicked this button and other buttons are disabled for a moment, an Animation is played and other stuff happens. This other stuff includes setting the Alpha-Value of the Children of "01INVENTORYMENU" to 0.0f and enabling the Sprite/Label-Components. This is how I do it:

  1.  
  2. public GameObject pageFlipper;
  3.         public tk2dSpriteAnimator flipperAnimator;
  4.  
  5.         public GameObject inventoryMenu;
  6.  
  7.         private UISprite[] spriteComp;
  8.         private UILabel[] labelComp;
  9.  
  10. // Start-Function just adds the EventDelegates...
  11.  
  12. IEnumerator ShowInventory()
  13.         {
  14.                 inventoryBtn.isEnabled = false;
  15.                 questmenuyBtn.isEnabled = false;
  16.                 diarymenuBtn.isEnabled = false;
  17.                 pageFlipper.renderer.enabled = true;
  18.  
  19.                 if(!flipperAnimator.IsPlaying("PageForward"))
  20.                 {
  21.                         flipperAnimator.Play("PageForward");
  22.                         flipperAnimator.AnimationCompleted = HitCompleteDelegate;
  23.                 }
  24.  
  25.                 foreach(UISprite s in spriteComp)
  26.                 {
  27.                         s.alpha = 0.0f;
  28.                         s.enabled = true;
  29.                 }
  30.                 foreach(UILabel l in labelComp)
  31.                 {
  32.                         l.alpha = 0.0f;
  33.                         l.enabled = true;
  34.                 }
  35.                 foreach(Transform child in inventoryMenu.transform)
  36.                 {
  37.                         TweenAlpha.Begin(child.gameObject, 1.0f, 1.0f);
  38.                 }
  39.  
  40.                 yield return new WaitForSeconds(2.0f);
  41.  
  42.                 inventoryBtn.isEnabled = true;
  43.                 questmenuyBtn.isEnabled = true;
  44.                 diarymenuBtn.isEnabled = true;
  45.  
  46.         }

I dragged and drop "01INVENTORYMENU" into the "inventoryMenu"-variable from the script.

And it works, but only the GameObject "ITEMGRID" is faded in. The UISprite/-Label-Components are enabled and the Alpha-Value is set to 0.0f, but they won't fade in. Just for testing I dragged "Sticker" in there, and only the child "Textbox" did fade in, but not the "Itemlabel".

Is there something wrong with my code?







57
NGUI 3 Support / Re: TweenPosition and OnFinished sending same event?
« on: January 11, 2014, 06:32:17 PM »
Yeah, but I thought NOT removing was the point of it.
I thought by ADDING the notification STAYS there and will be notified everytime the tween is finished, but obviously it doesn't do that, at least not the way I want to...

This way it is removed and "created" anew. It seems to work and suits my needs, but I just thought the other way would be more logical to work with.

58
NGUI 3 Support / Re: Label being a Button
« on: January 11, 2014, 06:26:29 PM »
Ah, you mean simply:

  1. void Clicked(GameObject g)
  2.         {
  3.                 // Debug.Log("Any was clicked");
  4.         }

That got rid of the errors, indeed, but it doesn't seem to work. When I click a Label which are also in the list, nothing Debugs.

(Edit: Don't think it doesn't Debug because of the CommentPart, the actual code does not have "//"  ;)  )

I wanted to use the UIButton-Script in the first place! But the Colors are bugging me :D
The idea was: when I click a Label it should fade out, but when I do so and hover around the area it immediately sets for some frames  its alpha-value back to 1 in order to represent the Hover-Color and then fades-out again.

59
NGUI 3 Support / Re: TweenPosition and OnFinished sending same event?
« on: January 11, 2014, 06:10:54 PM »
You mean like this:
  1. EventDelegate.Add(tp.onFinished, Fin1, false);
  2.  

Hm, if I pass "false" as third argument, nothing changes. But if I use "true" it works as it should and in the Inspector the particular OnFinished-Notification shows up and is removed after finishing.

60
NGUI 3 Support / TweenPosition and OnFinished sending same event?
« on: January 11, 2014, 01:38:58 PM »
Hey there,

so I spent the last hours trying to get to know the scripting side of NGUI (working with the latest version), especially the new way handling Events. I looked up the Upgrade-Tutorials and used the Searchfunction and got things to work.
Now I have a little problem. I don't know if it's my own stupidity or maybe a bug, so please enlighten me :D

I want to achieve this:

I have a Button at the Bottom of the Screen and a Sprite which is positioned by default offscreen at the top of the screen.
When the Button is hit the first time, the Sprite should come down (using TweenPosition) and stay at the middle of the screen.
Then, when the Button is hit again that certain sprites goes back to its initial position offscreen.

This is what I'm doing right now:

  1. using UnityEngine;
  2. using System.Collections;
  3.  
  4. public class BookButton : MonoBehaviour
  5. {
  6.  
  7.                 public bool firstTap;
  8.                 private GameObject gameBook;
  9.                 private UIButton btn;
  10.  
  11.                 // Use this for initialization
  12.                 void Start ()
  13.                 {
  14.  
  15.                                 firstTap = false;
  16.                                 gameBook = GameObject.FindGameObjectWithTag ("GAMEBOOK");
  17.                                 btn = GetComponent<UIButton> ();
  18.        
  19.                 }
  20.  
  21.                 public void BookClick ()
  22.                 {
  23.  
  24.                                 if(firstTap)
  25.                                 {
  26.                                 TweenPosition tp = TweenPosition.Begin(gameBook, 1.0f, new Vector3(gameBook.transform.localPosition.x,
  27.                                                                                              350.0f,
  28.                                                                                              gameBook.transform.localPosition.z));
  29.                                 EventDelegate.Add(tp.onFinished, Fin1);
  30.                                 }
  31.  
  32.                         else
  33.                         {
  34.                         TweenPosition tp2 = TweenPosition.Begin(gameBook, 1.0f, new Vector3(gameBook.transform.localPosition.x,
  35.                                                                                            -350.0f,
  36.                                                                                            gameBook.transform.localPosition.z));
  37.                         EventDelegate.Add(tp2.onFinished, Fin2);
  38.                         }
  39.  
  40.  
  41.  
  42.                 }
  43.  
  44.  
  45.         void Fin1()
  46.         {
  47.                 firstTap = false;
  48.                 Debug.Log("FIN1");
  49.         }
  50.  
  51.         void Fin2()
  52.         {
  53.                 firstTap = true;
  54.                 Debug.Log("FIN2");
  55.  
  56.         }
  57. }
  58.  

When I hit PLAY in Unity and start clicking the Button the first time the Sprite comes down, when I hit it again it goes back up, hitting it again it comes back down. Hitting it again, nothing happens. It doesn't move back up.
What is interesting though is the change of my firstTap-bool:

First Time hitting the Button: sprites comes down -> true
Second Time hitting the Button: sprites comes down -> false
Third Time hitting the Button: sprites comes down -> false

Another more interesting thing is:
When I hit the Button the first time, Debug.Log prints "FIN2", which is right, but when I hit it again in order to move the sprite back Debug.Log prints "FIN1" but also "FIN2" again! That shouldn't be the case, because TweenPosition tp is played and finished, why is the EventDelegate sending both Events? Did I miss something?

Pages: 1 2 3 [4] 5 6 ... 9