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

Pages: [1]
1
Support / Re: GUIText Positioning in GameObject
« on: August 16, 2013, 02:45:06 am »
I don't use GUIText in Unity - I am using tk2dTextMesh in this purposes for GUI dynamic (and some static) texts, in other cases i use text as sprite.
I don't know about GUIText, but:
1) all texts with tk2dTextMesh costs 1 draw call as they have the same material (for many fonts - simple pack it all in one spriteCollection)
2) I use GUI functions only for debugging because GUI elements drawing costs one draw call per element
3) text alignment (and other gui elements) is very simple: I use my custom component for that, but tk2d package contains the same component (tk2dCameraAnchor)

2
Support / Re: Unload Textures
« on: August 15, 2013, 08:22:02 am »
1) put all spriteCollectionData prefabs inside Resources folder;
2) add to tk2dSpriteCollectionData.cs:

Code: [Select]
public void ReloadTextures() {
foreach (Material mat in inst.materialInsts) {
mat.mainTexture = mat.mainTexture as Texture2D;
};
}

3) use this:

Code: [Select]
tk2dSpriteCollectionData scdToUnload = Resources.Load ("Unload_collection_name", typeof(tk2dSpriteCollectionData)) as tk2dSpriteCollectionData;
tk2dSpriteCollectionData scdToReload = Resources.Load ("Reload_collection_name", typeof(tk2dSpriteCollectionData)) as tk2dSpriteCollectionData;
scdToUnload.UnloadTextures();
scdToReload.ReloadTextures();

UPD:
I renamed all tk2dSpriteCollectionData prefabs from default "data.prefab" to collection name (as in attached image)

3
Support / Re: Atlas 2x textures in MeshRenderer loading with scene
« on: August 15, 2013, 06:45:37 am »
Thanks a lot, it works! :)

4
Support / Atlas 2x textures in MeshRenderer loading with scene
« on: August 14, 2013, 06:51:23 am »
As far as i know, unity at scene loading loads all resources (textures, materials, audioclips, e.t.c.) that has been assigned to script's fields in inspector (all serialized fields). Selecting a sprite in tk2dsprite component on gameobject automatically sets material/atlas texture to its MeshRenderer material. If at sprite selecting time tk2dsystem.currentPlatform is 2x it sets a large atlas texture, and that texture will be loaded with scene loading automatically because it has reference in scene. The first way is setting tk2dSprites with selected 1x platform in editor: at scene loading only 1x textures will be loaded by default, but in short period of time in memory can be loaded both 1x and 2x textures and it may cause a didRecieveMemoryWarning on devices with 2x platform settings. Second way is setting all tk2dSprite's MeshRenderer materials to none and resave scene - then scene has no references to atlases. Is it right?

5
Support / Re: tk2dExternal does not exist
« on: June 07, 2013, 07:36:42 am »
Before updating tk2d to 2.0 version, I deleted "tk2d" folder in "Assets/Plugins" directory. After that, I reinstalled tk2d 2.0 with no errors.

P.S.: sorry for my bad English

6
Support / Re: Unused atlas textures still loaded after LoadLevel
« on: June 07, 2013, 02:08:38 am »
I have same problem.
In empty scene, loaded after main menu scene (even no camera, absolutely empty scene!), after UnloadUnusedAssets menu atlases, materials and collection prefabs are still loaded in memory.


UPD:
tk2d was updated to 2.0, in special empty scenes I wrote:

Code: [Select]
...
Object[] txt = GameObject.FindObjectsOfTypeIncludingAssets(typeof(GameObject));
for (int i = 0; i < txt.Length; i++)
if (txt[i].name.Length >= 18)
if (txt[i].name.Substring(0, 18) == "Interface_mainMenu"){ //my sprite collection prefab name that need to be unloaded
tk2dSpriteCollectionData t = (txt[i] as GameObject).GetComponent< tk2dSpriteCollectionData>();
if (t)t.UnloadTextures();
};
...

and rewrote tk2dSprite.cs and tk2dSlicedSprite.cs UpdateMaterial() function with this:

Code: [Select]
...
protected override void UpdateMaterial()
{
renderer.sharedMaterial = collectionInst.spriteDefinitions[spriteId].material;
}
...

UnloadTextures() function frees up a lot of memory, and rewriting of UpdateMaterial() function fixes a bug with black textures in sprite materials when scene with unloaded spritecollection has been reloaded.

P.S.: sorry for my bad English

Pages: [1]