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.


Topics - aikitect

Pages: [1]
1
Hello, I am trying to create a customizable 2D character that is comprised of 30 different sprites.  Assuming that there are 10 variations of each sprite, there would be 300 sprites in total.  I also want to have multiple characters on screen at one time.  As a result, I am trying to figure out what's the best way to render a given character at runtime if I know the sprite names that need to be shown.  There are three solutions:

  • Create an atlas for each of the 10 character variations offline.  However, this would require me to load all 10 atlases if the character uses a sprite from each character variation.  This will waste memory because I am loading a lot of sprites I will never use.
  • Create an atlas for each sprite.  This would require 30 draw calls per character.  If I have 5 characters on screen, that would require 150 draw calls which is too much.
  • Since I know which sprites the character will use, I can theoretically create an atlas at runtime and use that.  This will require 1 draw call per character.

I want to attempt the last solution.  However, I am trying to figure out how to do that with TK2D.  I have been reading other threads such as this one: http://2dtoolkit.com/forum/index.php/topic,2576.15.html.

However, I have a few questions about the workflow for this works.  From what I gather, it work as follows.

  • Use Texture2D.PackTextures to pack the correct textures into an atlas.
  • Use tk2dSpriteCollectionData.CreateFromTexture to create a tk2dSpriteCollectionData.
  • Use RenderTexture to actually display the character?  I'm looked at the Unity documentation for Render Texture and am not sure how it fits into the workflow.

Can you help advise on the workflow above or suggest something else completely if it is not correct.

2
Hello, I am interested in packing 1x/2x tk2dSpriteCollections into AssetBundles.  I started reading some of the other threads on the topic, but am not entirely clear on what actually needs to be in the AssetBundle.

Here's my best guess - please correct me where I am wrong:

1. In a new project, create a tk2dSpriteCollection that uses "1x" platform setting.  Create a different tk2dSpriteCollection that uses "2x" platform setting.  Add all the appropriate sprites and commit the collection.  Is it okay to use PNG settings here?
2. Add the tk2dSpriteCollectionData component to the AssetBundle using the following code:

Code: [Select]
tk2dSpriteCollectionData data;
BuildPipeline.BuildAssetBundle(data, new Object[] { data }, path, BuildAssetBundleOptions.CompleteAssets | BuildAssetBundleOptions.CollectDependencies);

3. Download the Asset Bundle and perform the following code for to set a sprite.

Code: [Select]
AssetBundle ab = <reference to an assetbundle>;
sprite = GetComponent<tk2dSprite>();
sprite.collection = ab.Load ("human", typeof(tk2dSpriteCollectionData)) as tk2dSpriteCollectionData;
sprite.SetSprite("mySpriteName");

3
Support / Particle Systems Rendering Behind All tk2dSprites
« on: May 09, 2014, 05:10:36 pm »
Hello, I have set up a scene where my camera is at z: -10, my tk2D sprites are at z: 0, and my particle system is at z: -5.  When I generate particle effects, my particles are definitely in front of the sprites in the scene view, but get rendered behind the sprites in the game view.  Why is this happening?  I am using an orthographic camera by the way.

4
Support / Sprites Shrinking by Factor of 100 on Game Start?
« on: May 08, 2014, 06:59:05 am »
Hello,

I am working with 2DToolkit, and I have set my tk2dCamera to Pixels per Meter of 100, and set it to orthographic.  I have a sprite in my scene from one tk2dCollection, and when I start the game, the scale automatically shrinks from 1 to 0.01.  On the other hand, if I have a sprite from another tk2dCollection, it does not shrink the scale automatically.  What is going on?  I tried to look in the tk2dCollection settings but my Pixels per Meter for both collections are set to 100.

Pages: [1]