Skip to content
Snippets Groups Projects
Commit edb0739d authored by stendler's avatar stendler
Browse files

advanced debug method

parent 4b82ed96
No related branches found
No related tags found
No related merge requests found
......@@ -17,14 +17,20 @@ public class webCamScript : MonoBehaviour
// may need to situational based on rotation ?
GameObject cameraParent = new GameObject ("camParent");
cameraParent.transform.position = this.transform.position;
this.transform.parent = cameraParent.transform;
_debug("camParent");
cameraParent.transform.position = transform.position;
transform.parent = cameraParent.transform;
if (Application.isMobilePlatform) {
cameraParent.transform.Rotate (Vector3.right, 90);
}
_debug("camParent transformed");
Input.gyro.enabled = true;
_debug("gyro enabled");
_webCameraTexture = new WebCamTexture();
WebCameraPlane.GetComponent<Renderer>().material.mainTexture = _webCameraTexture;
_webCameraTexture.filterMode = FilterMode.Trilinear; // quality >? performance
......@@ -35,12 +41,16 @@ public class webCamScript : MonoBehaviour
// set webCamPanel screen size
PlaneResize();
_debug("Plane resized");
_webCameraTexture.Play();
_debug("camera plays");
}
public void PlaneResize()
{
float distance = Vector3.Distance(this.WebCameraPlane.transform.position, this.transform.position);
float distance = Vector3.Distance(WebCameraPlane.transform.position, transform.position);
_debug(distance);
Vector3 v3ViewPort = new Vector3(0, 0, distance);
Vector3 v3BottomLeft = Camera.main.ViewportToWorldPoint(v3ViewPort);
......@@ -48,7 +58,7 @@ public class webCamScript : MonoBehaviour
Vector3 v3TopRight = Camera.main.ViewportToWorldPoint(v3ViewPort);
_debug(v3BottomLeft);
_debug(v3TopRight);
this.WebCameraPlane.transform.localScale = new Vector3(-v3BottomLeft.x / 4, 1, -v3BottomLeft.y / 4);
WebCameraPlane.transform.localScale = new Vector3(-v3BottomLeft.x / 4, 1, -v3BottomLeft.y / 4);
if(_webCameraTexture != null && _camInitialized)
RecalculateCameraResolution();
......@@ -78,7 +88,7 @@ public class webCamScript : MonoBehaviour
// update rotation per gyro
Quaternion cameraRotation = new Quaternion(Input.gyro.attitude.x, Input.gyro.attitude.y,
-Input.gyro.attitude.z, -Input.gyro.attitude.w);
this.transform.localRotation = cameraRotation;
transform.localRotation = cameraRotation;
}
else
{
......@@ -91,10 +101,17 @@ public class webCamScript : MonoBehaviour
}
}
private void _debug(object message)
private void _debug(object message = null)
{
string msg = message.ToString();
Debug.Log(msg);
this.DebugInfo.GetComponent<Text>().text += msg+"\n";
if (message == null)
message = " - ";
_debug(message.ToString());
}
private void _debug(string message) {
message = "-- "+message;
Debug.Log(message);
DebugInfo.GetComponent<Text>().text += message+"\n";
}
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment