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 - Aki Kanerva

Pages: [1]
1
NGUI 3 Support / Re: Strategies for avoiding freezes on scene load?
« on: July 28, 2014, 07:04:33 AM »
We have a scrollable map that contains all of the game's levels (55 in total), including level number, icon, player's best time, two par times, and various sprites showing whether or not level-specific goals were reached. Due to an uncommon control method, it's not possible to show this information piecemeal. The total number of NGUI widgets is very high, but as I mentioned, there are no issues at runtime. The map is larger than the screen, so not all of the widgets are always visible (but they still need to wake up to begin with). The 1-2 seconds I mentioned is the sum of time spent on OnEnable(), Awake() and Start() calls on NGUI widgets, mostly sprites and labels.

We already have a load screen. This is not an issue of maximum load time, it's about the frame rate freezing for the time it takes to call Awake() and Start() on a large number of GameObjects that are mostly NGUI widgets, because this isn't asynchronous. The loading screen animation does not advance during this time.

I managed to split the loading somewhat by making each submenu into a prefab, then having a coroutine instantiate them, one per frame. This alleviates the problem a bit, but the map is by far the biggest of the submenus - the others take only a few milliseconds to initialize. It looks like I'll need to somehow split the map into segments as well.

2
NGUI 3 Support / Strategies for avoiding freezes on scene load?
« on: July 25, 2014, 08:15:48 AM »
Hi,

We have a menu with a large number of NGUI components. It runs perfectly smoothly during usage, but when loading the scene, the game freezes for 1-2 seconds while all the OnEnable, Awake and Start functions run. The freeze time goes past the platform's maximum requirement - and anyway, it looks silly because we're supposed to be showing a loading screen animation during the time.

Are there ways of spreading this out over a longer period of time to allow a decent frame rate? Unity's own LoadLevelAsync is quite good at this, but it's limited to loading assets. Once everything has been loaded (which actually only takes less than a second), there's a lot of code that gets executed that causes the freeze.

Thank you.

3
NGUI 3 Support / Custom pointer over UIDraggablePanel
« on: March 22, 2013, 04:39:18 AM »
Hi,

I have a fairly simple UI, with most widgets residing under a single main panel, and I have one UIDraggablePanel for a scrollable list. I have a context-sensitive custom pointer implemented as an UISprite under the main panel.

My problem is that the pointer is drawn behind the draggable panel. However, the draggable panel needs to be in front of the main panel, because the main panel has content that needs to be displayed behind the draggable panel (mainly, a background that doesn't scroll, like in the UIDraggablePanel example).

The obvious solution seems to be to create a third panel just for the pointer. From what I understand, though, panels should be kept to a minimum. Is there a way I could achieve the same effect with fewer panels?

Thanks.

4
NGUI 3 Support / Re: [Solved] Setting the position of UIDraggablePanel
« on: March 04, 2013, 11:23:04 AM »
Ah, that makes sense. Thanks again for the speedy help!

5
Okay, thanks, that got it working. Bit of a roundabout way of doing it though - I was looking for a shorthand to avoid having to do calculations with the panel's bounds.

Now I'm curious, though. What is SetDragAmount() used for?

6
NGUI 3 Support / [Solved] Setting the position of UIDraggablePanel
« on: February 27, 2013, 04:12:25 AM »
I am developing a level selection menu that's essentially a long, scrollable list of items using UIDraggablePanel and UIGrid. I'm trying to find a way to initialize the scroll position so that the last played level is visible. However, calling SetDragAmount() on the UIDraggablePanel seems to do weird things: it moves the entire panel as well as the contents.

To test this, open NGUI/Examples/Scenes/Example 7 - Scroll View (Panel).unity, then add the following script to the Click Me button (and disable the UIButton Tween component):

TestDragPanel.cs
  1. using UnityEngine;
  2. using System.Collections;
  3.  
  4. public class TestDragPanel : MonoBehaviour {
  5.     void Start() {
  6.         UIEventListener.Get(this.gameObject).onClick += onButtonClick;
  7.     }
  8.  
  9.     void onButtonClick(GameObject button) {
  10.         GameObject gob = GameObject.Find("UIPanel (Clipped View)");
  11.         UIDraggablePanel draggablePanel = gob.GetComponent<UIDraggablePanel>();
  12.         draggablePanel.SetDragAmount(0.25f, 0f, true);
  13.     }
  14. }

I would assume that the code would move the scroll position to 25%. And that seems to happen, since in the second picture the scrollbar has moved to the right - but so has the panel itself. See the attachments for screenshots before and after calling the method.

I'm using NGUI 2.3.4 and Unity 4.0.1f2.

Edit: Marked as solved, and clarified subject to match with the solution.

Pages: [1]