Search Unity

  1. Megacity Metro Demo now available. Download now.
    Dismiss Notice
  2. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

Unity in a Window

Discussion in 'Wish List' started by zumwalt, May 17, 2008.

  1. zumwalt

    zumwalt

    Joined:
    Apr 18, 2007
    Posts:
    2,287
    Ability to use a Unity rendered area in a window on a regular form based application. Here is what I am talking about, I brought this subject up in the help area, but unfortunately no one understood what HWND was or what a target.hwnd was. Instead they thought I was talking about freezing pixels on a screen. Never could figure out why they thought that. Anyway, using the end result of the Unity build and tell it to render in a target window object. In the example image here, I am rendering to a picturebox. I tell my 3d applicaiton to use the PB.HWND's handle as the 3d render window handle. I know Unity can't do this at the moment, but it would come in very handy.
     

    Attached Files:

  2. AngryAnt

    AngryAnt

    Keyboard Operator

    Joined:
    Oct 25, 2005
    Posts:
    3,045
    You're talking about embedding a unity project in your own application? Ignoring that this task would probably be an extremely funky and large project for the unity guys to embark on: Why would you even want to do this?
     
  3. jeffcraighead

    jeffcraighead

    Joined:
    Nov 15, 2006
    Posts:
    740
    Well I'm not sure how much more this would take on top of the webplayer. An ActiveX control can be embedded in forms I think. BUT, I wonder the same as Ant, why would you want this?
     
  4. zumwalt

    zumwalt

    Joined:
    Apr 18, 2007
    Posts:
    2,287
    All on screen gui elements require rendering operations and take from frame rate etc. With some applications I write, I utilize exterior functions and buttons along with form objects that have no need to be in the rendered window at all. It serves no purpose. The buttons / objects that are outside of Unity can still pass elements into Unity and vice versa. I can pass variables into and out of the 3d app as needed. If you have never had a need to do what I am doing, you wouldn't understand the purpose to which this ability gives.

    I can create scientific models by altering values in a form and letting the application perform tasks against these, then I need to see the end result visually which in turn is passed as final variables back into the live rendering application, so on the next render loop, it as the correct values and renders the end result.

    You see, Unity is already performing this task, when they generate the game window, they give it a target. This target is either a window or full screen. If it is a window they have to generate the window, and the end result is the target HWND is the window HWND itself.

    What I am asking is that we gain access to that variable and be allowed to pass in our own window handle. This is not hard. All of the programs written now within Unity are based on one assumption, Unity creates the window and uses that window handle.

    This ability has wide spread use beyond just maybe a game. DNA models with code to show replication and splitting can be put into a program and Unity can handle everything else. All of the DirectX based engines I use have this ability. Unity is the only professional engine I own a commercial license of that cost me over $1k, it is the only one not able to do what I am asking.

    Maybe it never will be able to. Maybe it will. The same concept could be done with a written Cocoa application or any other mac based forms application, BUT, for this to happen, Unity will probably also need to be able to be compiled into a DLL and then the DLL called with something like:

    DWORD hwnd=PB.HWND.ToInt32();
    UnityEngine eng = new UnityEngine(hwnd,false);

    Definition:
    UnityEngine(target window handle, full screen);

    If target window handle is 0, then unity creates and controls the windows and full screen is valid to be true.

    End result of a build of Unity when you compile it using the Unity editor would need 1 more target, DLL target.

    Then we could write applications that initialize the DLL and run it. This would also mean that we need a way to expose properties and methods outside of the DLL with a secure key passed with the call so that what ever is written accepts the passed in information to avoid injection.

    Anyway, it is a wish, nothing more. I am writing applications that already do this using DirectX and OpenGL on Windows. I just wanted a way to do it cross platform using Unity which is more powerful.

    It is extremely easy for them to accomplish.
     
  5. jeffcraighead

    jeffcraighead

    Joined:
    Nov 15, 2006
    Posts:
    740
    Got it. I'll vote for this, not sure when I'd use it but I do see the benefit in this case. I've done similar work (ie. scientific visualization) and have been using .NET sockets to communicate between Unity and my other apps. It works quite well. So that may work for you too if UT doesn't like this wish :D. Its not as clean as a single app, but with Sockets you could have your processing nodes distributed around the net (I've done this in robot simulations and its pretty cool).
     
  6. Scrat

    Scrat

    Joined:
    Apr 20, 2008
    Posts:
    316
    Wouldn't it be better to use something else than Unity for what you're trying to do. I don't know but it seems Ogre3D would be the perfect choice. It is easy to integrate into forms (wxWidgets, Qt and even .NET forms with .NET wrappers), you only have a rendering engine (which is just what you need if I understand correctly), it is cross-platform Window, Mac, Linux and free.

    This is just my humble opinion but using Unity for what you are trying to do seems a little bit overkill as you don't need a full-featured game engine but just a rendering one.
     
  7. zumwalt

    zumwalt

    Joined:
    Apr 18, 2007
    Posts:
    2,287
    As I had stated, I already have DirectX based engines that I am doing this with. The kiosks are limited to Windows based platforms, and personally I hate windows but it works. I was thinking long term with the iPhone and some of the cool web work that Unity does which would come in very handy for application distribution. Interactive science models require some heavy lifting which Unity appears to handle very well.

    The interesting thing about Unity is the load level ability which can be used to load in different model scapes and retain previous information from the last "level" in this case, passing data into a new "level" which takes on a new angle for data modeling.

    You are right though, I do this with Windows now, I guess a Mac solution using Unity would not be an appropriate use of the engine. Was just looking for a way to avoid having to use Java directly to do the same thing, maybe its being lazy but hey.
     
  8. thylaxene

    thylaxene

    Joined:
    Oct 10, 2005
    Posts:
    716
    i kind of had this working with realbasic. i used the webplayer embedded in a browser canvas/form whatever they are called in realbasic. seemed to work fine. but I would have needed another plugin for realbasic to extend the the browser canvas to allow me to "talk" to unity. The test was enough for me to be convinced this would be a good (cross platform) solution for kiosks and such where you needed that extra control that unity doesn't give you... in my case the ability to use USB hardware controllers for museum interactive exhibits.

    Cheers.
     
  9. Morgan

    Morgan

    Joined:
    May 21, 2006
    Posts:
    1,223
    I would love Unity-RealBasic integration in some form. I inquired at the RB forums too.
     
  10. zumwalt

    zumwalt

    Joined:
    Apr 18, 2007
    Posts:
    2,287
    I thought about this, but the Unity browser build has a "white border" built into the control with no way to get rid of it. This is inherit to the Unity control not IE, or anything else. If there was a way to tell Unity to not have the border, it would be useful, but this is something they put into the control. Plus, I would want to disable the 'fullscreen' right click option for the web control if I embed it. Take a look at this image to see the border (and no, this is not a problem with the control it is the same on the web pages as in Firefox has the border, IE has the border, Mozilla has the border etc)
     

    Attached Files:

  11. Morgan

    Morgan

    Joined:
    May 21, 2006
    Posts:
    1,223
    All my Unity webplayers have always been borderless.
     
  12. Aras

    Aras

    Unity Technologies

    Joined:
    Nov 7, 2005
    Posts:
    4,770
    I am not sure why you are getting the white border. I have seen people embed Unity ActiveX control into external application, and it did not have any extra white borders.

    I have written Unity's ActiveX control from scratch, and I can assure you there is no white border code put into the control :)

    You can use disableFullscreen (and similarly, disableContextMenu) plugin tags to do that.
     
  13. David-Helgason

    David-Helgason

    Moderator

    Joined:
    Mar 29, 2005
    Posts:
    1,104
    How much UI do you plan to have around the Unity window? You might consider simply using UnityGUI for this, which would solve all your integration headaches.

    d.
     
  14. shaun

    shaun

    Joined:
    Mar 23, 2007
    Posts:
    728
    I think this is very cool - having the ability to embed Unity in a Winform is useful IMO. When I was using Virtools we did this a lot because we could integrate with other enterprise platforms and use things like .Net 3.5 and WCF etc whilst abstracting the limitations of the engine away from the client app. It kept the developers doing what they are good at, quickly and with no learning curve.

    Hope you post a nice walkthru on the Wiki when you're done. If Gartner predictions are correct, 80% of enterprises will use some sort of MMO solution for virtual collaboration by 2011, and a couple of companies happen to use Windows I'm sorry to say. :)
     
  15. MrBodean

    MrBodean

    Joined:
    Jan 25, 2008
    Posts:
    103
    The border? Are you simply calling a web page with the webplayer embedded? If so I think I know why you have a border.

    Try this in your html code
    add this

    <style>
    body
    {
    margin: 0;
    padding: 0;
    }
    </style>


    I think that may do the trick
     
  16. HiggyB

    HiggyB

    Unity Product Evangelist

    Joined:
    Dec 8, 2006
    Posts:
    6,183
    And if so you should be able to easily disable the context menu via the object/embed tags. If you're hosting the ActiveX Control directly then that's a bit tougher as I don't think the control exposes that option in any way.

    FWIW, I can see some value in having this option but wonder about the overall priority against other plans we have afoot.
     
  17. AngryAnt

    AngryAnt

    Keyboard Operator

    Joined:
    Oct 25, 2005
    Posts:
    3,045
    MrBodean:
    I think you're right on that one. Internet Explorer and afaik all browsers have a standard padding applied when nothing else is specified.
     
  18. zumwalt

    zumwalt

    Joined:
    Apr 18, 2007
    Posts:
    2,287
    MrBodean, thanks, I had that in my style sheet, but I had to move it to the body tag itself then it worked, so the white border went bye bye in all browsers. For some reason the CSS for the page isn't working right, going to rebuild it from scratch, maybe an invalid character is on it somewhere.

    HiggyB, I am hosting it myself (as in it goes with the software, not on a web page on a web server, it resides on the local machines)

    All others, the use for this under my circumstances goes beyond just general user control otherwise, regular GUI elements work fine. My admin tools are written 'around' the engines, I also have other tools for other projects written 'around' the engine but not in the engine. These projects are scientific in nature including simulations where from a click of a button I can load in sim data or replace entire sets of coordinates and allow for much more data to be utilized and worked on before it ever reaches the engine.

    These are all specific to the needs of the projects I am on. For instance, I am on a project for oil well drilling predictions. When the well is drilled to X depth they switch to horizontal, this then has to again be drilled X Length, of this time, insurance is calculated and if any problems happen, the problem depths and reason are recorded and recalculations happen based on reasons.

    Long boring stuff. Anyway, other things I have to do with the data is using cores and information from these cores help give drilling depth analysis information and 'what if' scenarios. This is all fine and dandy on a spreadsheet and graphs, but a visual representation of the drill helps.

    This is just 1 angle of probably a dozen scenarios, each one I am putting into a 'level' (best way to describe it for those who don't understand what I am doing), and then switch 'levels' to give different scenarios.

    I also allow them to enter notes into the system, adjust schedules in the system, and it helps to calculate out the begin to depth plan even if it turns out to be a dry well.

    So doing this the way I am doing it works in DirectX on other engines, as I began the thread, this is just a wish of mine that Unity could perform this same task, however, it is probably way out of scope of Unity's purpose. Many others know what I am talking about with wrapping the render window into the form based application and what use it is to them. Mine is more business need but I have other applications that are fitting the need, just wanted to get rid of them and just use 1 application.
     
  19. EducaSoft

    EducaSoft

    Joined:
    Sep 9, 2007
    Posts:
    650
    I would like to use the uniy activeX from within my delphi application.

    Delphi can use activeX controls easily and it takes me 2 minutes only to make a project with a unity movie playing inside my delphi form...

    But.....


    How can I communicate something (anything is welcome, but preferably sending a string) between delphi and unity and reverse ?

    Is there any method availabe on the activeX which could help us to communicate with its host system?

    For example, we all know that unity on windows explorer uses activeX, but is there a list somewhere of METHODS and PROPERTIES for this activeX control ?


    Any help would be greatly appreciated.



    And for the people who wonder why this would be usefull.
    1 sentence "Mixing Flash content and unity content (not at same time onscreen) in a customer friendly way"

    Both packages have their advantages and we can load both Flash and Unity3D content inside activeX containers. It would be great to be able to communicate from delphi to unity and back somehow. In that case we could at least send basic messages to the activeX
     
  20. skitz

    skitz

    Joined:
    Jun 26, 2007
    Posts:
    29
  21. EducaSoft

    EducaSoft

    Joined:
    Sep 9, 2007
    Posts:
    650
  22. cherub

    cherub

    Joined:
    Apr 26, 2006
    Posts:
    493
    err....wrong thread....sorry.

    ~C
     
  23. EducaSoft

    EducaSoft

    Joined:
    Sep 9, 2007
    Posts:
    650
    What is this msg doing here?
     
  24. skitz

    skitz

    Joined:
    Jun 26, 2007
    Posts:
    29
    Hmm while my original solution worked (and I even built a little application out of it) this was pre-Unity 2.x - unfortunately it doesn't seem to work anymore. Sorry! :(
     
  25. EducaSoft

    EducaSoft

    Joined:
    Sep 9, 2007
    Posts:
    650
    that was what I think too.

    I tried this previously also and then it worked, but now it doesn't anymore.

    I'll mail Aras and as if this could be made to work again, although I think chances are little
     
  26. EducaSoft

    EducaSoft

    Joined:
    Sep 9, 2007
    Posts:
    650
    At this moment it looks like this is NOT supported in an easy way.

    I'll try to explain what I got as response when asking the same question earlier.

    "In the ActiveX plugin we're using CDataPathProperty to download the
    data (which then uses some MFC voodoo internally, i.e. binding to some
    monikers, etc.). So I think it's the ActiveX container's
    responsibility to handle that "somehow"."


    As I try to understand this, it would mean that your browser software is responsable for feeding the data of the unityweb file into the plugin.
    According to UT this is the preferred way for doing it in internet explorer on windows.(and they are probably right when its about internet explorer)

    Now this could of course be the reason why it doesn't work when embedding this activeX into an application. Setting the SRC property doesn't tell the activeX to load (yeah, even I don't really understand why you set it then)


    Now I've mailed to Aras Pranckevicius at Unity Technologies and asked him if there is a possibility to at least build this functionality into the activeX.

    It can't be more then just accepting some kind of parameter in the SRC property (maybe instead of http:// or file:// it could just accept SOMETHING else, no matter what but that param should tell the webplayer to read the file specified from local disk)

    As you might know the people at unity never sleep, so its always very busy over there. Therefore, it could take some time before I get an answer to this.

    I do intend to follow this up, because on this forum there are allready other people who have asked this and if unity ever gets available on the windows platform (dunno when, but the activeX is allready working so the demand is already there) then I can guess that there will be a lot more of these questions asking how to integrate the activeX in programs like VB or delphi.

    Flash and Director Shockwave + a lot of other plugins handle this perfectly OK. You set the SRC property and the plugin loads in the content. as a matter of fact I haven't seen any activeX before which did not handle this (if the plugin has a similar property of course)

    I really hope that UT can implement this in the webplayer, certainly because in a previous version of the player (1.62) this worked perfectly.

    My company would even pay for it if it cannot be implemented for free, but I cannot say enough that this is a feature that is very very very (3 times is enough) important on windows platform the have integration in anything else then a webbrowser)

    I agree that you could indeed now also embed a webbrowser into your vb or delphi program and then in that webbrowser you can load custom html to load the plugin that way. However, this is not a good way to go if you intend to sell your software commercially. Its way to dangerous to deploy using that technique on the diversity of PCs out there...

    A) If you embed the activeX directly, then the only necessity to run your software is that the activeX should be on the system.

    B) If you load it through the webbrowser interface, then you are at the grace of the webbrowser. If the pc is infected with some popup-throwers, then you can even get unwanted popups when using your software. And what if the users internet explorer is setup to BLOCK activeX controls, or to disable local loaded javascript by default. What if internet explorer isn't even installed at all on that system or if its broken ?


    You see, there are just too many cons to even consider loading it up through a custom webbrowser on your form.


    If somebody at unity technologies read this, then pretty please do try to understand our request.
    I'm 100% sure that it is NOT a big one and I'm not asking for a solution by tomorrow (since you are bussy).
    But please have a look if this can be implemented.

    I even bought a unity pro license back in the 1.62 days when I tried and found that the activeX worked when embedded inside my delphi application. Now it doesn't work anymore and I aint the only person who allready asked for this on the forum.

    Embedding the activeX makes a lot of sense for some developers among us (ok, maybe not all, but there is more then game programming isn't there?)

    I'll post this message to the other threads also which handle the same subject and hope to hear the opinion of other people on this subject.

    It worked before -> I hope it can be made working again...


    Kind regards and thank you for reading this large post.

    Bart Libert
    ceo EducaSoft BVBA
    Emiel gellyncklaan 8
    8940 Wervik
    Belgium
     
  27. HiggyB

    HiggyB

    Unity Product Evangelist

    Joined:
    Dec 8, 2006
    Posts:
    6,183
    And also know that we're working full-tilt on internal projects, notably Unity for Windows, that of course includes Aras. This isn't a priority for that release and so it will likely sit on a back-burner until we're clear of that release.


    There's no need to "pretty please" us into understanding this request, I think we already "get it" but have other things on our plate (and have had on our plate) with a higher priority. I know how often folks used this with Shockwave for example, so I know how this can help here as well. :)
     
  28. EducaSoft

    EducaSoft

    Joined:
    Sep 9, 2007
    Posts:
    650
    So what should I do then?

    Just shup up until the next release of unity is ready and then start asking again?

    Or is it by this allready included in the todo for that next release Tom ?

    And by the way, thanks for fast response
     
  29. HiggyB

    HiggyB

    Unity Product Evangelist

    Joined:
    Dec 8, 2006
    Posts:
    6,183
    Note that you chose to make this a touch negative with "shut up until..." All I was trying to do was set some expectations and fill you in on where our priority focus is for right now. So my suggestion as to what to do is to wait patiently for us to clear the Windows launch then either ping Aras again or check back for updates.


    I can't say for sure whether it's on a to-do list for another release, all I know is that I don't believe it's on the list for the coming release and that Aras and the engineers aren't likely to divert focus at this point.
     
  30. EducaSoft

    EducaSoft

    Joined:
    Sep 9, 2007
    Posts:
    650
    Is shutting up negative, then my appologies.

    My native language isn't English. I didn't want to say it in a negative way.
     
  31. Schaerer

    Schaerer

    Joined:
    Dec 17, 2007
    Posts:
    35
    We are also seriously interested in being able to embed a unity window inside our own applications and would be willing to fork over some cash to see this happen.
    We would like to be able to do this on both OSX and Windows (future linux, once Miguel finishes the Linux port) platforms.
    For us it would be important to have the player embedded so we could call our extern dot net and CPP dlls / dylibs ( web player we cannot do this).

    Thanks!
     
  32. HiggyB

    HiggyB

    Unity Product Evangelist

    Joined:
    Dec 8, 2006
    Posts:
    6,183
    It's just a touch abrupt and yes, a bit negative. You generally command someone to "shut up!" and thus it's negative tone and my preference for "patiently wait". :)
     
  33. Deleted User

    Deleted User

    Guest

    If you use Wikipedia as an etiquette guide, this entry explains it:

    http://en.wikipedia.org/wiki/Shut_up

    My fifth grade teacher told us "Don't say shut up, that's truck driver talk!" I've never actually heard a truck driver say it, but they probably do on the Internet.
     
  34. minevr

    minevr

    Joined:
    Mar 4, 2008
    Posts:
    1,018
  35. jcarpay

    jcarpay

    Joined:
    Aug 15, 2008
    Posts:
    561
  36. minevr

    minevr

    Joined:
    Mar 4, 2008
    Posts:
    1,018
    Allows indie version of a document to build a Win Exe
     
  37. bloodtiger10

    bloodtiger10

    Joined:
    Nov 9, 2008
    Posts:
    619
    how? and isn't it illegal?
     
  38. Dreamora

    Dreamora

    Joined:
    Apr 5, 2008
    Posts:
    26,601
    how many chinese things do you know that are legal when it comes to multi hundred USD software?
     
  39. bloodtiger10

    bloodtiger10

    Joined:
    Nov 9, 2008
    Posts:
    619
    good point! :D
     
  40. HiggyB

    HiggyB

    Unity Product Evangelist

    Joined:
    Dec 8, 2006
    Posts:
    6,183
    Yes, but now I've been alerted to this activity and I will investigate this for potential license violations.


    @Minevr: is this from you? Please contact me (PM or email) ASAP, thanks.


    And yes, lots of piracy around the world, we'll never put out all the "fires" but we also won't let them burn unchecked so I'm off to see what I can find out.
     
  41. minevr

    minevr

    Joined:
    Mar 4, 2008
    Posts:
    1,018
    @HiggyB:I have PM you.
     
  42. minevr

    minevr

    Joined:
    Mar 4, 2008
    Posts:
    1,018
    AS FAR AS I KNOW, ALL UNITY3D USERS IN CHINA ARE USING LEGAL UNITY3D NOW AND I AM ONE AMONG THEM. SO PLEASE PAY ATTENTION TO WHATYOU ARE TALKING ABOUT.
    据我所知,在中国,所有Unity3D用户用的都是正版!包括老子!请注意你言辞!

    ps:Well, as you know, we lent all of our money to Uncle SAM
     
  43. HiggyB

    HiggyB

    Unity Product Evangelist

    Joined:
    Dec 8, 2006
    Posts:
    6,183
    Please stop shouting, there's no need for all caps. I'll look for your PM now but am no longer worried about what you're doing (it was passing, a quick check showed all seemed to be ok so I moved on).
     
  44. extragotcha

    extragotcha

    Joined:
    Mar 20, 2009
    Posts:
    42
    Has someone managed to find a good workflow to embed unity into windows forms? My current project is of the industrial visualization type. I know there are few of us out there ;)
     
  45. Christian

    Christian

    Joined:
    Dec 2, 2008
    Posts:
    24
    In one of our last projects we had the same problem. We want to embed a Unity3D window in a C# application to visualize some 3D data with it.

    After some research we decided that the best way to integrate Unity in a C# application is to use the web browser component of .Net and display a unity webplayer in this component. To handle the communication between the external c# app and the webplayer, unity opens a tcp server and listen for incoming connections from localhost. After loading the web browser content (in this case the Unity app), the c# app connect themself to the unity server so that both apps can exchange serialized data over a tcp connection.

    With some tricks it should be possible to code a custom SendMessage function in Unity and the c# app that can call any method of the other component, like it's implemented for the Webplayer - Browser communication.

    Here some Screenshots of our Unity3D/C# Hybrid application:
     

    Attached Files:

    mrtkhosravi and BilalShafqat like this.
  46. rouhee

    rouhee

    Joined:
    Dec 23, 2008
    Posts:
    194
    On windows, I simply use c# to do a basic form with WebBrowser Component. It uses IE as browser, but it works fine. Although have some problems to enter fullscreen mode.
    It is very easy to load stuff into it and you can use also other content in it (if you need to i.e. Flash, Java, PHP, etc).
     
  47. helloween

    helloween

    Joined:
    Nov 19, 2009
    Posts:
    8
    Hi,

    I am trying to load a html demo of unity into a webbrowser component in c# but it seems like it doesnt load the unity webplayer and the demo doesnt work.
    I have tried to deactivated all security options from IE but in vain.

    Could you tell me more on how you did it ?

    thanks!

    Also, I agree that using Unity in an external window would be great, like most other engines, a simple hwnd to give or something like that.
    I don't want to be rude but the GUI system in the editor is really really,apart from some scripts/simple buttons there is nothing much to do.

    It would be a lot better if we could use a Unity "sdk" in pure code instead of being forced to use the editor.
     
  48. helloween

    helloween

    Joined:
    Nov 19, 2009
    Posts:
    8
    Ok, just found why it wasnt working!
    I was compiling for x64...

    thx anyway.
     
  49. dongke

    dongke

    Joined:
    Apr 17, 2008
    Posts:
    93
    Hi Christian , could you please upload a small example of your method about opening a tcp and do perfect communicate between unitywebplayer and c# program?
    thankyou very much!
     
  50. rapidrunner

    rapidrunner

    Joined:
    Jun 11, 2008
    Posts:
    944
    not sure if is relevant, but is there a way to do this on mac for a regular desktop app?