Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public class Viewer : MonoBehaviour {
- private Rect sliderRect;
- void Awake () {
- sliderRect = new Rect((Screen.width/2) - 100, 25, 200, 75);
- }
- void OnGUI () {
- GUILayout.BeginArea (sliderRect);
- GUILayout.BeginHorizontal ();
- GUILayout.Label ("0", GUILayout.MaxWidth(10));
- keyLightStrength = GUILayout.HorizontalSlider (keyLightStrength, 0.0f, 1.0f);
- GUILayout.Label ("1", GUILayout.MaxWidth(10));
- keyLight.intensity = keyLightStrength;
- GUILayout.EndHorizontal ();
- GUILayout.Label ("Key Light Intensity: " + keyLight.intensity);
- GUILayout.EndArea ();
- }
- void Update () {
- if (Input.GetMouseButton(0) && sliderRect.Contains (Input.mousePosition)) {
- Debug.Log ("Over GUI");
- } else {
- Debug.Log ("NOT Over GUI");
- if (Input.GetMouseButtonDown(0)) {
- previousMousePos = Input.mousePosition;
- } else {
- deltaPos = Vector3.zero;
- }
- if (Input.GetMouseButton(0)) {
- deltaPos = Input.mousePosition - previousMousePos;
- previousMousePos = Input.mousePosition;
- Vector3 newRotation = Vector3.zero;
- newRotation.x = -deltaPos.y * sensitivity;
- newRotation.y = -deltaPos.x * sensitivity;
- thisTransform.Rotate (newRotation, Space.World);
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement