Esempio n. 1
0
        public void AddHighLighter(IHighlightAware highlight)
        {
            HightLightConfig config = highlight.HightLightConfig();

            TMHighlightEffect highlighter = _highlightOverriderGameObject ? _highlightOverriderGameObject.GetComponent <TMHighlightEffect>() : _gameObject.GetComponent <TMHighlightEffect>();

            if (highlighter == null)
            {
                highlighter = _highlightOverriderGameObject ? _highlightOverriderGameObject.AddComponent <TMHighlightEffect>() : _gameObject.AddComponent <TMHighlightEffect>();
            }

            try
            {
                highlighter.SetConfiguration(config);
            }
            catch (Exception e)
            {
                LogManager.GetCurrentClassLogger().Error($"Can not add highlight to game object = {_gameObject}");
            }
        }
Esempio n. 2
0
        private void Init()
        {
            try
            {
                _inputActions.Add(new UseAction(_objectController, _gameObject, _vio));
                _inputActions.Add(new GrabAction(_objectController, _gameObject, _vio));
                _inputActions.Add(new TouchAction(_objectController, _gameObject, _vio));
                _inputActions.Add(new PointerAction(_objectController, _gameObject, _vio));
            }
            catch (Exception e)
            {
                Debug.LogError($"Can't create input actions for {_gameObject.name} Error: {e.Message}");

                return;
            }


            IHighlightAware highlightAware = _gameObject.GetComponent <IHighlightAware>();

            if (Settings.Instance().HighlightEnabled&& highlightAware == null)
            {
                highlightAware = _gameObject.AddComponent <DefaultHightlighter>();
            }

            HighlightOverrider highlightOverrider = _gameObject.GetComponent <HighlightOverrider>();

            if (highlightOverrider != null)
            {
                _highlightOverriderGameObject = highlightOverrider.ObjectToHightlight;
            }

            if (highlightAware != null)
            {
                _highlight = highlightAware;
                AddHighLighter(highlightAware);
            }

            if (Settings.Instance().HighlightEnabled&& IsObjectInteractable())
            {
                EnableHighlight();
            }

            IHapticsAware hapticsAware = _gameObject.GetComponent <IHapticsAware>();

            if (hapticsAware == null &&
                (Settings.Instance().TouchHapticsEnabled ||
                 Settings.Instance().GrabHapticsEnabled ||
                 Settings.Instance().UseHapticsEnabled))
            {
                hapticsAware = _gameObject.AddComponent <DefaultHaptics>();
            }

            if (hapticsAware != null)
            {
                AddHaptics(hapticsAware);
                _haptics = hapticsAware;
            }


            var highlightColor = new Color(255f, 235f, 0f, 255f);

            HightLightConfig config = new HightLightConfig(true,
                                                           0.3f,
                                                           highlightColor,
                                                           false,
                                                           0.2f,
                                                           0.1f,
                                                           0.3f,
                                                           Color.yellow,
                                                           true,
                                                           0f,
                                                           0f,
                                                           Color.red,
                                                           false,
                                                           0f,
                                                           1.0f,
                                                           Color.red);


            _useHighlightConfig = config;
        }
Esempio n. 3
0
        public void Init()
        {
            IUseStartAware useStartAware = _gameObject.GetComponent <IUseStartAware>();

            if (useStartAware != null)
            {
                _useStart = useStartAware;
            }

            IUseEndAware useEndAware = _gameObject.GetComponent <IUseEndAware>();

            if (useEndAware != null)
            {
                _useEnd = useEndAware;
            }

            IGrabStartAware grabStartAware = _gameObject.GetComponent <IGrabStartAware>();

            if (grabStartAware != null)
            {
                _grabStart = grabStartAware;
            }

            IGrabEndAware grabEndAware = _gameObject.GetComponent <IGrabEndAware>();

            if (grabEndAware != null)
            {
                _grabEnd = grabEndAware;
            }

            IGrabPointAware grabPointAware = _gameObject.GetComponent <IGrabPointAware>();

            if (grabPointAware != null)
            {
                _grabPoint = grabPointAware;
            }

            IPointerClickAware pointerClickAware = _gameObject.GetComponent <IPointerClickAware>();

            if (pointerClickAware != null)
            {
                AddPointerBehaviour();
                _pointerClick = pointerClickAware;
            }

            IPointerInAware pointerInAware = _gameObject.GetComponent <IPointerInAware>();

            if (pointerInAware != null)
            {
                AddPointerBehaviour();
                _pointerIn = pointerInAware;
            }

            IPointerOutAware pointerOutAware = _gameObject.GetComponent <IPointerOutAware>();

            if (pointerOutAware != null)
            {
                AddPointerBehaviour();
                _pointerOut = pointerOutAware;
            }

            ITouchStartAware touchStartAware = _gameObject.GetComponent <ITouchStartAware>();

            if (touchStartAware != null)
            {
                _touchStart = touchStartAware;
            }

            ITouchEndAware touchEndAware = _gameObject.GetComponent <ITouchEndAware>();

            if (touchEndAware != null)
            {
                _touchEnd = touchEndAware;
            }

            IHighlightAware highlightAware = _gameObject.GetComponent <IHighlightAware>();

            if (Settings.Instance().HighlightEnabled)
            {
                highlightAware = _gameObject.AddComponent <DefaultHightlighter>();
            }

            HighlightOverrider highlightOverrider = _gameObject.GetComponent <HighlightOverrider>();

            if (highlightOverrider != null)
            {
                _highlightOverriderGameObject = highlightOverrider.ObjectToHightlight;
            }

            if (highlightAware != null)
            {
                _highlight = highlightAware;
                AddHighLighter(highlightAware);
            }

            if (Settings.Instance().HighlightEnabled)
            {
                EnableHighlight();
            }

            IHapticsAware hapticsAware = _gameObject.GetComponent <IHapticsAware>();

            if (hapticsAware == null &&
                (Settings.Instance().TouchHapticsEnabled ||
                 Settings.Instance().GrabHapticsEnabled ||
                 Settings.Instance().UseHapticsEnabled))
            {
                hapticsAware = _gameObject.AddComponent <DefaultHaptics>();
            }

            if (hapticsAware != null)
            {
                AddHaptics(hapticsAware);
                _haptics = hapticsAware;
            }
        }