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?
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?
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?
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.mousePosition);
} 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);
}
Problem solved in case anyone is curious. Some of the code referencing screen height/width wasn’t jiving with mac and safari for some reason. Working now.