Where can I find a list of unityObject methods (functions)?

In the HTML file there is the following javascript…

unityObject.embedUnity("unityPlayer", "WebPlayer/WebPlayer.unity3d", 760, 456);

.embedUnity is one of them… can anyone point me in the right direction regarding this documentation?

Try this

http://unity3d.com/support/documentation/ScriptReference/20_class_hierarchy.html

Try this too.

I think rotaercz is referring to the web page JavaScript implementation used to help embed and manage the Unity browser plugin object.

EDIT: Is this it? http://unity3d.com/support/documentation/Manual/Working%20with%20UnityObject.html

Thank you everyone for the replies and yes FizixMan, that was what I was asking about. Hmm… I’m trying to figure out how to change the width height (the 760, 456 values in the sample code), is there no function to do this in javascript?

The way I handled sizing (at least in Unity 2.6.1) was to have the Unity plugin embedded HTML define its width/height as 100%. I didn’t need to resize it manually via JavaScript (just let it fill its container), but I suppose at that point if you have the plugin wrapped with a div you can control that div’s width and height properties which in turn Unity will size itself to fit.

I’ve tried changing the div’s width/height properties but it doesn’t seem to do anything. Hmmm… I think I’ll have to keep experimenting.

What does your embedding HTML/JavaScript code look like?

<script type="text/javascript" language="javascript">
	// unity related
	function GetUnity() {
		if (typeof unityObject != "undefined") {
			return unityObject.getObjectById("unityPlayer");
		}
		return null;
	}
	
	if (typeof unityObject != "undefined") {
		unityObject.embedUnity("unityPlayer", "WebPlayer/WebPlayer.unity3d", 760, 456);
	}

function ToggleWidth(targetLayer, w) {
		var elem, vis;
		
		if( document.getElementById ) // this is the way the standards work
			elem = document.getElementById( targetLayer );
		else if( document.all ) // this is the way old msie versions work
			elem = document.all[targetLayer];
		else if( document.layers ) // this is the way nn4 works
			elem = document.layers[targetLayer];
		vis = elem.style;
		
		vis.width = w;
	}
</script>

<div id="unityPlayer" style="width:360px;height:456px;">
			<div class="missing">
				<a href="http://unity3d.com/webplayer/" title="Unity Web Player. Install now!">
					<img alt="Unity Web Player. Install now!" src="http://webplayer.unity3d.com/installation/getunity.png" width="193" height="63" />
				</a>
			</div>
		</div>

Ahh, I did not bother with using the “embedUnity()” method. I handled the HTML manually, so my embed tags have its width/height listed as 100%, whereas that embedUnity you’re passing a fixed 760x456.

Maybe you can try:

unityObject.embedUnity(“unityPlayer”, “WebPlayer/WebPlayer.unity3d”, “100%”, “100%”);

Is this the same UnityObject as from http://www.unifycommunity.com/wiki/index.php?title=UnityObject?

Yeah, I actually tried that but it doesn’t work. Could you provide an example of doing it manually? It’d be really helpful.

Well, I just had it write out the HTML. I think this was how Unity 2.6.1 created the published HTML files and I just extracted it from there:

var unityHtml = '<object id="UnityObject" classid="clsid:444785F1-DE89-4295-863A-D46C3A781394" width="100%" height="100%"> \n' +
                                '  <param name="src" value="main.unity3d" /> \n' +
                                '  <embed id="UnityEmbed" src="main.unity3d" width="100%" height="100%" type="application/vnd.unity" pluginspage="http://www.unity3d.com/unity-web-player-2.x" ' + 
                                '/> \n' +
                                '</object>';

                document.getElementById("UnityWrapper").innerHTML = unityHtml;

Notice the 100% for width/height. In my code I have a div:

<div id="UnityWrapper" />

Theoretically, you should be able to alter that div’s width/height and it should propagate to the Unity window.

Thank you for all the help!

I did actually figure out a different way. You can get access to the object and modify the style this way… Thanks again! :slight_smile:

function GetUnity() {
		if (typeof unityObject != "undefined") {
			return unityObject.getObjectById("unityPlayer");
		}
		return null;
	}

GetUnity().style.width = 1;
GetUnity().style.height = 1;