ActiveX Initialization: AxHost.State Object

I am trying to embed a Unity3D-ActiveX control in a WPF form using WinFormsHost-Control.

Actually, this works well when setting the path in the VS properties window, but when you install it in my code file, it doesn't load anything. This is a known management issue, but I thought I could just copy the code to create the form designer and initialize it manually.

When I looked at the initialization code, I noticed that there is no property in the code src, but the property is used in the properties window. Setting the property manually does not work (it gives an error message).

After some testing, I decided to check the hole assembly for the property src, but the property is srcnever set, and I can’t even find the path string.

Final thoughts

I noticed that there can only be one place where the src path is located: a resource created by the window form constructor, which is an object of the AxHost.State type.

Question

How to create a valid object AxHost.Stateto initialize a Unity3D-ActiveX control that should load the Unity3D file I specified?

+3
source share
3 answers

This is a solution that works, but a little slower (Note: you need to initialize Control once in the form constructor and copy the OcxState object to the assembly resources):

// Create a ocx state object with the correct path
_Unity = new AxUnityWebPlayerAXLib.AxUnityWebPlayer();
((System.ComponentModel.ISupportInitialize)(_Unity)).BeginInit();
_Unity.OcxState = (AxHost.State)(Resources.Unity3DOcx);
_Unity.TabIndex = 0;
Controls.Add(_Unity);
((System.ComponentModel.ISupportInitialize)(_Unity)).EndInit();
_Unity.src = _File;
AxHost.State state = _Unity.OcxState;
_Unity.Dispose();

// Create the unity web player object
_Unity = new AxUnityWebPlayerAXLib.AxUnityWebPlayer();
((System.ComponentModel.ISupportInitialize)(_Unity)).BeginInit();
this.SuspendLayout();
_Unity.Dock = DockStyle.Fill;
_Unity.Name = "Unity";
_Unity.OcxState = state;
_Unity.TabIndex = 0;
Controls.Add(_Unity);
((System.ComponentModel.ISupportInitialize)(_Unity)).EndInit();
this.ResumeLayout(false);
+4
source

If you want to set the parameter to the disableContextMenu property in ActiveX Unity Web Player, you need to prepare the IPropertyBag.Read method in your program.

++ (Visual Studio 2010), "true" disableContextMenu. . http://www.nibiirosoft.com/download/UnityActiveXSample.zip

, .unity3d (http://www.nibiirosoft.com/Product/UniPlayer.html).

, .

+2

dll "AxUnityWebPlayerAXLib" src .

, "disableContextMenu".

0

All Articles