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

在unity3d中使用flash作为gui的一个插件

[复制链接]

1602

主题

1

听众

2万

积分

资深设计师

Rank: 7Rank: 7Rank: 7

纳金币
24658
精华
6

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

跳转到指定楼层
楼主
发表于 2012-2-8 10:14:06 |只看该作者 |倒序浏览
So this is mainly a proof of concept and not yet a finnished product but I thought I would share my progress.
How it works:
Winform
The winform is***cuted by the UnityApp and a connection is set up by an AppConnector, a dll that uses Tcp/Ip to communicate and reflection to invoke functions on the remote peer (In my head this is how I imagine RPC calls work).
Then the Winform is simply placed on top of the Unity App to work as GUI.
Flash
The flash gui is simply an extension of the Winform, where the winform owns a docked flash component. Communications with the flash component happens through the flash API with a "CallCom" wrapper that makes it the same interface as the AppConnector.
In this post
I have attached a sample Unity project that has a flash button that you can click and that button creates a box with scale defined in the flash app.
I have also attached the CallCom-wrapper.
AppCommunicator
The AppCommunicator has the following functions:
Cons***ctor where you specify if he is server or not
HandleRecievedPackages: Handles any calls from the remote peer
SendMessage(string functionName, params object[] args) : Invokes a function on the remote peer.
AddListener(object o): If an object is added to the listener list it enables the remote peer to invoke public functions in him
RemoveListener(Object o)
Issues & still todo
This only works in the Unity Editor and on Standalone (Windows). It would be nice to somehow get it working on Web Player but it's tricky (as many before me has realised) because the Unity App allways wants to be displayed last.
It's a bit tricky to get the Winform "mounted" on the Unity Player. Currently to get the Unity Window position I take the Input.mousePosition from Unity and through User.32 dll get the real mouse position to calculate where Window is located. This however does not work perfectly when the mouse is in movement.
You still can't send messages to flash. I have to build a Wrapper for that who parses the params to XML to send it to flash.
Finally
I made this with Untiy 3.5 beta so I hope it will work on 3.4 as well. I really dont see why it shouldn't but just a "heads up".
I may sell this on the Asset Store, depending on if I have time and/or if this will be native feature in Unity soon, but you are free to use this "beta" as you like.
转自:http://f***m.unity3d.com/threads/115052-Flash-and-Winform-Gui-quot-Plugin-quot
I hope you will like it, tell me what you think and please post if you have any ideas on solutions to the problems and I have listed and/or you find.
相关项目文件1

相关项目文件2
分享到: QQ好友和群QQ好友和群 腾讯微博腾讯微博 腾讯朋友腾讯朋友 微信微信
转播转播0 分享淘帖0 收藏收藏0 支持支持0 反对反对0
回复

使用道具 举报

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

关闭

站长推荐上一条 /1 下一条

手机版|纳金网 ( 闽ICP备08008928号

GMT+8, 2024-4-29 03:07 , Processed in 0.085482 second(s), 33 queries .

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

© 2008-2019 Narkii Inc.

回顶部