x


3D Object Doesn't Show Up In Safari Web Player

We built a web player of our project and it works great in IE and Firefox on PC and Firefox on Mac but will not run properly in Safari! It loads and the interface we designed comes up but the 3d object doesn't show. Any ideas what could cause this?

more ▼

asked Jun 16 '11 at 04:27 PM

krivel gravatar image

krivel
-4 1 1 1

Any takers on this? As per Unity's suggestion, we've separated our "interface" script and "camera" script but the 3d object still does not load in Safari. Any ideas?

Jun 28 '11 at 03:25 PM krivel

Safari's always sucked for me when it comes to the webplayer.

Jun 28 '11 at 09:25 PM Eli Davis

I should also note that the initial load in firefox on mac does the same thing...no 3d object. But reloading it works fine. But still nothing in Safari. Must be a bug no?

Jun 30 '11 at 06:44 PM krivel

Sounds like it

Jun 30 '11 at 11:48 PM Eli Davis
(comments are locked)
10|3000 characters needed characters left

4 answers: sort newest

Your code relies on the initial value of Screen.width and/or Screen.height:

private var quarterScreen = 4.0 / Screen.width;
...

That is bad, since these change dynamically as the WebPlayer is loaded and resized. You need to track and adapt to changes in these values, or at the very least hard-code in your final assumed size. So:

function Update()
{
    quarterScreen = 4.0 / Screen.width;
    ...

The reason you see different results in different browsers is that they each resize plugins in their own unspecified ways. Safari's way happens to hit your bug, but that's not Safari's fault.

more ▼

answered Jul 12 '11 at 03:10 PM

Waz gravatar image

Waz
6.4k 22 33 70

(comments are locked)
10|3000 characters needed characters left

Bump...posting the code for our camera. Something in here I'm thinking isn't working. We tried a try-catch scenario and get no errors. Any takers?

*********************************************** //CAMERA SETTINGS var target : Transform; //What to rotate around var interfaceGameObject : GameObject; // 07-05-2011 RMG: New

//Standard Settings

private var camDistance : float = 15.0; //# //17

private var offsetCircleX : float = 0.2; //# private var offsetCircleY : float = 1.0; //#

private var startAngleX : float = 122.5 + 180; //# private var startAngleY : float = 91.9; //#

private var angleMin : float = 45.0; //# private var angleMax : float = 92.0; //#

private var angleX : float = 0.0; private var angleY : float = 0.0;

private var xSpeed : float = 45.0; //X sensitivity //# private var ySpeed : float = 45.0; //Y sensitivity //#

private var speedDecay: float = 0.97; //#

private var xMouse : float = 0.0; //X rotation private var yMouse : float = 0.0; //Y rotation

private var xMousePin : float = 0.0; private var yMousePin : float = 0.0;

private var velX : float = 0.0; //X Velocity private var velY : float = 0.0; //Y Velocity

private var useVelocityLimits : boolean = true; private var velXMax : float = 30.0; private var velYMax : float = 30.0;

//HD SETTINGS /* private var camDistance : float = 14.5;

private var offsetCircleX : float = -0.2; private var offsetCircleY : float = 1.25;

private var startAngleX : float = 122.5 + 180; private var startAngleY : float = 91.9;

private var angleMin : float = 45.0; private var angleMax : float = 92.0;

private var angleX : float = 0.0; private var angleY : float = 0.0;

private var xSpeed : float = 45.0; //X sensitivity private var ySpeed : float = 45.0; //Y sensitivity

private var speedDecay: float = 0.98;

private var xMouse : float = 0.0; //X rotation private var yMouse : float = 0.0; //Y rotation

private var xMousePin : float = 0.0; private var yMousePin : float = 0.0;

private var velX : float = 0.0; //X Velocity private var velY : float = 0.0; //Y Velocity

private var useVelocityLimits : boolean = true; private var velXMax : float = 30.0; private var velYMax : float = 30.0; */

private var quarterScreen : float = parseFloat(4)/parseFloat(Screen.width); private var interfaceComponent : Interface = null; // 07-05-2011 RMG: New private var screenAspectRatio : float; // 07-05-2011 RMG: New private var screenRes : Vector2; // 07-05-2011 RMG: Screen resolution at startup

function Start(){

// 07-05-2011 RMG: Save our screen resolution. If this changes, we need to initialize again. screenRes = new Vector2(Screen.width, Screen.height); Initialize();

// 07-05-2011 RMG: If an interface game object exists, find it's Interface component. if (interfaceGameObject != null) { interfaceComponent = interfaceGameObject.GetComponent("Interface"); } //Set Initial Camera Angle angleX = startAngleX; angleY = startAngleY;

UpdateCameraPosition(); }

function LateUpdate() {

var mousePos = Input.mousePosition;

if(Input.GetMouseButtonUp(0)) { //Released mouse button velX = mousePos.x - xMousePin; velY = mousePos.y - yMousePin;

//Check for limits if (useVelocityLimits) { if (velX > velXMax) velX = velXMax;

if (velX < (velXMax * -1)) velX = velXMax * -1;

if (velY > velYMax) velY = velYMax;

if (velY < (velYMax * -1)) velY = velYMax * -1; } }

if (Input.GetMouseButtonDown(0)) { //Pushed mouse button xMousePin = mousePos.x; yMousePin = mousePos.y;

// 07-05-2011 RMG: If an interface component exists, call OnMouseClicked. if (interfaceComponent != null) interfaceComponent.OnMouseClicked(Input.mousePosit ion);

} else if(Input.GetMouseButton(0)) { //Mouse button is down xMouse = mousePos.x - xMousePin; yMouse = mousePos.y - yMousePin;

//Check for limits if (useVelocityLimits) { if (xMouse > velXMax) xMouse = velXMax;

if (xMouse < (velXMax * -1)) xMouse = velXMax * -1;

if (yMouse > velYMax) yMouse = velYMax;

if (yMouse < (velYMax * -1)) yMouse = velYMax * -1; }

xMousePin = mousePos.x; yMousePin = mousePos.y;

} else { //Handle Velocity xMouse = velX; yMouse = velY;

if (velX != 0.0) velX = velX * speedDecay; if (velY != 0.0) velY = velY * speedDecay;

if (velX < 0.01 && velX > -0.01) velX = 0.0; if (velY < 0.01 && velY > -0.01) velY = 0.0;

}

UpdateCameraPosition(); }

function Update () { // 07-05-2011 RMG: If screen resolution changes, call Initialize() if (screenRes.x != Screen.width || screenRes.y != Screen.height) { screenRes = new Vector2(Screen.width, Screen.height); Initialize(); } }

function Initialize() { if (Screen.width >= 1200) { camDistance = 14.5; offsetCircleX = -0.2; offsetCircleY = 1.25; speedDecay = 0.98; } else { camDistance = 15.0; offsetCircleX = 0.2; offsetCircleY = 1.0; speedDecay = 0.97; } screenAspectRatio = Screen.width / Screen.height; }

function UpdateCameraPosition(){

var cam = Camera.main; if (cam == null){ print("! Need to tag a camera as Main Camera !"); return; }

angleX += xMouse * screenAspectRatio * quarterScreen * xSpeed; angleY += yMouse * screenAspectRatio * quarterScreen * ySpeed;

//Check angle limits if (angleY < angleMin){ angleY = angleMin; velY = 0; } else if (angleY > angleMax){ angleY = angleMax; velY = 0; } if (angleX > 360){ angleX -= 360; } else if (angleX < 0){ angleX += 360; }

//print(angleX + " : " + angleY);

//Get position around object using polar coordinates var x:float = camDistance * Mathf.Cos(Mathf.Deg2Rad * angleX) * Mathf.Sin(Mathf.Deg2Rad * angleY); var y:float = camDistance * Mathf.Cos(Mathf.Deg2Rad * angleY); var z:float = -camDistance * Mathf.Sin(Mathf.Deg2Rad * angleX) * Mathf.Sin(Mathf.Deg2Rad * angleY);

//Offset from target if (target){ x += target.position.x; y += target.position.y; z += target.position.z; }

//Offset ring x += (Mathf.Cos(Mathf.Deg2Rad * angleX) * offsetCircleX); z += (Mathf.Sin(Mathf.Deg2Rad * angleX) * offsetCircleY) * -1;

//Position camera; cam.transform.position = Vector3(x, y, z);

//Rotate camera to face object cam.transform.rotation.eulerAngles = Vector3((angleY-90)*-1, angleX-90, 0);

}

more ▼

answered Jul 12 '11 at 02:59 PM

krivel gravatar image

krivel
-4 1 1 1

Editing your answer would suffice. Formatting the code properly would have been ideal.

Jul 12 '11 at 03:14 PM Waz

Sorry Warwick..I don't follow.

Jul 12 '11 at 03:16 PM krivel

You should not add an answer to bump your question, that makes it look more already-answered. Instead, edit your original question. That bumps it on the Questions list too.

If you meant to comment on my answer,

private var quarterScreen : float = parseFloat(4)/parseFloat(Screen.width); 

That is wrong.

Jul 12 '11 at 03:29 PM Waz

Yeah sorry...did that by mistake..still getting used to the format here. But HUGE thanks for pointing that out. Been driving us nuts!! Its fixed now! I owe you a round some day so maybe at a future Unity event or something :-)

Jul 12 '11 at 04:36 PM krivel

I'd be happiest if you could tidy up this Q&A such that others could benefit. I've cleaned up the Answer.

Jul 12 '11 at 09:58 PM Waz
(comments are locked)
10|3000 characters needed characters left

No I didn't mess with the html. Connection server is fast. Works flawlessly on IE, firefox and chrome from any pc.

more ▼

answered Jul 01 '11 at 02:57 AM

krivel gravatar image

krivel
-4 1 1 1

(comments are locked)
10|3000 characters needed characters left

Are you using the page as generated by unity or did you toy with the html? Also is the connection to the server fast enough? (the reload fixes it note on firefox implies that it might not run all as round as it would need to)

more ▼

answered Jul 01 '11 at 02:38 AM

Dreamora gravatar image

Dreamora
3.2k 1 4 25

(comments are locked)
10|3000 characters needed characters left
Your answer
toggle preview:

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here

By RSS:

Answers

Answers and Comments

Topics:

x810
x337
x87
x44
x10

asked: Jun 16 '11 at 04:27 PM

Seen: 1026 times

Last Updated: Jul 12 '11 at 10:03 PM