4

I'm trying to embed a Unity3D-ActiveX control into a WPF-Form by using a WinFormsHost-Control.

Actually it works well when setting the path in the property window of VS, but when setting it in my code file it does not load anything. This is a known issue of the control but i thought i can simply copy the creation code of the forms-designer and initialize it manually.

When looking at the code of the initialization i noticed that there is no src property in the code, but the property is used in the property window. Setting the property manually does not work ( throws a error ).

After some test's i decided to check the hole assembly for the src property, but the src property is never set and i can't even find the string of the path.

Final thoughts

I noticed that there can be only one place where the src-path is located: The resource generated by the window forms designer, which is a object of the AxHost.State-type.

Question

How do i create a valid AxHost.State object to initialize the Unity3D-ActiveX control which should load a Unity3D-file specified by me?

Community
  • 1
  • 1
Felix K.
  • 6,201
  • 2
  • 38
  • 71
  • Use the vendor's support channels to find support. – Hans Passant Jan 05 '12 at 00:29
  • 1
    @HansPassant We are talking here about the `AxHost.State` object, not about unity itself. The state object is generated by visual studio. – Felix K. Jan 05 '12 at 11:16
  • Found a solution which works, but it's nothing more than a hack. I modified the existing activeX object src path, saved the state in a local variable, disposed the existing ActiveX object, created a new one by using the state which has been saved in the local variable. – Felix K. Jan 06 '12 at 14:03

3 Answers3

4

This is the solution which works but is a little bit slow( Note: You need to initialize the Control once in the Forms Designer and copy the OcxState object into 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);
Felix K.
  • 6,201
  • 2
  • 38
  • 71
2

If you want to set a parameter into disableContextMenu property in ActiveX Unity Web player, you need to prepare IPropertyBag.Read Method in your program.

I made a sample C++ program (Visual Studio 2010) which set "true" parameter into disableContextMenu property. See http://www.nibiirosoft.com/download/UnityActiveXSample.zip

And using that codes, I made a player for .unity3d files (http://www.nibiirosoft.com/Product/UniPlayer.html).

I hope it will be helpful to you.

0

Decompiling the dll "AxUnityWebPlayerAXLib" and adding the src parameter directly in the code solves the problem.

Everything works fine, but I still have a problem with "disableContextMenu".

Irshad
  • 3,071
  • 5
  • 30
  • 51