Exemplo 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}");
            }
        }
Exemplo n.º 2
0
        public HightLightConfig HightLightConfig()
        {
            var defColor = new Color(0f, 255f, 255f, 255f);

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

            return(config);
        }
Exemplo n.º 3
0
        public void InitializeController(InputController inputController = null)
        {
            _inputController = inputController;

            if (_inputController != null)
            {
                _defaultHighlightConfig = _inputController.DefaultHighlightConfig;
            }
            else
            {
                var defHighlighter = gameObject.AddComponent <DefaultHightlighter>();
                _defaultHighlightConfig = defHighlighter.HightLightConfig();
            }

            _highlight = gameObject.GetComponent <VarwinHighlightEffect>();

            if (_highlight == null)
            {
                _highlight = gameObject.AddComponent <VarwinHighlightEffect>();
            }


            HightLightConfig config = new HightLightConfig(true,
                                                           0.3f,
                                                           Color.red,
                                                           false,
                                                           0.2f,
                                                           0.1f,
                                                           0.3f,
                                                           Color.red,
                                                           false,
                                                           0.8f,
                                                           0.5f,
                                                           Color.red,
                                                           true,
                                                           0.5f,
                                                           1.0f,
                                                           Color.red);


            _collisionControllerHighlightConfig = config;

            _highlight.SetConfiguration(_collisionControllerHighlightConfig);

            _tempColliders  = new List <CollisionControllerElement>();
            _childColliders = new List <Collider>();

            List <GameObject> objectsWithColliders = new List <GameObject>();

            Collider[] children = GetComponentsInChildren <Collider>();

            foreach (Collider child in children)
            {
                if (!child.isTrigger && child.enabled)
                {
                    _childColliders.Add(child);

                    if (!objectsWithColliders.Contains(child.gameObject))
                    {
                        objectsWithColliders.Add(child.gameObject);
                    }
                }
            }

            foreach (GameObject objectWithCollider in objectsWithColliders)
            {
                CollisionControllerElement triggerObject = CreateTriggersColliders(objectWithCollider);
                triggerObject.OnCollisionEnterDelegate += OnCollide;
                triggerObject.OnTriggerExitDelegate    += OnColliderExit;
                _tempColliders.Add(triggerObject);
            }

            ProjectData.GameModeChanged += GameModeChanged;
        }
Exemplo n.º 4
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;
        }