// Update is called once per frame void Update() { GetComponent <Text>().text = ""; if (player.GetInteractableObj() != null && GameObject.FindWithTag("Player").GetComponent <FirstPersonController>() != null) { if (player.GetInteractableObj().enabled) { GetComponent <Text>().text = "Press 'E': " + player.GetInteractableObj().message; } } }
// Update is called once per frame void Update() { FirstPersonController player = GameObject.FindWithTag("Player").GetComponent <FirstPersonController>(); Interactable obj = player.GetInteractableObj(); if (this == obj) { isSelected = true; if (!isChanging) { isChanging = true; } _targetColor = GlowColor; } else { isSelected = false; _targetColor = Color.black; if (!isChanging) { isChanging = true; } } if (isSelected) { if (Input.GetKeyUp(KeyCode.E)) { onUp.Invoke(); } if (Input.GetKey(KeyCode.E)) { onHold.Invoke(); } if (Input.GetKeyDown(KeyCode.E)) { onDown.Invoke(); } } if (isChanging) { _currentColor = Color.Lerp(_currentColor, _targetColor, Time.deltaTime * LerpFactor); for (int i = 0; i < _materials.Count; i++) { _materials[i].SetColor("_GlowColor", _currentColor); } if (_currentColor.Equals(_targetColor)) { isChanging = false; } } }