SphereHighlightEventExample.cs 822 B

12345678910111213141516171819202122232425262728293031323334353637383940
  1. using UnityEngine;
  2. using HighlightPlus;
  3. namespace HighlightPlus.Demos {
  4. public class SphereHighlightEventExample : MonoBehaviour {
  5. HighlightEffect effect;
  6. void Start() {
  7. effect = GetComponent<HighlightEffect> ();
  8. effect.OnObjectHighlightStart += ValidateHighlightObject;
  9. }
  10. bool ValidateHighlightObject(GameObject obj) {
  11. // You can return false to cancel highlight on this object
  12. return true;
  13. }
  14. void HighlightStart () {
  15. Debug.Log ("Gold sphere highlighted!");
  16. }
  17. void HighlightEnd () {
  18. Debug.Log ("Gold sphere not highlighted!");
  19. }
  20. void Update() {
  21. if (InputProxy.GetKeyDown ("space")) {
  22. effect.HitFX (Color.white, 0.2f);
  23. }
  24. if (InputProxy.GetKeyDown("c")) {
  25. effect.SetGlowColor(new Color(Random.value, Random.value, Random.value));
  26. }
  27. }
  28. }
  29. }