Hello Guest

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

Pages: [1]
1
Support / Re: Unload tk2danimator assets
« on: January 16, 2015, 05:09:33 pm »
Ok, the strange thing is that the only assets that it doesn’t unload are the materials and textures asssociated with tk2dspriteanimations, which are the biggest assets in 2D games

2
Support / Re: Unload tk2danimator assets
« on: January 16, 2015, 03:22:56 pm »
Ok I’ve taken further look into this problem after reading the bug fix -> http://2dtoolkit.com/forum/index.php/topic,4738.0/prev_next,prev.html#new

This correction still doesn’t solve the unloading problem but allowed me to find it.

So basically it seems that all objects with tk2dspriteanimator attach to them, won’t be unloaded from memory after a scene switch with

Code: [Select]
       
Application.LoadLevel((int) ESCENE.LOADING);
System.GC.Collect();
Resources.UnloadUnusedAssets();

if the objects played in the previous scene where attached into a public/protected/private variable on any object. It is only loaded if the variable referencing the object with tk2dspriteanimator was only temporary declared inside a method.

To give a better example:

Code: [Select]
public class A : Monobehaviour
{
public GameObject player;
}

public class Player : Monobehaviour
{
private tk2dSpriteAnimator _animator;
}

public class Manager : Monobehaviour
{
void Start()
{
DonDestroyOnLoad(gameobject);
}

public void LoadLevel(int level)
{
Application.LoadLevel(level);
System.GC.Collect();
Resources.UnloadUnusedAssets();
}

With the player variable from the A object referenced in the inspector to the Player GameObject, when switching scenes, all the atlas from the Player _animator animations won’t be unloaded, and I’ll have garbage in my memory that won’t be needed the next scene (I’m 100% sure that there is no need for this atlas because there are no objects using them after carefully comparing Resources.FindObjectsOfTypeAll(typeof(Material)) and Resources.FindObjectsOfTypeAll(typeof(Renderer)).

So I went deeper into it and found out if I switch the A class method to the following it unloads correctly:

Code: [Select]
public class A : Monobehaviour
{
public GameObject player;

void OnDestroy()
{
player = null;
}
}

After this working I thought that I understand it wrong and I had the NULL every public/protected/private variable in my game. It was a pain but I went for it. But just now I noticed that the only objects that aren’t unloaded are the atlas from my animations and not from static not animated objects.

So my question is, why doesn’t 2D Toolkit unload the textures and materials associated with the previous scene played animations? Is it a bug, or is it intended?

3
Support / Re: Unload tk2danimator assets
« on: August 21, 2014, 08:14:57 pm »
It works for all assets except the ones that are animations.

I’m deleting an entire prefab with objects using 5 atlas inside of it (2 atlas are for tk2danimations and 3 are for tk2dsprites). This prefabs manages every single object that is his children.
After deleting I’m doing UnloadUnusedAssets() and 3 atlas are cleaned up (the ones for the tk2dsprites) and 2 are still in memory, and there is no way they are removed, except by cleaning with Resources.UnloadAsset(). Unfortunatly Resources.UnloadAsset is not a very good way to solve this because if I later need to resources.load the prefab, all the atlas that were unload will come all wrong.

Cheers

4
Support / Unload tk2danimator assets
« on: August 21, 2014, 07:45:20 pm »
Hi,

I noticed that Resources.UnloadUnusedResources() doesn’t unload the atlas from objects that have a tk2danimator script attack to it. This means that during the entire game session, I will have forever all the atlas that has sprites inside from animations (even if I go from the menu into the game while cleaning resources during loading).

What I’m doing is searching for all tk2danimator in scene and Resources.UnloadAsset() of the texture of the object. While this works, is not very safe and costs extra CPU.

So my question is, how can I clear the texture atlas attached to the tk2danimator object that was already destroyed?

5
Support / Re: Sprite Batcher loading all unecessary atlas
« on: August 21, 2014, 05:39:01 pm »
Ohhhh ok, I’ll look into that. Thank you :D

6
Support / Sprite Batcher loading all unecessary atlas
« on: August 21, 2014, 05:23:35 pm »
Hi,

I just encounter a very strange bug and very problematic one, but I’ll do my best to explain it to you.
So in my RPG game, before I go to gameplay I have an Main Menu. Inside of the main menu I have two buttons, a button to go to my play scene and a button that goes to the Heroes Menu, Inside of the Heroes Menu I go to the Spells Menu.
Each Menu has it’s own atlas and prefab and works independently.

Everything works perfectly, but when I builded my game to low end mobile devices I noticed that my game runner very very slow. After a lot of search and debugging I found the problem (a very very strange one).

I noticed that tk2dspritebatcher loads all my sprite collections textures (even the ones not needed for the batcher).
Probably you will be saying that I’m doing something wrong and I’m adding an sprite without know (that was my thought also), but after a lot of digging and searching I found out that I’m not adding nothing from other atlas.

This is also a very strange bug that only happens in some occasions, that is getting very hard to solve the problem. For example:

- When I open the app(game), and enter in the main menu, everything is loaded correctly (and in the main menu I have some objects with sprite batters).
- When I open the heroes menu from the main menu, for some reason that I don’t know why I have every single atlas from the sprite collection I created loaded (but not being used).
- When I open the spells menu from the heroes menu, I have only the necessary atlas loaded and everything that unnecessarily added from the heroes menu is removed from memory.
- When going back to the main menu, noticed that everything is back to normal.

So with this, I investigated into the heroes menu. After a lot of digging noticed that the single button to open the spells menu (from the heroes menu) is loading every single atlas from the my sprite collections. Well I found this very strange because the button is exactly the same the ones I used in the main menu or spells menu (with the only difference is the tk2dtextmesh above it).
I dig more into it, and after some desperation I removed the sprite batcher from the button (because the button is composed with 4 sprites), and noticed that all of the sudden I didn’t had the unnecessary atlas any more.

So my question is, how can a tk2dSpriteBatcher load all the unnecessary atlas from my sprite collections, and how can I fix that?

Cheers,

Miguel

7
Support / Re: Hover button Candy Crush style
« on: May 26, 2014, 04:19:52 pm »
Yeah I tried to do it on the UIManager, but with no success. I use on all my UI Items the tk2dUIItem so it works perfectly in my game.

8
Support / Hover button Candy Crush style
« on: May 26, 2014, 12:34:45 pm »
Hi,

In my current project I got the task to create hover state button like candy crush buttons where:
- user press down the button -> moves out the button (and the button goes up) -> moves back in to the button (button goes down) -> user releases the button (button is activated)
You can check this movement here -> https://www.youtube.com/watch?v=f-YXqNoC54g Because it’s a video about a buggy function the reaction is the the contrary as intended but you can get a clue of what is the objective.

Well I try to do this with tk2dUIHoveItem or hover states, but I had no success because hover states only works with the mouse and my game is for the mobile devices.
To solve this I added this lines of code in line 308 of tk2dUIItem.cs on the function public void CurrentOverUIItem(tk2dUIItem overUIItem)
Code: [Select]
else if(!isPressed)
{
Press(overUIItem.Touch);
if (parentUIItem != null)
{
parentUIItem.CurrentOverUIItem(overUIItem);
}
}

I would kindly ask if this effect could be added to 2D toolkit (if a flag like the hover is) so we could have cool effect like candy crush does. If not on every update I’ll add that code :)

Cheers

9
Support / Re: DestroyImmidiate
« on: February 05, 2014, 05:28:35 pm »
Thanks, that did it :)

10
Support / Re: DestroyImmidiate
« on: February 05, 2014, 04:06:45 pm »
Ok, that fixed everything.

But now I have another problem. Most of my code needed to have the render data next to the tile map because I’m moving the parent object around (because it’s literally a map).

How can I achieve that  If the tiles are created dynamically?

11
Support / Re: DestroyImmidiate
« on: February 05, 2014, 01:59:05 pm »
Nop, but the tile map and the render data objects have the same parent in the prefab where they are included

12
Support / Re: DestroyImmidiate
« on: February 05, 2014, 12:17:27 am »
Ok. Just noticed that in the middle of the entire red warning I had this ones

Destroying object multiple times. Don't use DestroyImmediate on the same object in OnDisable or OnDestroy.
UnityEngine.Object:DestroyImmediate(Object)
tk2dUtil:DestroyImmediate(Object) (at Assets/TK2DROOT/tk2d/Code/tk2dUtil.cs:50)
tk2dRuntime.TileMap.SpriteChunk:DestroyGameData(tk2dTileMap) (at Assets/TK2DROOT/tk2dTileMap/Code/tk2dTileMapChunks.cs:54)
tk2dRuntime.TileMap.Layer:DestroyGameData(tk2dTileMap) (at Assets/TK2DROOT/tk2dTileMap/Code/tk2dTileMapChunks.cs:405)
tk2dTileMap:OnDestroy() (at Assets/TK2DROOT/tk2dTileMap/Code/tk2dTileMap.cs:146)

Another thing is I do LoadLevelAsync() and the tile map is a pre saved prefab. The prefab is automatically destroyed by Unity on scene change.

13
Support / Re: DestroyImmidiate
« on: February 03, 2014, 04:50:38 pm »
Hi,

I’m having the same issue.

In my case I have 2 unity scenes (a menu and a game scene). I have the a map created with tile map on my menu scene and every time at runtime I go from the menu to the game I get this red warning on Unity console multiple times:

Destroying object multiple times. Don't use DestroyImmediate on the same object in OnDisable or OnDestroy.
UnityEngine.Object:DestroyImmediate(Object)
tk2dUtil:DestroyImmediate(Object) (at Assets/TK2DROOT/tk2d/Code/tk2dUtil.cs:50)
tk2dTileMap:OnDestroy() (at Assets/TK2DROOT/tk2dTileMap/Code/tk2dTileMap.cs:150)

On the Tilemap demo this doesn’t happen because there is only one scene and you don’t switch from that demo scene to a new scene.

Pages: [1]