using UnityEngine;
using UnityEngine.UI;
public class SFB_DemoControl_v2 : MonoBehaviour {
public GameObject cameraObject; // The camera object
public float mouseSensitivityY = -0.005f;
public float mouseSensitivityX = 0.01f;
private Vector2 lastMousePosition;
public Slider heightBar;
///
/// Simply sets the .y value of the camera transform
///
/// New value.
public void SetCameraHeight(float newValue)
{
//Debug.Log("Old:" + cameraObject.transform.localPosition);
Vector3 newPosition = new Vector3(cameraObject.transform.localPosition.x, newValue, cameraObject.transform.localPosition.z);
cameraObject.transform.localPosition = newPosition; // Set the position
//Debug.Log("New: " + cameraObject.transform.localPosition);
}
///
/// Simply sets the timescale
///
/// New value.
public void SetTimescale(float newValue){
Time.timeScale = newValue; // Set the value
}
private void FixedUpdate()
{
if (Input.GetMouseButtonDown(1))
{
lastMousePosition = Input.mousePosition;
}
if (Input.GetMouseButton(1))
{
//Debug.Log("Value 1: " + heightBar.value);
heightBar.value += (Input.mousePosition.y - lastMousePosition.y) * mouseSensitivityY;
lastMousePosition = Input.mousePosition;
//Debug.Log("Value 2: " + heightBar.value);
}
}
}