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.UWB2_Winfor§D Library