示例#1
0
文件: Demo.cs 项目: bambong/template
        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);
        }
示例#2
0
    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;
        }
    }
示例#3
0
文件: Demo.cs 项目: bambong/template
 void PlayHapticsFromAHAP()
 {
     Debug.Log("Playing AHAP");
     UnityCoreHapticsProxy.PlayHapticsFromFile(ahapRelativePath);
 }
示例#4
0
文件: Demo.cs 项目: bambong/template
 void PlayContinuousHaptics()
 {
     Debug.Log("Playing continuous!");
     UnityCoreHapticsProxy.PlayContinuousHaptics(1f, 0.2f, 1f);
 }
示例#5
0
文件: Demo.cs 项目: bambong/template
 void PlayTransientHaptics()
 {
     Debug.Log("Playing transient!");
     UnityCoreHapticsProxy.PlayTransientHaptics(1f, 1f);
 }
示例#6
0
 public void PlayContinuousHaptics()
 {
     UnityCoreHapticsProxy.PlayContinuousHaptics(intensity, sharpness, duration);
 }
示例#7
0
 public void PlayTransientHaptics()
 {
     UnityCoreHapticsProxy.PlayTransientHaptics(intensity, sharpness);
 }