| 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980 | 
							- using UnityEngine;
 
- using System.Collections;
 
- public class SC_shakeCamera : MonoBehaviour
 
- {
 
-     private float shakeTime = 0.0f;
 
-     private float fps = 60.0f;
 
-     private float frameTime = 0.0f;
 
-     private float shakeDelta = 0.002f;
 
-     public Camera cam;
 
-     public static bool isshakeCamera = false;
 
- 	public static float shakeINT = 2;
 
-     // Use this for initialization
 
-     void Start()
 
-     {
 
-         shakeTime = 0.1f;
 
-         fps = 60.0f;
 
-         frameTime = 0.01f;
 
-         shakeDelta = 0.002f;
 
-         //cam = GameObject.FindGameObjectWithTag ("MainCamera").GetComponent<Camera> ();
 
-         cam = gameObject.GetComponent<Camera>();
 
-     }
 
-     private void OnEnable()
 
-     {
 
-     }
 
-     private void OnDisable()
 
-     {
 
-         if (cam == null )
 
-         {
 
-             cam = gameObject.GetComponent<Camera>();
 
-         }
 
-         cam.rect = new Rect(0.0f, 0.0f, 1.0f, 1.0f);
 
-     }
 
-     // Update is called once per frame
 
-     void Update()
 
-     {
 
-         if (isshakeCamera)
 
-         {
 
-             if (shakeTime > 0)
 
-             {
 
-                 shakeTime -= Time.deltaTime;
 
-                 if (shakeTime <= 0)
 
-                 {
 
-                     cam.rect = new Rect(0.0f, 0.0f, 1.0f, 1.0f);
 
-                     isshakeCamera = false;
 
-                     shakeTime = 0.1f;
 
-                     fps = 60.0f;
 
-                     frameTime = 0.01f;
 
-                     shakeDelta = 0.002f;
 
-                 }
 
-                 else
 
-                 {
 
-                     frameTime += Time.deltaTime;
 
-                     if (frameTime > 2.0 / fps)
 
-                     {
 
-                         frameTime = 0;
 
- 						cam.rect = new Rect(shakeDelta * (-1.0f + shakeINT * Random.value), shakeDelta * (-1.0f + shakeINT * Random.value), 1.0f, 1.0f);
 
-                     }
 
-                 }
 
-             }
 
-         }
 
-         //else if (Input.GetMouseButtonDown(0))
 
-         //{
 
-         //    shakeCamera();
 
-         //}
 
-     }
 
-     public static void shakeCamera(float shakeInt)
 
-     {
 
- 		shakeINT = shakeInt;
 
- 		isshakeCamera = true;
 
-     }
 
- }
 
 
  |