57 lines
		
	
	
		
			998 B
		
	
	
	
		
			C#
		
	
	
	
		
		
			
		
	
	
			57 lines
		
	
	
		
			998 B
		
	
	
	
		
			C#
		
	
	
	
|  | using System.Collections; | |||
|  | using System.Collections.Generic; | |||
|  | using UnityEngine; | |||
|  | 
 | |||
|  | public class VibrateManager | |||
|  | { | |||
|  |     private static VibrateManager mInstance; | |||
|  |     public static VibrateManager Instance | |||
|  |     { | |||
|  |         get | |||
|  |         { | |||
|  |             if (mInstance == null) | |||
|  |             { | |||
|  |                 mInstance = new VibrateManager(); | |||
|  |             } | |||
|  | 
 | |||
|  |             return mInstance; | |||
|  |         } | |||
|  |     } | |||
|  | 
 | |||
|  |     private VibrateManager() | |||
|  |     { | |||
|  | 
 | |||
|  |     } | |||
|  | 
 | |||
|  |     private bool mIsVibrateOn = true; | |||
|  | 
 | |||
|  |     public void SetVibrateOn(bool pIsOn) | |||
|  |     { | |||
|  |         mIsVibrateOn = pIsOn; | |||
|  |     } | |||
|  | 
 | |||
|  |     public void Vibrate(VibrateType pType, float pIntensity = 1) | |||
|  |     { | |||
|  |         if (mIsVibrateOn) | |||
|  |         { | |||
|  |             //Debug.Log("Vibrate : " + pType); | |||
|  |             NativeTool.Shake((int)pType, pIntensity); | |||
|  |         } | |||
|  |     } | |||
|  | 
 | |||
|  |     public void Shake() | |||
|  |     { | |||
|  |         if (mIsVibrateOn) | |||
|  |         { | |||
|  |             //Debug.Log("Shake!!!"); | |||
|  |             Handheld.Vibrate(); | |||
|  |         } | |||
|  |     } | |||
|  | } | |||
|  | 
 | |||
|  | public enum VibrateType | |||
|  | { | |||
|  |     Light = 0, | |||
|  |     Medium, | |||
|  |     Heavy | |||
|  | } |