2D Toolkit Forum

2D Toolkit => Releases => Topic started by: unikronsoftware on February 12, 2012, 11:30:41 pm

Title: 2D Toolkit 1.57 beta 1
Post by: unikronsoftware on February 12, 2012, 11:30:41 pm
Maintenance release, not feature complete.


Still TODO for 1.57
Cache normals instead of calling Recalculate normals - will be much faster for materials with custom shaders
Title: Re: 2D Toolkit 1.57 beta 1
Post by: unikronsoftware on February 13, 2012, 12:43:43 am
tk2dCamera mini-tutorial.

1. Create sprite collection / font, and make sure you tick "Use tk2d Camera". You will not need to set up ortho size / height as you'd normally need to. Set up as usual, and don't forget to commit.
2. In the scene, delete the Main Camera, and "Create/tk2d/Camera"
3. Create a sprite as usual - if you set up the sprite collection as in step 1, it will automatically be pixel perfect, always. Otherwise, click "1:1" to make other sprites pixel perfect. You may need to click commit on your sprite collections again for this to work properly. You will see an error in the log if this is the case.

tk2dCamera Anchor mini-tutorial.

1. Click on the camera created above, and "Create Anchor". You will have an anchor object as a child to this camera.
2. Select this anchor object, and set it up as you like - offset is the offset from the anchor. For instance if your anchor wants to be 5 pixels in from the bottom right, simply select "BottomRight" as anchor, and set offset to -5, 5 (5 pixels in horizontally, 5 pixels up).
3. Create sprites as children to this object (simply select the object, and "Create/tk2d/Sprite" will automatically parent them and these objects will now automatically be anchored.
Title: Re: 2D Toolkit 1.57 beta 1
Post by: fsadeq on February 13, 2012, 04:31:30 am
Hello, when I try to commit a sprite sheet, I now get this error:

Code: [Select]
NullReferenceException
UnityEngine.Mesh.Clear ()
tk2dStaticSpriteBatcher.Build () (at Assets/TK2DROOT/tk2d/Sprites/tk2dStaticSpriteBatcher.cs:38)
tk2dSpriteCollectionBuilder.Rebuild (.tk2dSpriteCollection gen) (at Assets/TK2DROOT/tk2d/Sprites/Editor/tk2dSpriteCollectionBuilder.cs:866)
tk2dSpriteCollectionEditor.OnInspectorGUI () (at Assets/TK2DROOT/tk2d/Sprites/Editor/tk2dSpriteCollectionEditor.cs:81)
UnityEditor.InspectorWindow.DrawEditors (Boolean isRepaintEvent, UnityEditor.Editor[] editors, Boolean eyeDropperDirty)
UnityEditor.InspectorWindow.OnGUI ()
System.Reflection.MonoMethod.Invoke (System.Object obj, BindingFlags invokeAttr, System.Reflection.Binder binder, System.Object[] parameters, System.Globalization.CultureInfo culture)

I haven't tried creating a new project from scratch, but this is happening after I updated from the last release.
Title: Re: 2D Toolkit 1.57 beta 1
Post by: unikronsoftware on February 13, 2012, 08:17:40 am
OK, I've found the problem - it only happens when you have a prefab created from a StaticSpriteBatcher in the project, and it is loaded in when you click Commit. A quick patch for this version:

in tk2dStaticSpriteBatcher.cs
delete line 35 - mesh.Clear()

and further down the same function, replace
mesh.vertices = meshVertices;
mesh.uv = meshUvs;
mesh.colors = meshColors;
mesh.triangles = meshIndices;
mesh.RecalculateBounds();

with:
if (mesh)
{
  mesh.Clear();
  mesh.vertices = meshVertices;
  mesh.uv = meshUvs;
  mesh.colors = meshColors;
  mesh.triangles = meshIndices;
  mesh.RecalculateBounds();
}

I will post an updated fixed version later.
Title: Re: 2D Toolkit 1.57 beta 1
Post by: KyleStaves on February 13, 2012, 04:09:02 pm
Quick question; is there any important reason that the default far clipping plane is 20? Or can I safely increase that number?

Thanks!
Title: Re: 2D Toolkit 1.57 beta 1
Post by: fsadeq on February 13, 2012, 08:28:38 pm
Thanks for the reply unikron, no longer get that error. Though, maybe I'm not understanding something here, but I can't really get the sprites to display properly. It seems to look fine in the camera preview, but when I actually run, the sprite is offset and appears much larger than it should. I tried this on a new project from scratch, following your directions above. Any ideas? Thanks!
Title: Re: 2D Toolkit 1.57 beta 1
Post by: unikronsoftware on February 13, 2012, 11:19:57 pm
Hi,

If you look at the game view, the sprite should be pixel perfect in there all the time. If it isn't, try clicking on "1:1" - if that fixes it it implies that something else has gone wrong there. Failing that, could you post your scene / project folder in the private support section / or email it to support at unikronsoftware dot com. Could be a bug...
Title: Re: 2D Toolkit 1.57 beta 1
Post by: unikronsoftware on February 13, 2012, 11:20:18 pm
Quick question; is there any important reason that the default far clipping plane is 20? Or can I safely increase that number?

Thanks!

You can increase that to whatever you like.