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

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 (https://assetstore.unity.com/packages/templates/systems/uwb-2-0-unity-winform-bridge-107159) 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;

interface

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

type
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);
private
fPluginForm : IHYVisualPlugin;

procedure SwitchButtons;

public

end;

var
Form1: TForm1;

implementation

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

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

ModuleManager.ReleaseInstance(fPluginForm);
end;

procedure TForm1.bLoadClick(Sender: TObject);
begin
with ModuleManager do begin
// Loads the module
LoadModule(‘C:\Users\abv1lo\Desktop\UWB2_Setup\UWB2_Setup\UWB2_Setup\bin\Debug\UWB2_Setup.dll’);

//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
fPluginForm.ShowParented(HostPanel);
//fPluginForm.Show;

end;

SwitchButtons;
end;

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

// Unloads the module
ModuleManager.UnloadModule(0);

SwitchButtons;
end;

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

end.

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;

[Guid(“DF8CC56C-27FA-4091-9471-1F53AC6DA84B”)]

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()
    {
        InitializeComponent();
    }

    private void OnLoad(object sender, EventArgs e)
    {
        uwB2_Winform3DLib1.Init();
    }

    private void PluginClosing(object sender, FormClosingEventArgs e)
    {
        uwB2_Winform3DLib1.UWB2_Closing();
    }

    private void PluginSizeChanged(object sender, EventArgs e)
    {
        uwB2_Winform3DLib1.UWB2_Resize();
    }

    private void Plugin_Shown(object sender, EventArgs e)
    {
        uwB2_Winform3DLib1.UWB2_Resize();
    }

    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

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.

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.

Hello

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