Unity Spain
Post Antiguos => General (Antiguo) => Mensaje iniciado por: Gastonspas en Octubre 08, 2018, 09:02:50 PM
Hola muy buenas a todos tengo un pequeño problema con las funciones del mouse y nose por que no anda
codigo
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class inv_prin : MonoBehaviour {
public int id_objecto;
public int cantidad;
public int slot;
// Use this for initialization
void Start () {
//Debug.Log("Slot: " + slot);
}
// Update is called once per frame
void Update () {
}
void OnMouseDown()
{
Debug.Log("Test!");
}
void OnMouseUp()
{
Debug.Log("Test!");
}
void OnMouseOver()
{
Debug.Log("Test!");
}
void OnMouseDrag()
{
Debug.Log("Test!");
}
}
Video:
http://www.gastontutorialeshd.xyz/fastdll/unity_fail.mp4 (http://www.gastontutorialeshd.xyz/fastdll/unity_fail.mp4)
Si alguien sabe como solucionarlo se lo agradeceria
Si buscas en el manual:
https://docs.unity3d.com/ScriptReference/MonoBehaviour.OnMouseEnter.html (https://docs.unity3d.com/ScriptReference/MonoBehaviour.OnMouseEnter.html)
Dice en la primer oración: "Called when the mouse enters the GUIElement (https://docs.unity3d.com/ScriptReference/GUIElement.html) or Collider (https://docs.unity3d.com/ScriptReference/Collider.html)."
En tu escena no tenés ningun GUIElement ni Collider, tenés un Collider2D.
Podrías ponerle un BoxCollider y listo, pero igual, si vas a usar elementos UI no uses esos mensajes del monobehaviour, usá el mismo Event System que ya Unity te dá para hacer ese tipo de cosas, tenés los mismos mensajes casi en versión de eventos.