Bug in Unity UI OnEndDrag - pointerCurrentRaycast?
i try to determine which object is under my dragged object when OnEndDrag is called. I guess, for this reason pointerCurrentRaycast is in the PointerEventData.
For example a simple inventory system:
The power item has a simple script component with the IEndDragHandler implementation.... When i drag the item from cell1 over cell2 and the OnEndDrag event is called, there is is cell2.GO in the pointerCurrentRaycast Field of the event data...
But, when i drag a item upwards in the hierarchy, in this example from cell1 in cell0, the item itself is in the pointerCurrentRaycast Field,...
any idea?
//remarks
i know that other ways exist to determine which object is under the pointer but i try to understand this strange OnEndDrag behavior.
unity3d
add a comment |
i try to determine which object is under my dragged object when OnEndDrag is called. I guess, for this reason pointerCurrentRaycast is in the PointerEventData.
For example a simple inventory system:
The power item has a simple script component with the IEndDragHandler implementation.... When i drag the item from cell1 over cell2 and the OnEndDrag event is called, there is is cell2.GO in the pointerCurrentRaycast Field of the event data...
But, when i drag a item upwards in the hierarchy, in this example from cell1 in cell0, the item itself is in the pointerCurrentRaycast Field,...
any idea?
//remarks
i know that other ways exist to determine which object is under the pointer but i try to understand this strange OnEndDrag behavior.
unity3d
This has to deal with your hierchy, the raycast returns the closest object. In the case of going over cell2, cell2 is later in the hierchy then your power therefore in that case cell2 is closer to your pointer then the powerUp, in the circumstance you go over cell0, cell1 is closer then cell0, and your Power is under Cell1 thus making him closer then Cell1, when the raycast is hit over cell0, your order from furthest to closest since you are draggingpower
is cell0, Power.
– Eddge
Nov 28 '18 at 13:34
If on DragDown you made Power the first child element of Inventory, then all of your cells would be considered closer then Power.
– Eddge
Nov 28 '18 at 13:35
huhu, @Eddge thanks for the plausible and good answer :)
– wild_card
Nov 28 '18 at 15:10
add a comment |
i try to determine which object is under my dragged object when OnEndDrag is called. I guess, for this reason pointerCurrentRaycast is in the PointerEventData.
For example a simple inventory system:
The power item has a simple script component with the IEndDragHandler implementation.... When i drag the item from cell1 over cell2 and the OnEndDrag event is called, there is is cell2.GO in the pointerCurrentRaycast Field of the event data...
But, when i drag a item upwards in the hierarchy, in this example from cell1 in cell0, the item itself is in the pointerCurrentRaycast Field,...
any idea?
//remarks
i know that other ways exist to determine which object is under the pointer but i try to understand this strange OnEndDrag behavior.
unity3d
i try to determine which object is under my dragged object when OnEndDrag is called. I guess, for this reason pointerCurrentRaycast is in the PointerEventData.
For example a simple inventory system:
The power item has a simple script component with the IEndDragHandler implementation.... When i drag the item from cell1 over cell2 and the OnEndDrag event is called, there is is cell2.GO in the pointerCurrentRaycast Field of the event data...
But, when i drag a item upwards in the hierarchy, in this example from cell1 in cell0, the item itself is in the pointerCurrentRaycast Field,...
any idea?
//remarks
i know that other ways exist to determine which object is under the pointer but i try to understand this strange OnEndDrag behavior.
unity3d
unity3d
asked Nov 28 '18 at 10:29
wild_cardwild_card
144
144
This has to deal with your hierchy, the raycast returns the closest object. In the case of going over cell2, cell2 is later in the hierchy then your power therefore in that case cell2 is closer to your pointer then the powerUp, in the circumstance you go over cell0, cell1 is closer then cell0, and your Power is under Cell1 thus making him closer then Cell1, when the raycast is hit over cell0, your order from furthest to closest since you are draggingpower
is cell0, Power.
– Eddge
Nov 28 '18 at 13:34
If on DragDown you made Power the first child element of Inventory, then all of your cells would be considered closer then Power.
– Eddge
Nov 28 '18 at 13:35
huhu, @Eddge thanks for the plausible and good answer :)
– wild_card
Nov 28 '18 at 15:10
add a comment |
This has to deal with your hierchy, the raycast returns the closest object. In the case of going over cell2, cell2 is later in the hierchy then your power therefore in that case cell2 is closer to your pointer then the powerUp, in the circumstance you go over cell0, cell1 is closer then cell0, and your Power is under Cell1 thus making him closer then Cell1, when the raycast is hit over cell0, your order from furthest to closest since you are draggingpower
is cell0, Power.
– Eddge
Nov 28 '18 at 13:34
If on DragDown you made Power the first child element of Inventory, then all of your cells would be considered closer then Power.
– Eddge
Nov 28 '18 at 13:35
huhu, @Eddge thanks for the plausible and good answer :)
– wild_card
Nov 28 '18 at 15:10
This has to deal with your hierchy, the raycast returns the closest object. In the case of going over cell2, cell2 is later in the hierchy then your power therefore in that case cell2 is closer to your pointer then the powerUp, in the circumstance you go over cell0, cell1 is closer then cell0, and your Power is under Cell1 thus making him closer then Cell1, when the raycast is hit over cell0, your order from furthest to closest since you are dragging
power
is cell0, Power.– Eddge
Nov 28 '18 at 13:34
This has to deal with your hierchy, the raycast returns the closest object. In the case of going over cell2, cell2 is later in the hierchy then your power therefore in that case cell2 is closer to your pointer then the powerUp, in the circumstance you go over cell0, cell1 is closer then cell0, and your Power is under Cell1 thus making him closer then Cell1, when the raycast is hit over cell0, your order from furthest to closest since you are dragging
power
is cell0, Power.– Eddge
Nov 28 '18 at 13:34
If on DragDown you made Power the first child element of Inventory, then all of your cells would be considered closer then Power.
– Eddge
Nov 28 '18 at 13:35
If on DragDown you made Power the first child element of Inventory, then all of your cells would be considered closer then Power.
– Eddge
Nov 28 '18 at 13:35
huhu, @Eddge thanks for the plausible and good answer :)
– wild_card
Nov 28 '18 at 15:10
huhu, @Eddge thanks for the plausible and good answer :)
– wild_card
Nov 28 '18 at 15:10
add a comment |
0
active
oldest
votes
Your Answer
StackExchange.ifUsing("editor", function () {
StackExchange.using("externalEditor", function () {
StackExchange.using("snippets", function () {
StackExchange.snippets.init();
});
});
}, "code-snippets");
StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "1"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});
function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});
}
});
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53517304%2fbug-in-unity-ui-onenddrag-pointercurrentraycast%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
0
active
oldest
votes
0
active
oldest
votes
active
oldest
votes
active
oldest
votes
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53517304%2fbug-in-unity-ui-onenddrag-pointercurrentraycast%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
This has to deal with your hierchy, the raycast returns the closest object. In the case of going over cell2, cell2 is later in the hierchy then your power therefore in that case cell2 is closer to your pointer then the powerUp, in the circumstance you go over cell0, cell1 is closer then cell0, and your Power is under Cell1 thus making him closer then Cell1, when the raycast is hit over cell0, your order from furthest to closest since you are dragging
power
is cell0, Power.– Eddge
Nov 28 '18 at 13:34
If on DragDown you made Power the first child element of Inventory, then all of your cells would be considered closer then Power.
– Eddge
Nov 28 '18 at 13:35
huhu, @Eddge thanks for the plausible and good answer :)
– wild_card
Nov 28 '18 at 15:10