WinForms GUI with Unity 3D Renderer (Unity 3D embedded in WinForms) not working in Delphi with Hydra Visual Plugin


(Abhijit) #1

In my Project, I have created WinForm GUI in this I have embedded Unity 3D renderer using UWB (Unity WinForm Bridge) plugins and I want to show this whole WinForm GUI in Delphi Form using Hydra VIsual Plugins. But the Problem is that, all the controls from WinForm GUI is working well but only Unity 3D animation is not working in Delphi when I Embed WinForm GUI in Delphi. With UWB 2.0 ( Asset of Unity 3D I can run Unity 3D animation in Visual Studio WinForms program but I unable to execute when I run it in Delphi. Other WinForm GUI Controls such as Text boxes, buttons, drop down list, checkboxes etc are working fine in Delphi. Is there any solution for this problem. If you need more information kindly ask me. I have attached screenshots. ! 1. the Unity 3D Animation in WinForm GUI Project. 2. Unity 3D renderer embedded in WinForm GUI using UWB 2.0 Asset and WinForm Project configured as Hydra Plugin Module. 3. Delphi Form Project using Hydra Host Plugin which hosts WinForm GUI and displays it in TPanel of Delphi. 4. Delphi Program Execution (GUI). 5. After Clicking Load Button it loads the WinForm Hydra plugin into the TPanel (Problem is that it does not display the Unity 3D animation in renderer window but it shows it in WinForm Project. Your help and suggestions are highly appreciated. Thank you !!!

Here is the code of Delphi program: fHostForm.pas

unit fHostForm;


Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, ExtCtrls, StdCtrls, uHYModuleManager, uHYIntf, uHYBaseModuleManager;

TForm1 = class(TForm)
bLoad: TButton;
bUnload: TButton;
HostPanel: TPanel;
ModuleManager: THYModuleManager;
procedure bLoadClick(Sender: TObject);
procedure bUnloadClick(Sender: TObject);
procedure FormCreate(Sender: TObject);
procedure FormClose(Sender: TObject; var Action: TCloseAction);
fPluginForm : IHYVisualPlugin;

procedure SwitchButtons;



Form1: TForm1;


{$R *.dfm}
procedure TForm1.FormCreate(Sender: TObject);

procedure TForm1.FormClose(Sender: TObject; var Action: TCloseAction);
// Makes sure the reference to the plugin is released so that the DLL
// can unload successfully


procedure TForm1.bLoadClick(Sender: TObject);
with ModuleManager do begin
// Loads the module

//Modulemanager.LoadModule('C:\Users\abv1lo\Desktop\UWB2_Setup\UWB2_Setup\UWB2_Setup\bin\Debug\Renderer.exe'); ... not working
//Error - cannot load the Renderer.exe not a valid Win32 application.

// Creates an instance of the visual plugin
CreateVisualPlugin('AbhijitPlugin', fPluginForm, HostPanel); // See the initialization part of the unit fVisualPlugin.pas

// Displays it



procedure TForm1.bUnloadClick(Sender: TObject);
// Releases the reference to the plugin (equivalent to “fPluginForm := NIL”)

// Unloads the module


procedure TForm1.SwitchButtons;
bLoad.Enabled := ModuleManager.ModuleCount=0;
bUnload.Enabled := not bLoad.Enabled;


Visual Studio Code: Winforms

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using UWB2_Winform3D;
using RemObjects.Hydra;
using System.Runtime.InteropServices;
using RemObjects.Hydra.CrossPlatform;


public interface IABHIPLUGIN : IHYCrossPlatformInterface
void ProcessMessage(string Message);

namespace UWB2_Setup
[Plugin(Name = “AbhijitPlugin”, Description = “This is Unity plugin.”)]

public partial class Plugin1 : VisualPlugin
    public Plugin1()

    private void OnLoad(object sender, EventArgs e)

    private void PluginClosing(object sender, FormClosingEventArgs e)

    private void PluginSizeChanged(object sender, EventArgs e)

    private void Plugin_Shown(object sender, EventArgs e)

    private void Plugin1_Load(object sender, EventArgs e)

    private void backgroundWorker1_DoWork(object sender, DoWorkEventArgs e)


Following are the UWB Libraries and its structure:

UWB Setup.
UWB%20WinForm3D%20Library UWB2_Winfor§D Library

(antonk) #2

There is no much info (if at all) how UWB works.

So you need to try to do 2 things:

  1. Try to load the plugin into the default domain. When you call the ModuleManager.LoadModule method there is a second parameter. Pass there false to check if it makes a difference.

If that doesn’t help

  1. Add somewhere in your plugin constructor code line like Debugger.Attach()

So when you’ll load the plugin and it will be instantiated the system will ask you to attach Visual Studio as debugger to this process. So you’ll be able to see if there are any suppressed exceptions.

(Abhijit) #3

I have edited the post included more information. Actually there is no User manual or any information about UWb 2.0 Asset. Thanks for your reply. Could you please telll me the procedure to use my existing WinForm GUI project direclty into the Delphi Project without using Hydra Visual Plugin container. I would like to show Host WinForm directly into Delphi without adding winform controls on Visual Plugin form of Hydra.

(antonk) #4


Could you please rephrase your question? What exactly do you want to do?

Have you tried to load your plugin into the default domain?

Perhaps in your case the best solution would be to create a non-visual plugin that would expose a method to display entire GUI around the UWB in a separate WinForms window.

So it would work like this:

Delphi host app calls a plugin method
Plugin method creates a new WinForms dialog and displays it, w/o embedding into any of the Host windows