I’ve tried everything, read all docs, and questions/answers i could find, Tried using those methods, Still didnt work at all.
I tried ‘OnMouseEnter’ and ‘onMouseEnter’ same thing for the OnMouseExit, Still doesnt work.
Edit: My objects have BoxColliders on them, along with rigidbody.
I get no errors. Only problem is ‘OnMouseEnter();’
Code[Unity 5] (C# Because I don’t like using JS):
using UnityEngine;
using System.Collections;
using UnityEngine.UI;
public class PickupItem : MonoBehaviour {
public Text text;
public string itemname;
public string hoverMessage;
public string pickupMessage;
public bool mouseHover;
public int itemID;
public Inventory inv;
public GameDB invAdd;
public bool[] items;
public int itemAmount;
public bool pickedupItem;
private float texttime;
public float textTime;
void Start () {
texttime = textTime;
inv = GameObject.FindObjectOfType<Inventory> ();
invAdd = GameObject.FindObjectOfType<GameDB> ();
text = GameObject.Find ("ItemPickupText").GetComponent<Text>();
}
void Update () {
if (pickedupItem) {
text.text = "" + pickupMessage + " [" + itemname + " x" + itemAmount + "]";
texttime -= Time.deltaTime;
if (texttime <= 0) {
texttime = textTime;
text.text = "";
pickedupItem = false;
}
}
if (!mouseHover) {
text.text = "";
}
if (mouseHover) {
if (Input.GetMouseButton (0)) {
this.gameObject.transform.position = Input.mousePosition;
}
}
}
//Backup if Event Trigger Doesnt work
public void OnMouseEnter(){
Hover (true);
}
public void OnMouseExit(){
Hover (false);
}
public void Hover(bool h){
mouseHover = h;
if (mouseHover) {
text.text = "" + hoverMessage + " [" + itemname + " x" + itemAmount + "]";
if (Input.GetKeyDown (KeyCode.E)) {
if (items [0] = true) {
invAdd.AddWaterBottle (itemAmount);
pickedupItem = true;
}
if (items [1] = true) {
invAdd.AddChocolateBar (itemAmount);
pickedupItem = true;
}
if (items [2] = true) {
invAdd.AddCannedBeans (itemAmount);
pickedupItem = true;
}
if (items [3] = true) {
invAdd.AddGauze (itemAmount);
pickedupItem = true;
}
if (items [4] = true) {
invAdd.AddAxe (itemAmount);
pickedupItem = true;
}
}
}
}
}