This is something I've been looking for ages. To make a dialogue system that can reference properties and check what they are
@xdCloudxd19963 жыл бұрын
You make programming look so easy, it's impressive, hope I get there eventually!
@小鳥ちゃん3 жыл бұрын
wanna be friends?
@xdCloudxd19963 жыл бұрын
@@小鳥ちゃん yeah sure ^^ it's just, sometimes you don't really know where to start ':D
@小鳥ちゃん3 жыл бұрын
@@xdCloudxd1996 nice uwu then, I guess it would make sense to move to discord or something xd
@xdCloudxd19963 жыл бұрын
@@小鳥ちゃん I sent you an invite on steam
@benj25352 жыл бұрын
I did this a while ago and forgot to leave a comment but combining this with your cheat console tutorial has been so useful! Thank you so much! Your videos has been so useful for me and I feel stupid about not knowing about some of this stuff before.
@kennypu3 жыл бұрын
Nice, I used to use Enums for a much simpler version of this, but being able to tag attributes to automatically create a list is much more helpful in the long run (although more to code).
@thebebinator3 жыл бұрын
Awesome video. I'm definitely going to use this in my work. Some constructive feedback: I would say in the future you could reduce your fastforward speed by about 50%. it was a bit too fast to follow what was going on without heavy use of the pause/rewind buttons. I would just slow everything down a little bit to make it a bit easier on the viewers. Also pausing for a second between the voiceover sentences would help digest the information as well.
@TheOriginalFish3 жыл бұрын
Your in depth content is exactly the thing I need to up my Unity knowledge further, thanks matt and keep it up!
@3enny3oy2 жыл бұрын
Thanks for this! The first tutorial on custom attributes in Unity that hasn't sent me to sleep 😂 you're a legend
@SanderDecleer3 жыл бұрын
I am always kind of put back by the complexity and verbosity of using reflection. I hope we can all agree that this kind of code is not very readable at first glance. You have convinced me to push through and make more use of it however. It is a potent tool with many possible applications. Thank you for giving such a clear example.
@harshmudhar963 жыл бұрын
Two words: extension methods. Another two words: TypeCache class. It is rather tiresome at first glance, but gets easier over time. Still, deep reflection will always feel, for the lack of a better work, fucky.
@SanderDecleer3 жыл бұрын
@@harshmudhar96 Wow, thanks for the TypeCache pointer
@darkenaxe3 жыл бұрын
@@harshmudhar96 Do you mean that you are packing your "reflection" related code into extension methods in order to keep things more clear ?
@harshmudhar963 жыл бұрын
@@darkenaxe Basically, I have two classes: ReflectionUtils and TypeExtensions. Type extensions has the common extension methods, like GetMemberValue (getting value from fieldinfo/propertyinfo/method). Every reflection based operation I have to do, usually ends up as a pair of Static Method + Private Static Dictionary. Over time, I end up re-using these operations, which saves time.
@darkenaxe3 жыл бұрын
@@harshmudhar96 Oh ok, it indeed seems kind of flexible, thank you for taking the time to share this :)
@krisztianszendrodi70573 жыл бұрын
This is really cool! I use and create this kind of tools all the time, but I did not see anyone covering it on youtube, great job!
@arksizy17293 жыл бұрын
Now this is quality content, glad I found this channel. Best of wishes
@_denzy_63103 жыл бұрын
When you spend more time designing the tools for the game than the actual game lol
@TheRmbomo3 жыл бұрын
Always sharpening the axe.
@behnamrasooli88013 жыл бұрын
I guess it's because making tools are easier than making games. Some people do this to make themselves feel productive :) No offence to this channel though. I love this channel.
@MaZyYTube3 жыл бұрын
I spend more time in tools. Tools can be used so often and make development workflow easier.
@behnamrasooli88013 жыл бұрын
@Гоша Ватюнга The reason I say making tools is easier is that a tool doesn't need to be fun. This 'fun factor' makes developing games harder because it often requires radical changes in the codebase architecture. When making tools, we relatively know more about the end product, so we can plan ahead. I'm not say making tools is easy, but it's easier.
@harshmudhar963 жыл бұрын
@@behnamrasooli8801 The one thing that makes or breaks a game engine is tooling. It's not how state of the art the rendering pipeline is, how many systems are prepackaged into the engine, how advanced in built AI is. It's tooling, and it takes a lot of UX knowledge and coding chops to make good tools.
@tommy0310883 жыл бұрын
Dude, this is a fantastic video with both clear concept and explanation! Your channel really deserves more attention.
@MaZyYTube3 жыл бұрын
I like that. I most time work on stuffs like that more than game development. Reflections are really cool. Worked very often with that.
@Pedro_Marangon2 жыл бұрын
Awesome video! I can see this being applied to that Debug Cheat video you did, making it easier to add commands simply by adding an attribute to a method (similar to how the Quantum Console asset works)
@Hymnal273 жыл бұрын
I literally ran into this today and thought "there must be a better way". Thanks!
@gammacreeper12343 жыл бұрын
Just found your Channel 2 Weeks ago and i think you are my new Brackeys :D. Great Videos :)
@ChiliDev3 жыл бұрын
Very useful video dude loving the concept and it will really ease the load for the designers in making content
@enriquemorenotent3 жыл бұрын
Wow, this is really advanced. I gotta admit I was unable to follow it, even pausing the video :/
@burstofsanity3 жыл бұрын
Same here and I've been programming to some degree for over 20 years … damn I'm old.
@小鳥ちゃん3 жыл бұрын
@@burstofsanity really? :o were you using c# for a long time? because im using it for like 6 years and can't live without custom attributes basically
@burstofsanity3 жыл бұрын
@@小鳥ちゃん No, I started using c# about 3 years ago through Unity but no formal training in it. Most of my time was in C++. Since my earlier comment I watched some other videos on the subject because I was curious and rewatched this one. I don't see the way it's explained here any easier to follow though. And I find the example use case for text replacement clunky.
@小鳥ちゃん3 жыл бұрын
@@burstofsanity well, I'm used to use reflection for something like modules or marking routes in the web dev
@enriquemorenotent3 жыл бұрын
@@lee1davis1 Who is Matt?
@bluedev63042 жыл бұрын
Can the process of getting attributes from reflection get faster? Coz i wanna access them at runtime but it takes like 5 seconds for the reflection task to finish. and i also noticed that the current appdomain gives 91 assemblies but only 2 of them are actually created by me and i can edit them all the others are unity's pre compiled dlls or system dlls which are useless to me
@Mimas742 жыл бұрын
This is amazing! Thank you for your time to create this video.
@bobbymcbobface3 жыл бұрын
yay! new game dev guide vid - good as always :)
@RandomProduct3 жыл бұрын
Pretty cool to see my name in the credits! Keep up the good work dude! :)
@noodle-eater3 жыл бұрын
Awesome, thanks dude. Perfect idea for my localization
@MarekNijaki3 жыл бұрын
Awesome video
@ThatAcc3 жыл бұрын
Did I say that i love you deeply before? I think I did, but just in case: I love you and all the videos you upload, thank you.
@KoshYoutube3 жыл бұрын
I think it is more readable to assign values to tags in the text. So you can say {PLAYER_AGE} refers to the age value of the player. {0}, {1}, etc, do not really make sense too much for the person editing the text
@slagtp86033 жыл бұрын
I would love to see logical box representation of all classes in single frame.
@Pedro5antos_3 жыл бұрын
Awesome, awesome content and explanation! Keep it up
@LaCreArthur2 жыл бұрын
Awesome video thank you ! Never had the courage to dig into this subject and finally did so very happy ! Is there a way for the code to be more performant though ? The all assemblies lookup is very long even for almost empty project... Every access to a ExposedValueText takes several seconds...
@liualex323 жыл бұрын
Great work, Great help.
@ffurkan043 жыл бұрын
Nice thanks I use
@ruchirraj53003 жыл бұрын
I've been searching for this for a long time 😀
@yhd47114993 жыл бұрын
like it so much whats the name of the graphic editing tool (looks like an graphic coding tool) at the begining? it looks really cool
@monsume1233 жыл бұрын
Amazing tutorial. Thanks ! Is this available somewhere, would like to browse through the code some more?
@ludologian3 жыл бұрын
Reflection and dynamic aren't allowed on ios , ( sure the editor is allowed) the final compiled won't have any editor related code . I might need this in the future thanks for sharing
@legends3893 жыл бұрын
Awesome Video =D
@DePistolero3 жыл бұрын
Thank you so much!!!
@mrx100013 жыл бұрын
Do you ever share the repos for your videos? Would be really appreciated.
@twoloopgames2 жыл бұрын
What software do you use to edit?
@gregoryfenn1462 Жыл бұрын
At 2:45, what even is an assembly? How can you iterate through them?
@crash19981003 жыл бұрын
I tend to use attributes and reflections as a last resort because it takes a lot of work and code for pretty basic results. Feels like there should be a simpler way.
@Mika-di5nz3 жыл бұрын
Nice
@ThomasChen-ur2gt3 жыл бұрын
Can I somehow get your project file? I'm kind of lost after watching the video, and I really want to fully understand it.
@herohiralal32553 жыл бұрын
Can you do a video on the behaviour nodes thing that you use?
@uncleg12143 жыл бұрын
Can you please make a tutorial for creating a node graph editor extension using reflection and serialized properties please
@Caslte3713 жыл бұрын
That thing, where you get access to assemblies. Can I add to all data, that need to be persisted an interface (something like "savable") and get through them all?
@floriangr78883 жыл бұрын
Hi, i wanted to extend your code and include prefabs in the list but I got stuck with the selection part Since prefabs are instances of the same class i cant differentiate the FieldInfo with a simple string So when i select a exposed Property of my Prefabs it just takes the first FieldInfo with the same name i would have to change the ExposedValueSelector to something else then a string or extend it somehow
@teemuleppa33473 жыл бұрын
i've heard that using reflections are inefficent performancewise since doing those things at runtime gives a performance hit....what's your take on this?
@AM-vr4qy2 жыл бұрын
I would use these methods for game code, but editor code I don't see too much of an issue.
@chrisskyr6232 жыл бұрын
Plas help me I am getting a error at 3:17 with the line if(member.CustomAttributes.ToArray.Lenght > 0) it say that ToArray() does not exist I am using unity 2021.2.9f1
@Pedro_Marangon2 жыл бұрын
You probably need to add the System.Collections.Generic namespace
@RandomProduct3 жыл бұрын
Hellllll yeah
@ananttiwari13373 жыл бұрын
Patreon?
@RandomProduct3 жыл бұрын
@@ananttiwari1337 yup! Would recommend.
@ruchirraj53003 жыл бұрын
What was the node editor framework you were using?
@arthurmartins15113 жыл бұрын
he made it himself
@vAscA1873 жыл бұрын
I don't even know how to ask... Can int[ ] [ ] or int[ , ] be saved in a binary formatter, serializable, data container method (insert coding words here)? :)))
@harshmudhar963 жыл бұрын
Yes. You can save it with Unity's serialiser too if you first make a class out of it.
@vAscA1873 жыл бұрын
@@harshmudhar96 tnx bud, allready did that but the game wasn, t at testable point and i wanted to double check
@nomadcrossfire3 жыл бұрын
Any idea how to make a "hook" style attribute like the unet syncVar so that it'll cause a method to run whenever the value changes? I know how to do it via properties, but was curious about an attribute based solution.
@harshmudhar963 жыл бұрын
In an ideal world, we'd have proxy objects easily available. The job of a proxy is to transparently intercepts, in this case, get/set operations. So as a programmer all you did was declare a normal auto property with an attribute, but when it runs, it automatically gets replaced by a proxy that intercepts (Prop.Set) and does something between the assignment and the actual setting of the value. (In this case it internally notifies some service that the view is dirty now and needs to be synced). You could achieve the same thing by patching the IL after compilation. I'm actually not sure how SyncVar does it.
@ThomasChen-ur2gt3 жыл бұрын
I normally double the play speed, but I have to slow it done for this
@milkgang63313 жыл бұрын
Cool. Nice teaching(easy to understand)
@Tiranice3 жыл бұрын
5:04 And throws a null reference exception when the game isn't running because GameManager.instance is initialized at runtime, unless I've missed something.
@ZiplawDev3 жыл бұрын
yeah that makes sense since you only wanna update those values at runtime
@Tiranice3 жыл бұрын
@@ZiplawDev But OnGUI() is called whenever the editor is interacted with, so will spam the console with errors. Fixing that would just require checking Application.isPlaying before doing the reflection.
@ZiplawDev3 жыл бұрын
@@Tiranice I thought you meant whenever you pressed the button
@willpetillo11893 жыл бұрын
Maybe I am not advanced enough for this content yet, but I am not seeing the value-add here over, say, giving public variables meaningful names and editing their content in ScriptableObjects.
@harshmudhar963 жыл бұрын
Attributes add meta data to your class definitions in a way you can't normally do.
@harshmudhar963 жыл бұрын
Guide showed a very simplified example for demonstration purposes. Not to mention, attributes are a part of the type system, and thus can be programmed against with static guarantees. Naming is a convention.
@harshmudhar963 жыл бұрын
Finally, making editor tools is basically the editor version of static type checking. You can misspell {D_HOME}, but it's much more difficult to select Locations/Home from a drop down. Let's say you have a new team member that doesn't know your 100s of content-specific variables. A tool for exploring variables goes a long way,
@willpetillo11893 жыл бұрын
Lol, if you are going to troll, show some self-respect and put at least a little effort into it! Thanks for the explanation Harshdeep. I still don't follow, again in terms of the real-world problem being solved. More specifically, the first half where he creates a property drawer instead of just using [SerializeField] variableName in the script directly (the advantage of selecting variables from a dropdown over typing them in is clear enough). Is it being able to reference the same variables from multiple scripts with no chance of misspelling? If so, that's incredibly trivial with ScriptableObjects. If this adds in being able to allow those scripts pick and choose in the editor which variables it has access to...again trivial with ScriptableObjects. If this also adds being able to avoid having to define which variables go together in a centralized way or being able to change what variables a script uses quickly, that's kinda cool I guess...
@harshmudhar963 жыл бұрын
End of the day, it's a simplified problem for demonstration porpoises.
@minecraftermad3 жыл бұрын
To avoid this issue i basically made a visual scripting language in my project...
@harshmudhar963 жыл бұрын
Delegate.CreateDelegate is my god.
@Kenbomp Жыл бұрын
Seems to violate encapsulation but ok.
@jayshippey67722 жыл бұрын
Jeez this video is impossible to follow. There's so much extra stuff he does not mention that is required and so much of the confusion comes from how zoomed in on things he is all the time. There's stuff offscreen that's needed for a lot of this stuff
@toastyshrimp1882 Жыл бұрын
this isn't for beginners. This channel isn't for you.
@kakarotsan30302 жыл бұрын
Holy over-engineering, Batman. I don't think reflection is great idea for performance either.
@RimmCriolle Жыл бұрын
this video is way too fast for me
@tomtomkowski76533 жыл бұрын
Because you showing something fast it doesn't make it looks more advanced. Slow down man, hard to follow even with pausing the video.