#How To Dynamically Know Who Sent "Unity Event"? (Event Trigger Component) | Useful For Inventories🎒

1 messages · Page 1 of 1 (latest)

nocturne abyss
#

Hey guys, refactoring my inventory system i want to remove "script machine" from each item slot..

and instead, inventoryManager listens to all the itemSlots. but event trigger only sends unity event.

it doesnt tell "who sent the trigger" so i cant assign the gameObject that triggered the event...

do you have any idea how to get UI mouse events in a single manager, by listening to different event trigger components (item slots) ?

#

How To Dynamically Know Who Sent "Unity Event"? (Event Trigger Component)

#

i see we can add another "action" to this event, but it goes... nowhere uVS can listen?

#

internet mentions we have a direct "trigger custom event" right there in the options, but that is false. we only have these...

sick coral
nocturne abyss
nocturne abyss
#

Im thinking of...

mouse position, raycast detecting only canvas objects. and get that gameObject data. that's what im trying now - but cant find the nodes for this.

sick coral
nocturne abyss
#

This is supposedly made to work... but i cant add a list (raycast results) even if its added in project settings... maybe this is bugged?

I cant declare a variable of this type, doesnt exist and its added there (+ regenerated nodes)

#

Is this a bug?

sick coral
nocturne abyss
#

oh. let me check

sick coral
nocturne abyss
#

oh no. that blue constructor again - ive never managed to make it work lol

sick coral
nocturne abyss
#

but it works!

sick coral
#

You should check the variable though to make sure it does not add the same object multiple times this can cause performance problems I would imagine

nocturne abyss
#

How To Dynamically Know Who Sent "Unity Event"? (Event Trigger Component) | Useful For Inventories🎒

#

**⚠️ How To Select UI Elements with uVS using the New Input System, that uses "Event System".
**
...without "Event Trigger" or "Button" Components...

This allows you to dynamically select elements in your UI from one single manager.

Without custom events and a script machine per UI element - such as Inventory bag slots, weapon slots, potion slots.

Before I had 1 script machine per item slot, and their variations. 15 Item slots, 4 gear slots, 2 potions, and 2 weapons. This gives a total of 23 script machines running in the background even if they wait for input. +23 Calls in the profiler.

Now I'll be able to use 1 single script machine for my entire inventory system. Which is in the process...

Part of my insane refactor process, more details can be found here: #1479879529450307836 - When I finish refactoring my inventory system, I will post updates here.

--
👨‍💻 If anyone in the future needs this.. this is how it's done:

  1. Project Settings >> Visual Scripting >> Add Type Options: [ RaycastResult ]... then, Regenerate Nodes.

  2. Get your Graphic Raycaster component as an Object Variable, the one that is the parent Canvas of the elements you want to detect.

  3. Get Graph variable for raycastResultsList type (List<RaycastResult>) || I tried using Flow variable for this, didn't work. Stick with Graph.

  4. Follow the sequence in the graph.

  5. Set Graph variable for the element you want to select, and make sure it has Bool variable and use nodes "Has Variable" so it doesn't select any object but what you want.