Hello Guest

Author Topic: 2D Toolkit 1.92 beta 2  (Read 16046 times)

unikronsoftware

  • Administrator
  • Hero Member
  • *****
  • Posts: 9709
    • View Profile
2D Toolkit 1.92 beta 2
« on: March 15, 2013, 11:07:48 am »
As with all beta releases, exercise caution when upgrading. Make sure you have a back up!

FIXES UNITY 4.1 INDEX BUILD ISSUE

Features:
- Full undo/redo support & multi-edit support in all scene instances
- Runtime TexturePacker import
    o tk2dSpriteCollectionData.CreateFromTexturePacker, non-XML/JSON simple format, can be written so it doesn't allocate any memory
    o TexturePacker 2D Toolkit exporter is in "tk2d/Goodies/TexturePacker"
    o Sliced/clipped/tiled sprites not supported yet
- Clipped sprite - a hard clipped sprite implementation, now part of the distribution (based of Clipped Sprite Sample)
- Tiled sprite - tiles the same sprite multiple times to fill given dimensions
- Use color32 instead of color, should require a lot less memory
- Sliced sprite "Draw Border Only" mode, just draws the sliced border only omitting the filled middle.

Pani

  • 2D Toolkit
  • Newbie
  • *
  • Posts: 29
    • View Profile
Re: 2D Toolkit 1.92 beta 2
« Reply #1 on: March 16, 2013, 07:16:10 am »
Was hoping for a TexturePacker feature! The data file exports fine, but how do you import it into 2D Toolkit? Can't seem to find anything regarding it in the sprite collection.


unikronsoftware

  • Administrator
  • Hero Member
  • *****
  • Posts: 9709
    • View Profile
Re: 2D Toolkit 1.92 beta 2
« Reply #3 on: March 16, 2013, 10:42:58 am »
@evs,

Is that working fine for you? I just wanna confirm everything is working as expected before submitting the exporter to the TexturePacker guys for inclusion in the next release.

Pani

  • 2D Toolkit
  • Newbie
  • *
  • Posts: 29
    • View Profile
Re: 2D Toolkit 1.92 beta 2
« Reply #4 on: March 16, 2013, 03:03:08 pm »
@Pani

http://www.unikronsoftware.com/2dtoolkit/doc/html/classtk2d_sprite_collection_data.html#a02e33478fb426c249c5ff31c143e97cb

cheers

evs
Sorry, but I'm still a little confused as to how to import it (new to 2DToolkit in still learning C#). I should probably create a new thread but I'd rather not clutter up the forums with one question threads so it would be great if you could give a quick example. Where do you get tk2dRuntime.SpriteCollectionSize to give the function?

unikronsoftware

  • Administrator
  • Hero Member
  • *****
  • Posts: 9709
    • View Profile
Re: 2D Toolkit 1.92 beta 2
« Reply #5 on: March 16, 2013, 04:59:28 pm »
I suggest waiting for the next update, there will be a sample doing this there. Hopefully sometime this weekend. If you're in a rush, email me at support, and I'll email you the crude sample as is.

thefiend

  • 2D Toolkit
  • Newbie
  • *
  • Posts: 8
    • View Profile
Re: 2D Toolkit 1.92 beta 2
« Reply #6 on: March 16, 2013, 07:15:18 pm »
I'm finding that creating a tk2dCamera in a brand new scene causes the scene to remain in an always-unsaved state.

Saving the scene seems to have no effect - the asterisk in the title bar never disappears.

Unity version 3.5.7f6 (free).
2DToolkit version 1.92 beta 2.

evs

  • 2D Toolkit
  • Newbie
  • *
  • Posts: 23
    • View Profile
Re: 2D Toolkit 1.92 beta 2
« Reply #7 on: March 16, 2013, 08:27:33 pm »
@unikron, @Pani

Attach this script to a game object and it works nicely!

I don't know if this is the best way to do it though?

Code: [Select]
using UnityEngine;
using System.Collections;
using System.IO;

public class TexturePackerCollection : MonoBehaviour {

Texture2D theTexture; // For the texture
string theData; // For Texture Packer 2d Toolkit .bytes file
FileStream theStream; // For loading image
byte[] theImageData; // Array for image data
tk2dRuntime.SpriteCollectionSize theSize; // Collection size
tk2dSpriteCollectionData theCollection; // For the created collection

void Start () {

// Get size using 2d Toolkit camera
theSize = tk2dRuntime.SpriteCollectionSize.ForTk2dCamera();

// *** OR ***
// Get size for orthographic camera float orthoSize, float targetHeight
//theSize = tk2dRuntime.SpriteCollectionSize.Explicit(100f, 320f);

// Create the texture
theTexture = new Texture2D(512, 512);

// Read Texture Packer data file into string
theData = File.ReadAllText("atlas.bytes");

// Read the image file into the texture
theStream = new FileStream("atlas.png", FileMode.Open, FileAccess.Read);

theImageData = new byte[theStream.Length];

theStream.Read(theImageData, 0, (int) theStream.Length);

theTexture.LoadImage(theImageData);

// Create the collection
tk2dSpriteCollectionData theCollection = tk2dSpriteCollectionData.CreateFromTexturePacker(theSize, theData, theTexture);

// Add the named sprite to the game object that this script is attatched to
tk2dSprite.AddComponent(gameObject, theCollection, "progressBar");

}

}


cheers

evs

jpaquin

  • Newbie
  • *
  • Posts: 1
    • View Profile
Re: 2D Toolkit 1.92 beta 2
« Reply #8 on: March 18, 2013, 08:03:58 pm »
Great work, you guys. The tiled sprite is going to be a big help for me.

I have a feature request. Could you please give tilemaps the ability to handle animated tiles? By that I just mean iterate through a flipbook of existing tiles.

This would let you make water that ripples, and grass that waves. Without this feature, the tilemaps look very static.

Thanks for the great software!

brussell

  • 2D Toolkit
  • Newbie
  • *
  • Posts: 16
    • View Profile
Re: 2D Toolkit 1.92 beta 2
« Reply #9 on: March 19, 2013, 02:08:51 pm »
I'm getting "Shader wants normals, but the mesh doesn't have them" warnings and my tiled sprite is black on iOS. It looks correct in Unity. I have applied tk2d/LitSolidVertexColor and have a spotlight to cast light.

brussell

  • 2D Toolkit
  • Newbie
  • *
  • Posts: 16
    • View Profile
Re: 2D Toolkit 1.92 beta 2
« Reply #10 on: March 19, 2013, 03:02:49 pm »
Well, I'm closer. I remembered I had to edit the scripts for the other sprites in order to enable normals. So, I added mesh.RecalculateNormals();  to the tk2dTiledSprite and now the tiled sprite shows up lit, but now the tiled sprite and all sprites from that same sprite collection are fully lit on iOS. They're supposed to be dark in the corners.

unikronsoftware

  • Administrator
  • Hero Member
  • *****
  • Posts: 9709
    • View Profile
Re: 2D Toolkit 1.92 beta 2
« Reply #11 on: March 19, 2013, 03:33:57 pm »
They will only appear dark in the corner if point lights are on. When lit per vertex, there won't be enough vertices for the light to illuminate properly. But pixel lights are really slow...

brussell

  • 2D Toolkit
  • Newbie
  • *
  • Posts: 16
    • View Profile
Re: 2D Toolkit 1.92 beta 2
« Reply #12 on: March 19, 2013, 03:59:42 pm »
Sorry, I'm a bit slow. This was working before I upgraded to Unity 4.1 and 2D Toolkit 1.92 beta 2. It is still working in the Unity simulator. I'm not sure what it is I need to do to get it working again.

unikronsoftware

  • Administrator
  • Hero Member
  • *****
  • Posts: 9709
    • View Profile
Re: 2D Toolkit 1.92 beta 2
« Reply #13 on: March 19, 2013, 04:21:18 pm »
What version of Unity were you on before that? Please start a thread in the private support forum about this. I'm sure I'll have more questions for you.

brussell

  • 2D Toolkit
  • Newbie
  • *
  • Posts: 16
    • View Profile
Re: 2D Toolkit 1.92 beta 2
« Reply #14 on: March 19, 2013, 04:35:17 pm »
Can do, I had originally put it here because the walls were lighting properly and just not the floor (new Tiled Sprite) and was just listing it as an issue. Now nothing in that sprite collection lights correctly.