for some reason i can’t get on mouse drag to work with GUI elements.
i have a dimple dragg script
using UnityEngine;
using System.Collections;
using UnityEngine.UI;
public class DraggScript : MonoBehaviour {
// userInputSimple user;
[SerializeField] Vector2 startPoint;
[SerializeField] Vector2 endPoint;
[SerializeField] bool drag;
void OnMouseDrag()
{
drag = true;
// user.dragging(false);
endPoint = Input.mousePosition;
// rend.material.color -= Color.white * Time.deltaTime;
}
void OnMouseUp() {
user.dragging(true);
drag =false;
}
void OnMouseDown() {
if(!drag){
startPoint = Input.mousePosition;
}
}
}
i should be able drop it on any guielement and it should work but onMouseDragg is never called
on gui elements.
if you right-click in the scene hierarchy create new panel and drag this script onto the panel it should work?
-by default it wont be in the ignore raycast layer it is in the UI layer.
-panels are gui elements i tried with buttons still did not work.
if i toss it on a plane then attach it to the camera it works
but for some reason it does not work for GUIelements
even though in the documentation clearly states “This event is sent to all scripts attached to the Collider or GUIElement.”
i am Missing something i dont know what it is.