예제 #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;
        }
    }