Advertisement
LittleAngel

OverGUI

Oct 19th, 2011
85
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.24 KB | None | 0 0
  1. public class Viewer : MonoBehaviour {
  2. private Rect sliderRect;
  3.  
  4. void Awake () {
  5. sliderRect = new Rect((Screen.width/2) - 100, 25, 200, 75);
  6. }
  7.  
  8. void OnGUI () {
  9. GUILayout.BeginArea (sliderRect);
  10. GUILayout.BeginHorizontal ();
  11. GUILayout.Label ("0", GUILayout.MaxWidth(10));
  12. keyLightStrength = GUILayout.HorizontalSlider (keyLightStrength, 0.0f, 1.0f);
  13. GUILayout.Label ("1", GUILayout.MaxWidth(10));
  14. keyLight.intensity = keyLightStrength;
  15. GUILayout.EndHorizontal ();
  16. GUILayout.Label ("Key Light Intensity: " + keyLight.intensity);
  17. GUILayout.EndArea ();
  18. }
  19.  
  20. void Update () {
  21. // if (Input.GetMouseButton(0) && sliderRect.Contains (Input.mousePosition)) {
  22. // Debug.Log ("Over GUI");
  23. // } else {
  24. // Debug.Log ("NOT Over GUI");
  25.  
  26. if (Input.GetMouseButtonDown(0)) {
  27. previousMousePos = Input.mousePosition;
  28. } else {
  29. deltaPos = Vector3.zero;
  30. }
  31.  
  32. if (Input.GetMouseButton(0)) {
  33. deltaPos = Input.mousePosition - previousMousePos;
  34. previousMousePos = Input.mousePosition;
  35. Vector3 newRotation = Vector3.zero;
  36. newRotation.x = -deltaPos.y * sensitivity;
  37. newRotation.y = -deltaPos.x * sensitivity;
  38. thisTransform.Rotate (newRotation, Space.World);
  39. }
  40. // }
  41. }
  42. }
  43.  
  44.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement