查看: 2278|回复: 0
打印 上一主题 下一主题

unity3d发布的flash与其它flash间的通信

[复制链接]

1602

主题

1

听众

2万

积分

资深设计师

Rank: 7Rank: 7Rank: 7

纳金币
24658
精华
6

最佳新人 活跃会员 热心会员 灌水之王 突出贡献

跳转到指定楼层
楼主
发表于 2012-2-8 10:16:13 |只看该作者 |倒序浏览
By popular demand, here's an example of how one can use UnityShared.swc to create a custom preloader and communicate between Unity and Flash.

The ActionScript source of this project can be used with ActionScript tools like FlashBuilder, FDT and FlashDevelop. The project needs to be setup so that the provided UnityShared.swc is used as a library.

In UnityShared an AS3 class named UnityContentLoader is provided, which is the base for loading and communicating with UnityContent.

When publishing to Flash Application.ExternalCall is routed to what is set as the UnityContentHost, when cons***cting the UnityContentLoader. These messages (unfortunately there is no way to send arguments at this point in time using Application.ExternalCall), then are directly called on IUnityContentHost.

The unityInitStart and unityInitComplete have to be implemented by the class set as IUnityContentHost and signify when the UnityContent is done loading and starting to initialize, and when it's done initializing, and ready for communication from AS3.

To communicate from AS3 to Unity, one calls sendMessage on the unityContent property of unityContentLoader. The sendMessage functionality is similar to the sendMessage functionality of the Unity webplayer.

sendMessage accepts arguments in the following order; first a string path to the gameobject, then the method to be called on that gameobject, and then an anonymous object to contain the arguments. This way, one can marshall direct references to objects between AS3 and Unity, cache them and call them directly.

This api is by no means in it's final state and are subject to change in later drops(we are thinking about a full api inside unity towards AS3, similar to custom platform api's for other platforms), but it should help implementing things like networking.

I'll post more examples in this thread.



相关下载1



相关下载2





文章来自unity3d8中文学习社区
分享到: QQ好友和群QQ好友和群 腾讯微博腾讯微博 腾讯朋友腾讯朋友 微信微信
转播转播0 分享淘帖0 收藏收藏0 支持支持0 反对反对0
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

手机版|纳金网 ( 闽ICP备2021016425号-2/3

GMT+8, 2024-11-23 12:59 , Processed in 0.441586 second(s), 32 queries .

Powered by Discuz!-创意设计 X2.5

© 2008-2019 Narkii Inc.

回顶部