FAQs




Requirements


Unity 3.5 or above.
OS X or Windows® XP/7.
Adobe® Air® runtime.
Adobe® Flash® CS5 or above *.

  • CS4 works with some known issues, see FAQ for a solution.

What Unity platforms are supported?


Unity Web Player

Unity Desktop Player ( Windows, Mac & Linux )
Unity iOS player

Unity Android Player

(Depreciated) Unity Flash® Player see notes

Coming soon: Window Phone 8


Does the WWWMovieClip support streaming or is it in memory?


In memory only.


Does uniSWF support video streaming?


no


Does uniSWF handle vector graphics or does it render everything to bitmaps?


uniSWF is a bitmap based renderer designed for speed, vectors are cached to bitmaps.


Does uniSWF support console platforms?


Though untested at this point there is no reason why it shouldn't work, the library is 100% .net. A few shader tweaks is all that is needed depending on the target platform.


What languages does uniSWF support?


Javascript
C#
Boo


How would I add a collider to a movieclip based animation?


Create a GameObject and attach a MovieClipBehaviour . Then add the collider.


What does the DrawScale do?


The DrawScale represents the swf pixels to the scene unit scaling eg. A DrawScale of 0.01 (default) scales 100 pixels in the swf to 1 game unit.


How do I embed font characters in a font?


To embed characters select the swf file in Unity Project view, go Window->uniSWF->Export Options, then expands the fonts section.
There are 2 options here:

1. You can type all the characters manually in the "Embed characters" field which requires every character eg. abdef..ü etc.

2. You can also embed Unicode ranges ( http://www.unicodemap.org/ ) for example the ü is "Latin-1 Supplement" 0x0-0xff so in the "Embed Unicode ranges" change it to 00-FF or enable ASCII in the "Character Set" section.

Also if the number of characters exceeds 1024, enabling "Pack tileset" will speed up the conversion process.


How do I use the WWWMovieClip


Select the swf ( in this case banner1.swf" ) file in the project view then go Window->uniSWF->Export Options, then expand Export Actions and tick on 'Embed assets' and press 'Export 'banner1'' to export it.

In the project view look in the Resources/ folder and there should be a folder named 'banner1.swf' or whatever the exported swf name is. Upload this folder to a web server, for the example below it is uploaded into the root of the web server.

The URL for the WWWMovieClip is always the folder name, do not include the file eg "banner1.swf.bytes" in the url





using UnityEngine;
using System.Collections;
using pumpkin.display;
using pumpkin.events;

public class WWWMovieClipTest : MonoBehaviour {

    // Use this for initialization
    void Start () {
    
        string url = "http://127.0.0.1:8080/banner1.swf";    // swf folder from the resources/ uploaded to web root
        
        WWWMovieClip clip = new WWWMovieClip( url, "Banner" );
        
        MovieClipBehaviour mc = GetComponent();
        mc.stage.addChild( clip );
        
        clip.addEventListener( ErrorEvent.ERROR, delegate( CEvent e ) {
            Debug.Log( "Clip failed: " + e.toEvent().error );
        });
        
        clip.addEventListener( CEvent.COMPLETE, delegate( CEvent e ) {
            Debug.Log( "Clip complete: " + clip );
        });     
    }
    
    // Update is called once per frame
    void Update () {
    
    }
}


How do I draw Textures or Materials?


Example code below, add a Texture2D or a Material to your behaviour and use the following code to draw into a Sprite:




using pumpkin.swf;
using pumpkin.display;

// To add dynamic png texture
Texture2D texture = .. // load texture here, could use WWW or load from Resource.Load
var spriteImg = new pumpkin.display.Sprite();
spriteImg.graphics.drawRectUV( texture, new Rect( 0,0,1,1), new Rect( 0, 0, texture.width, texture.height)  ); // Draw a texture or material into a sprite



To draw a Unity material


if( TextureManager.instance == null ) {
   new TextureManager();
}
Material material = new Material( TextureManager.baseBitmapShader );
material.mainTexture = .. // Set texture here
var spriteImg = new pumpkin.display.Sprite();
spriteImg.graphics.drawRectUV( material, new Rect( 0,0,1,1), new Rect( 0, 0, material.mainTexture.width, material.mainTexture.height ) ); // Draw a texture or material into a sprite

// Remeber to destory dynamic the material unless the materail is linked as project asset.
//GameObject.Destroy( material );



To add the sprite to an existing MovieClip do the following:


// Get the movieclip container to attach to
MovieClipBehaviour mcb = ... // Get mcb or overlay camera
var mc = mcb.movieClip.getChildByName( "myThumbnail" );
mc.addChild(spriteImg);

Also when attaching a sprite to a movieclip ensure the instance doesnt go out of scope when on the timeline.


How do I adjust the kerning of a charcter on a Font or TextField


An example how to get a character from a TextField/Font and adjust any character spacing:



// Get the TextField from an existing movieclip
var txt:TextField = mcgetChildByName.("txt");
       
// Cast to implementation type
var bmpTxt:BitmapTextField = txt_total as BitmapTextField;

// Get the character "2" from the font
var glyph:GlyphInfo = bmpTxt.getGlyph( "2"[0] );     //  [] operator is required to get a char type from a string in JS

// Increase character spacing + 20 pixels
glyph.charWidth += 20;

// Get another character, inline style
bmpTxt.getGlyph( "A"[0] ).charWidth += 10;

// Update the TextField to apply new character widths
bmpTxt.text = "22";

Does uniSWF support Runtime Shared Libraries ( RSL )


RSL is not supported but a feature exists to link shared exports between SWF files by doing the following:

To create a shared asset create a new FLA called eg. shared.fla. To share an asset you need to add "_shared" to the end of the export name.

Shared.fla: Button_shared (MovieClip)

Select the swf in unity, go Window->uniSWF->Export options and expand MovieClip References then click "Export references", by default uniswf will not export anything that has the _shared.

To use the shared asset, create a new FLA eg. called menu.fla, copy the Button_shared using the flash copy/paste into the menu FLA. at this point unSWF will not export the assets used by the Button_shared but only reference it.

To link the shared asset all you have to do is load the shared.swf before the menu.swf, a good way to this is follow "Step 6" on the shared font tutorial here: http://uniswf.com/home/tutorials/id/109

Or just add the shared.swf to the shared asset manager behavior in the Components->uniSWF menu


How do I load a SWF from an asset bundle?


Loading an asset bundle:
using pumpkin.swf;

AssetBundle assetBundle = .. // load from www etc
BuiltinResourceLoader loader = MovieClip.rootResourceLoader as BuiltinResourceLoader;
loader.addAssetBundle( assetBundle ); // Will auto enable


Loading a MovieClip:
new MovieClip( "Resources/some.swf:Linkage" ); // Will search added asset bundles for assets

Creating an asset bundle hint:

// Must be relative to project and full filename including .bytes extension.
AssetDatabase.LoadAssetAtPath( "Assets\Resources\some.swf\some.swf.bytes" );

// Add all textures in export folder here
AssetDatabase.LoadAssetAtPath( "Assets\Resources\some.swf\some.swf_tex0.png" );


What is the difference between the MovieClipOverlayCameraBehaviour, MovieClipBehaviour and the InteractiveMovieClipBehaviour


MovieClipOverlayCameraBehaviour will render a 2D overlay on the "Main Camera", each pixel in flash is the same as a screen pixel in the unity viewport.

MovieClipBehaviour will render a MovieClip in a 3d scene and can be used as regular Unity GameObjects. The scale is 100 pixels per 1 unity unit, this can be adjusted with the drawScale property in the inspector.

InteractiveMovieClipBehaviour is the same as a MovieClipBehaviour but allows for mouse and touch input as long as theres a valid box collider assigned to the GameObject.


(Unity4.3) Project does not compile due to the Sprite class conflict.


Rename any Sprite class references to pumpkin.display.Sprite or reference the class using the following code:

C#:


using SWFSprite = pumpkin.display.Sprite;

void Start() {
   SWFSprite = new SWFSprite();
}

JS:



void Start() {
   var s:pumpkin.display.Sprite = new pumpkin.display.Sprite();
}

How do I unload an swf


To unload an swf asset use the following code, ensure any trailing :Linkages are removed.


MovieClip.unloadSwf( "some.swf" );


To unload all movieclips use the following code:


MovieClip.clearContextCache();

Updating uniSWF DLLs from a zip file


- Open unity with the project that needs upgradring, this step is important.

- Open the uniSWF/DLLs folder in Windows explorer or Finder on Mac.

- Overwrite LibUniSWF.dll, LibUniSWFInternal.dll, and Editor/LibUniSWFEditor.dll.

- Activate the Unity application from the dock and the asset database should refresh.

- To verify the update has worked, go Window->UniSWF->Welcome, the version and build numbers should match the original zip or package name.