Created
June 21, 2018 21:21
-
-
Save Drenerdo/e0ec81378898110287243dfa0bfebad9 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System.Collections; | |
using System.Collections.Generic; | |
using UnityEngine; | |
public class NonUIInteraction : MonoBehaviour { | |
public UnityEngine.UI.Text outText; | |
protected Material oldHoverMat; | |
public Material yellowMat; | |
public void OnHoverEnter(Transform t) { | |
if (outText != null) { | |
oldHoverMat = t.gameObject.GetComponent<Renderer>().material; | |
t.gameObject.GetComponent<Renderer>().material = yellowMat; | |
outText.text ="hovering over: " + t.gameObject.name; | |
} | |
} | |
public void OnHoverExit(Transform t) { | |
if (outText != null) { | |
t.gameObject.GetComponent<Renderer>().material = oldHoverMat; | |
outText.text = "end over: " + t.gameObject.name; | |
} | |
} | |
public void OnSelected(Transform t) { | |
if (outText != null) { | |
outText.text = "clicked on: " + t.gameObject.name; | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment