void Start() { // Set to portrait mode Screen.orientation = ScreenOrientation.Portrait; // Indicate whether the device supports Core Haptics or not DeviceSupported.text = "Device supported: " + UnityCoreHapticsProxy.SupportsCoreHaptics(); // Check if relative path to AHAP is correct // Note: this demo won't play AHAP files in its current state // You must import an AHAP into Assets/StreamingAssets and ahapRelativePath to it // Please see README.pdf for more details if (ahapRelativePath != null && ahapRelativePath != "") { Utility.AssertFileExists(ahapRelativePath); } // Create haptic engine before using it to play haptics UnityCoreHapticsProxy.CreateEngine(); // Set up callbacks UnityCoreHapticsProxy.OnEngineCreated += () => { Debug.Log("Unity: ENGINE CREATED"); }; UnityCoreHapticsProxy.OnEngineError += () => { Debug.LogError("Unity: ENGINE ERROR"); }; // Listen to click events PlayTransient.onClick.AddListener(PlayTransientHaptics); PlayContinuous.onClick.AddListener(PlayContinuousHaptics); PlayCustomAHAP.onClick.AddListener(PlayHapticsFromAHAP); }
void Start() { // Create haptic engine before using it to play haptics // this should only be called one tine UnityCoreHapticsProxy.CreateEngine(); if (!createdEngineOnStart) { UnityCoreHapticsProxy.CreateEngine(); createdEngineOnStart = true; } }
void PlayHapticsFromAHAP() { Debug.Log("Playing AHAP"); UnityCoreHapticsProxy.PlayHapticsFromFile(ahapRelativePath); }
void PlayContinuousHaptics() { Debug.Log("Playing continuous!"); UnityCoreHapticsProxy.PlayContinuousHaptics(1f, 0.2f, 1f); }
void PlayTransientHaptics() { Debug.Log("Playing transient!"); UnityCoreHapticsProxy.PlayTransientHaptics(1f, 1f); }
public void PlayContinuousHaptics() { UnityCoreHapticsProxy.PlayContinuousHaptics(intensity, sharpness, duration); }
public void PlayTransientHaptics() { UnityCoreHapticsProxy.PlayTransientHaptics(intensity, sharpness); }