Noticias

¡RECUERDA QUE SI ERES UN NUEVO USUARIO, DEBES PRESENTARTE PARA PODER PUBLICAR MENSAJES! | TENEMOS CANAL OFICIAL DE TELEGRAM: t.me/unity3dspain

Problema con las funciones mousedrag/Over/down...

Iniciado por Gastonspas, Octubre 08, 2018, 09:02:50 PM

Tema anterior - Siguiente tema
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
 
 
 
Si alguien sabe como solucionarlo se lo agradeceria

Si buscas en el manual:
 
https://docs.unity3d.com/ScriptReference/MonoBehaviour.OnMouseEnter.html
 
Dice en la primer oración: "Called when the mouse enters the GUIElement or Collider."
 
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.

Etiquetas: