Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Tutorial about conversion from swf to lwf #5

Closed
camelot10 opened this issue Oct 26, 2012 · 11 comments
Closed

Tutorial about conversion from swf to lwf #5

camelot10 opened this issue Oct 26, 2012 · 11 comments
Assignees

Comments

@camelot10
Copy link

i tryed by myself but got plenty of ruby errors.
only detect that flash version 7 supported for converting

@HiroyukiHaga
Copy link
Contributor

I've uploaded a FLASH production guideline doc.
Can you please take a look this documentation?

http://gree.github.com/lwf-demo/pdf/FLASHforLWFproductionguideline.pdf

@HiroyukiHaga
Copy link
Contributor

You can verify your FLASH scene in FLASH environment by using LWF_Publish.jsfl.
LWF_Publish.jsfl is available in the "tools/flash" directory.

https://github.com/gree/lwf/blob/master/tools/flash/LWF_Publish.jsfl

Installing JSFL Scripts
http://summitprojectsflashblog.wordpress.com/how-tos/installing-jsfl-scripts/

@ghost ghost assigned HiroyukiHaga Oct 27, 2012
@phamvanan
Copy link

I try to bulid project tools swf2lwf but errors.
Can you post tutorial install detail that project, please?

Thanks and Regards.

@camelot10
Copy link
Author

tested. seems like export works. my animations works in unity

@Adamcbrz
Copy link

Adamcbrz commented Feb 4, 2013

I agree with having a tutorial. I can't seem to get sprite atlas to work with the animation. I can't seem to find any tutorials on this besides swf2lwf command line but I can't seem to get that to work. If any one has had success on this PLEASE help me out.

Thanks!

@HiroyukiHaga
Copy link
Contributor

Thank you Adamcbrz.
Sprite atlas works perfectly with LWF. Actually, we prefer to use atlas for reducing number of draw calls. The swf2lwf supports json file that is exported from Texture Packer (http://www.codeandweb.com/texturepacker).

Can you please take a look Texture Packer.

Anyway, a tutorial for converting swf by using Texture Packer's json data would be required...
I'd like to take a look it.

@HiroyukiHaga
Copy link
Contributor

Here is a quick tutorial for making sprite atlas for LWF:)
The tutorial file has been added to "flash" folder under https://github.com/gree/lwf-demo/ project.
If you have any questions for following step, please feel free to ask.

  1. Extract png files from the swf file.

ruby swf2lwf.rb sprite_atlas.swf

  1. All png files are extracted and stored in sprite_atlas.lwfdata folder.
  2. Create texture sheet with exporting placement information to json file

/Applications/TexturePacker.app/Contents/MacOS/TexturePacker --format json --data sprite_atlas.json --sheet "sprite_atlas_texture.png" sprite_atlas.lwfdata/*.png

  1. A texture atlas "sprite_atlas_texture.png" and json data " sprite_atlas.json" are generated.
  2. Re-convert swf into lwf with json data.

ruby swf2lwf.rb sprite_atlas.swf sprite_atlas.json

@Adamcbrz
Copy link

Adamcbrz commented Feb 5, 2013

First thanks for getting back to me!

Thats what I had figured out but when I run through this process and import it to Unity I see the animation on meshes but the atlas doesn't show correctly. Every Mesh shows the entire atlas. My process is as follows:

  1. Publish swf using LWF_Publish.jsfl (No Errors)
  2. Use the LWFS to convert to lwf and extract the images.
  3. Use those images in Texture Packer to generate an Atlas save as JSON (Hash)
  4. Run ruby script "ruby swf2lwf.rb Jake.swf Jake.json" (outputs with no errors)
  5. Include the files in the Unity Project
  6. In unity I have a script from your Unity Video demo and put the path to the text.bytes and path to the images.
  7. I debug some of your code and realized that its expecting the atlas name to be TeethBitmap.png so I renamed my image to that.
  8. I hit play and I see the animation but all the meshes have the entire atlas instead of the UV location of the appropriate altas item

I will include the flash file and unity project to see if you can see what I am doing wrong.

Drop box link: https://www.dropbox.com/s/4d5es1xv74efc80/LWFTest.zip

Edit: I am using Unity 4.0.1

Thanks,
Adam

@HiroyukiHaga
Copy link
Contributor

It seems swf2lwf.rb didn't handle given json file properly when images in Flash file has AS linkage...
I could have right lwf by removing some AS linkage in Flash files. See following screen shot.

I'd like to take a look processes of swf2lwf.rb, please wait for a moment.

Jake_in_Unity

@HiroyukiHaga
Copy link
Contributor

Image file names that used for TexturePacker have to be as same as Linkage names.
In your process 2), LWFS extracts images with "<SWF_filename>_#.png" like "Jake_0.png" instead of Linkage name"Bitmap1.png".
You can generate right lwf file with removing process 2).

  1. Publish swf using LWF_Publish.jsfl
    This process extract all images from Flash, and save to "<SWF_filename>.bitmap" folder with Linkage name.
    In your case, "Jake.bitmap" will be generated.

  2. Generate TexturePack by using "<SWF_filename>.bitmap".

/Applications/TexturePacker.app/Contents/MacOS/TexturePacker --opt RGBA4444 --scale 1.0 --format json --data Jake.json --sheet "Jake_texture.png" Jake.bitmap/*.png

  1. Generate LWF file.
    swf2lwf Jake.swf Jake.json

  2. Open unity/basic2 project in https://github.com/gree/lwf-demo/ .

  3. Copy your resources to Resources/LWF/Jake folder, and rename Jake.lwf into Jake.bytes.

  4. Update OnGUI() method in "SampleMenu.cs" with following code.

void OnGUI()
{
    GUI.Box(new Rect(10,10,100,120), "Menu");
    if (GUI.Button(new Rect(20,40,80,20), "Sample 1"))
        PlaySample("sample1_normal");
    if (GUI.Button(new Rect(20,70,80,20), "Sample 2"))
        PlaySample("sample2_normal");
    if (GUI.Button(new Rect(20,100,80,20), "Sample 3"))
        PlaySample("sample3_normal");
    if (GUI.Button(new Rect(20,130,80,20), "Jake"))
        PlaySample("Jake");
}
  1. Click Play, and then click"Jake" button.

@Adamcbrz
Copy link

Adamcbrz commented Feb 6, 2013

Thanks worked great!

@splhack splhack closed this as completed Mar 28, 2013
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants