纳金网

标题: 在unity3d中使用flash作为gui的一个插件 [打印本页]

作者: 奔跑的小兔    时间: 2012-2-8 10:14
标题: 在unity3d中使用flash作为gui的一个插件
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




欢迎光临 纳金网 (http://go.narkii.com/club/) Powered by Discuz! X2.5