void Awake()
        {
            if (dontDestroyOnLoad)
            {
                if (_manager == null)
                {
                    DontDestroyOnLoad(gameObject);
                }
                else
                {
                    Destroy(gameObject);
                    return;
                }
            }

            var uninstalledMessage = "bHaptics Player is not installed. Plugin is now disabled. Please download here." +
                                     "\nhttp://bhaptics.com/app.html#download";

            _manager = this;
            if (!BhapticsUtils.IsPlayerInstalled())
            {
                Debug.LogError(uninstalledMessage);
                return;
            }

            if (!BhapticsUtils.IsPlayerRunning())
            {
                Debug.Log("bHaptics Player is not running, try launching bHaptics Player.");
                BhapticsUtils.LaunchPlayer(launchPlayerIfNotRunning);
            }
        }
Beispiel #2
0
        void Update()
        {
            if (!visualizeFeedback)
            {
                return;
            }

            if (!BhapticsUtils.IsPlayerInstalled())
            {
                return;
            }

            if (Application.platform == RuntimePlatform.Android)
            {
                if (!Monitor.TryEnter(_changedFeedback))
                {
                    Debug.Log("failed to enter");
                    return;
                }
                try
                {
                    foreach (var feedback in _changedFeedback)
                    {
                        foreach (var vis in visualFeedback)
                        {
                            if (vis.Position == feedback.Position)
                            {
                                vis.UpdateFeedback(feedback);
                            }
                        }
                    }
                    _changedFeedback.Clear();
                }
                finally
                {
                    Monitor.Exit(_changedFeedback);
                }
            }
            else
            {
                foreach (var vis in visualFeedback)
                {
                    HapticApi.status status;
                    HapticApi.TryGetResponseForPosition(vis.Position, out status);

                    byte[] result = new byte[20];
                    for (int i = 0; i < result.Length; i++)
                    {
                        result[i] = (byte)status.values[i];
                    }

                    HapticFeedback feedback = new HapticFeedback(vis.Position, result);
                    vis.UpdateFeedback(feedback);
                }
            }
        }
Beispiel #3
0
 void OnDisable()
 {
     if (!BhapticsUtils.IsPlayerInstalled())
     {
         return;
     }
     HapticPlayer.TurnOff();
     HapticPlayer.Disable();
     HapticPlayer.StatusReceived -= OnStatusChanged;
 }
Beispiel #4
0
        void OnEnable()
        {
            if (!BhapticsUtils.IsPlayerInstalled())
            {
                gameObject.SetActive(false);
                return;
            }

            InitVisualFeedback();

            HapticPlayer.StatusReceived += OnStatusChanged;
            HapticPlayer.Enable();

            LoadFeedbackFile();
        }
Beispiel #5
0
        void Update()
        {
            if (!visualizeFeedbacks)
            {
                return;
            }

            if (!BhapticsUtils.IsPlayerInstalled())
            {
                return;
            }

            if (_changedFeedbacks.Count <= 0)
            {
                return;
            }

            if (!Monitor.TryEnter(_changedFeedbacks))
            {
                Debug.Log("failed to enter");
                return;
            }
            try
            {
                foreach (var feedback in _changedFeedbacks)
                {
                    foreach (var vis in visualFeedbacks)
                    {
                        if (vis.Position == feedback.Position)
                        {
                            vis.UpdateFeedbacks(feedback);
                        }
                    }
                }
                _changedFeedbacks.Clear();
            }
            finally
            {
                Monitor.Exit(_changedFeedbacks);
            }
        }
Beispiel #6
0
        void Awake()
        {
            if (dontDestroyOnLoad)
            {
                if (Instance == null)
                {
                    DontDestroyOnLoad(gameObject);
                }
                else
                {
                    Destroy(gameObject);
                    return;
                }
            }

            var uninstalledMessage = "bHaptics Player is not installed. Plugin is now disabled. Please download here." +
                                     "\nhttp://bhaptics.com/app.html#download";

            Instance = this;
            if (!BhapticsUtils.IsPlayerInstalled())
            {
                Debug.LogError(uninstalledMessage);
                return;
            }

            if (!BhapticsUtils.IsPlayerRunning())
            {
                Debug.Log("bHaptics Player is not running, try launching bHaptics Player.");
                BhapticsUtils.LaunchPlayer(launchPlayerIfNotRunning);
            }

            if (Application.platform == RuntimePlatform.Android && BhapticsAndroidManager.Instance == null)
            {
                var bhapticsAndroidManager = Instantiate(bHapticsAndroidManagerPrefab, Vector3.zero, Quaternion.identity);
                bhapticsAndroidManager.name             = "[bHapticsAndroidManager]";
                bhapticsAndroidManager.transform.parent = transform;
            }
        }
Beispiel #7
0
        void Awake()
        {
            var uninstalledMessage = "bHaptics Player is not installed. Plugin is now disabled. Please download here." +
                                     "\nhttp://bhaptics.com/app.html#download";

            _manager = this;
            if (!BhapticsUtils.IsPlayerInstalled())
            {
                Debug.LogError(uninstalledMessage);
                return;
            }

            if (!BhapticsUtils.IsPlayerRunning())
            {
                Debug.Log("bHaptics Player is not running, try launching bHaptics Player.");
                BhapticsUtils.LaunchPlayer(launchPlayerIfNotRunning);
            }

            if (Application.platform == RuntimePlatform.Android)
            {
                Invoke("AndroidStopScan", 3f);
            }
        }