ๆญฃๅœจๅŠ ่ฝฝ่ง†้ข‘...

่ง†้ข‘ๅŠ ่ฝฝๅคฑ่ดฅ

Reusable Interaction System in Unity in Under 60 ๐Ÿซณ๐Ÿ—ก๏ธ๐Ÿ˜Ž #unitytips #unity3d

15,931 ๆฌก่ง‚็œ‹ โ€ข 1 ๅนดๅ‰ โ€ขvia X (Twitter)

10 ๆก่ฏ„่ฎบ

Hura ็š„ๅคดๅƒ
Hura1 ๅนดๅ‰

Don't forget to cast your interface to UnityEngine.Object when checking for null. If not, you'll have some crazy moments ๐Ÿ‘€. The video doesn't do null checks so it doesn't apply but it's nice to know ๐Ÿ™

Sunny Valley Studio ็š„ๅคดๅƒ
Sunny Valley Studio1 ๅนดๅ‰

Thanks for sharing ๐Ÿ‘

Distracted Coder ็š„ๅคดๅƒ
Distracted Coder1 ๅนดๅ‰

Hah I usually use SendMessage for stuff like this. Good to know thereโ€™s a better way

Sunny Valley Studio ็š„ๅคดๅƒ
Sunny Valley Studio1 ๅนดๅ‰

Yeah c# is staticly typed so I would recommend using interfaces. On the other hand if you work in Godot in GDScript (dynamic language) sending messages is a default way. It is super cool but the tradeoff is there is no error checking done by the compiler.

Mobius Dev-Tech ็š„ๅคดๅƒ
Mobius Dev-Tech1 ๅนดๅ‰

This is an example of abstraction right? It's quite powerful thanks for sharing.

Sunny Valley Studio ็š„ๅคดๅƒ
Sunny Valley Studio1 ๅนดๅ‰

Technically i believe it is an example of implementing polymorphism through interface implementation. You do abstract out the concept of "interactable" object by defining a common method (interface) to be called.

Alex Ameye ็š„ๅคดๅƒ
Alex Ameye1 ๅนดๅ‰

Nice! How are the selection outlines rendered? Extruding the vertices?

Sunny Valley Studio ็š„ๅคดๅƒ
Sunny Valley Studio1 ๅนดๅ‰

I explain it here ๐Ÿ™‚

ozn1911 ็š„ๅคดๅƒ
ozn19111 ๅนดๅ‰

pls tell me how did you quickly add the function there

Mahima Singh ็š„ๅคดๅƒ
Mahima Singh1 ๅนดๅ‰

Thanks for sharing! Iโ€™ll give this a try

็›ธๅ…ณ่ง†้ข‘