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

Pages: [1]
1
NGUI 3 Support / Atlas Materials not clearing on Scene change
« on: March 02, 2017, 11:09:02 PM »
Hello,

I recently noticed that nearly every Texture or Material I'm loading into my scenes are not getting cleared as I transition to my next scene.  In the past, I circumvented these issues typically by loading to a blank or nearly empty scene while I'm loading in my next scene, but this seems to not be working in my current project.

Below is a sample of how I'm changing scenes, with some extra fluff removed for brevity.  (Note: The textures/material in question are mostly NGUI atlas materials, but I have some general Sprites that are not clearing either).

   
  1. public IEnumerator LoadLevel()
  2.     {
  3.         // Load into an empty scene
  4.         SceneManager.LoadScene("EmptySene", LoadSceneMode.Single);
  5.  
  6.         // Asychronously load in our new scene
  7.         asyncLoad = SceneManager.LoadSceneAsync("NextScene", LoadSceneMode.Additive);
  8.         asyncLoad.allowSceneActivation = false;
  9.  
  10.         // Wait until scene has finished loading
  11.         while (!asyncLoad.isDone) {
  12.             yield return new WaitForEndOfFrame();
  13.         }
  14.  
  15.         // NGUI specific call to release unused assets
  16.         UIDrawCall.ReleaseInactive();
  17.  
  18.         // Unload any unused assets here and then allow our scene to load
  19.         yield return Resources.UnloadUnusedAssets();
  20.         asyncLoad.allowSceneActivation = true;
  21.     }

Typically, I would except all loading textures and materials from the previous scene to be removed since I loaded into my "EmptyScene" in Single mode, and then unloaded any unused assets before activating my next scene.  However, I'm seeing a vast majority of my assets remain within memory while using the Profiler both during Editor testing and on iOS devices.

Granted, I used this method previously when all scene loading was done via the Application class, so perhaps this approach has changed and I'm not aware. I have a few assets in Resources, but they're not large and the assets that are sticking are not included or reference from there.  I've also been careful not to statically reference any assets to prevent them from properly clearly.

Anything else I should be looking out for?  In the Profiler, I will literally see that a single reference to the Material remains, but claims it's not being utilized by any GameObjects in the scene.  If that is the case, why does calling UnloadUnusedAssets() not clear these?

Any ideas or tips would be greatly appreciated.  Thanks!

2
NGUI 3 Support / Limit UIScrollView render dimensions
« on: May 26, 2016, 11:26:10 PM »
Hello all,

I'm running into a situation where I'd like to override the min/max scroll area of the UIScrollView.  Currently my hierarchy is setup as follows:

| UIScrollView
---| UIGrid
--------| Sprite 1
--------| Sprite 2
--------| Sprite N

In this example, let's say all that the total height of rendering all of my sprites extends from Vector3(0, 0, 0) to Vector3(0, 1500, 0).  However, due to masking and just not wanting to allow players to scroll all the way to the bottom of the scrollview, I wanted to limit the scrollview to only allow players to scroll from Vector3(0, 0, 0) to Vector3(0, 1200, 0).

It looks like in the UIScrollView, it's calculating the total width/height of the children elements to the scrollview and setting its scroll area to cover all renderable assets.  Is there an easier way to prevent this behaviour that I'm not aware of outside of modifying the script?  I tried limiting the Offset on the UIPanel attached to the UIScrollView, but that resulted in unexpected behaviour (possibly because I attempted to limit the values incorrectly).

Any ideas how I can achieve this?  Any tips or pointers on setup would be appreciated - thanks!

Pages: [1]