void Start ( ) { // // Alter existing font // Add root with single textfield mc = new MovieClip( "uniSWF/Examples/Extra examples/ProgramaticTextFields/swf/programaticText.swf:Root" ) ; stage.addChild( mc ); // Ensure player is not changing textfields on timeline mc.stop(); // Get textfield txt = mc.getChildByName<TextField>( "txt" ); // Get format TextFormat format = txt.textFormat; // Set new format format.fontClassName = null; // Clear class for bitmap fonts as this points to the exact font_size_filters assets format.size = 30; // Set format txt.textFormat = format; // // Add new textfield using font and size ( must be exported ) format = new TextFormat(); format.font = "Times Bold"; format.color = Color.green; format.size = 64; BitmapTextField bmpTxt = new BitmapTextField( ); bmpTxt.width = 500; bmpTxt.height = 200; bmpTxt.textFormat = format; bmpTxt.text = "Text set from code"; bmpTxt.y = 100; bmpTxt.x = 10; bmpTxt.type = TextFieldType.INPUT; bmpTxt.addCharColor( 5, 8, Color.cyan ); bmpTxt.addCharColor( 14, 17, Color.red ); bmpTxt.appendText( ", Appended text" ); stage.addChild( bmpTxt ); }
private void reloadHull() { if (player.ship.getHull() != null) { hull_view.removeEventListener(MouseEvent.CLICK, onClick); removeChild(hull_view); hull_view = new MovieClip(); hull_view.addEventListener(MouseEvent.CLICK, onClick); hull_view.load(new string[] { "DATA\\Ships\\" + player.ship.getHull().type + ".png" }); hull_view.width = 50; hull_view.moveAxisToCenter(); hull_view.stop(); hull_view.x = hull_view.x + 5; addChild(hull_view); } }
// Use this for initialization void Start() { if (MovieClipOverlayCameraBehaviour.instance == null) { return; } juggler = new Juggler(); Starling.juggler.add(juggler); sAssets = new AssetManager(1, false); sAssets.verbose = true; audioService = AudioService.getInstance(); audioService.gameObject = this.gameObject; stage = MovieClipOverlayCameraBehaviour.instance.stage; stage.addEventListener(CEvent.RESIZE, onResize); var sWidth = Screen.width; var scaleWidth = sWidth / 640f; stage.width = Screen.width; stage.height = Screen.height; MovieClipOverlayCameraBehaviour.instance.stageScale.Set(scaleWidth, scaleWidth); var tfmc = new MovieClip("flash/fonts_shared.swf:Fonts"); tfmc.stop(); // set the default textformat var txt = tfmc.getChildByName <TextField>("txt"); textFormat = txt.textFormat; viewManager = new ViewManager(stage); assets.enqueue( "atlas", "atlas_tex" ); assets.loadQueue(AssetManager.Call(assetsProg)); }
IEnumerator Start () { #if UNITY_EDITOR if( !UnityEditorInternal.InternalEditorUtility.HasPro() ) { Debug.LogError( "Unity PRO required to load asset bundles" ); yield break; } #endif // Bundle path relative to project, please note this will not work in the webplayer, you will need to upload and change the www path accordingly string assetBundlePath = "file://" + Application.dataPath + "/uniSWF/Examples/Extra examples/AssetBundleLoading/assetBundles/assetBundleAssets0.unity3d"; WWW www = new WWW( assetBundlePath ); yield return www; if( www.error != null ) { Debug.LogError( "Failed to load asset bundle" ); yield break; } Debug.Log( "Asset bundle loaded, adding to resource loader" ); // Add asset bundle BuiltinResourceLoader loader = MovieClip.rootResourceLoader as BuiltinResourceLoader; loadedBundle = www.assetBundle; loader.addAssetBundle( loadedBundle ); // Load swf MovieClip mc = new MovieClip( "assetBundleAssets0.swf:Zombie" ); mc.stop(); Stage stage = MovieClipOverlayCameraBehaviour.instance.stage; stage.addChild( mc ); ScreenUtils.center( stage, mc ); // Unload btn MovieClip btn = new MovieClip( "assetBundleAssets0.swf:btn_ui" ); stage.addChild( btn ); btn.x += btn.width; btn.y += btn.height; ScreenUtils.createButtonWithLabel( btn, "Unload", onUnloadAssetBundle ); yield break; }