I've been using Odin for the past few years, mainly for its serialization system. I ran into a wall when I tried to expose custom serialization on components. I heard about SerializeReference a few months ago. I did a few tests, converted ALL my SerializedMonoBehaviour, SerializedScriptableObject and everything in favor of the good old MonoBehaviour, coupled with the power of SerializeReference. It just worked magically, solved all my problems, wow! Note that I still use odin serialization regarding saving a complex object from/to disk but that's it.
@saeedbarari2207 Жыл бұрын
the serializeReference is way more expensive though. and it's not exactly bugless. You should try to *not* use it unless you have to, or the alternative approach doesn't worth the time
@Kanon_39_ Жыл бұрын
I just started working on a card game and was wondering how to implement all the card effects and abilities. Using scriptable objects to create cards worked just fine but I didn't even consider doing the same for abilities. Thanks a bunch!
@shibuyajin_music Жыл бұрын
I LOVE YOU! just browsing your channel randomly solved a lingering problem for me with inventory items (consumables, weapons, vastly different types of items that still should be considered and listed the same: inventory items) my dum ass was literally feeding empty properties like 0 durability to all items just to fulfill the weapon durability system. It felt very goofy
@notlaw1567 Жыл бұрын
That's cool! I would like to share something I do a little bit different. Instead of making a virtual method on the base class, I create an interface to apply required methods for the class (i.e: ISpell), and then apply the interface abstractly to the base class. That way it serializes without making the class abstract.
@Un4GivNX Жыл бұрын
Another cool thing is that you could declare [SerializeReference] private List _someList; You'll be able to serialize basically any serializable class that implement IMyInterface.
@newarteest3 ай бұрын
neat, I think this is even better than having an abstract class (what he mentions in the video)
@dreamisover9813 Жыл бұрын
Haven't used SerializeReference yet, but I read up on it and it seems pretty useful. Before I'd usually just make each effect as its own Scriptable object class.
@mauriciopartnoy2789 Жыл бұрын
Looks very useful! The headers could be left there to let the user know the Effect type of each member of the collection without having to create custom inspectors. Thanks for sharing, Jason!
@Unavailable8923 Жыл бұрын
For new people, it may be useful to show an Apply() method in Spell that does: foreach (var effect in Effects) effect.Apply();
@JayZireael Жыл бұрын
I am absolutely shocked that your example is exactly how I set up that system in my own game. I feel a little proud, to be honest.
@EnderElohim Жыл бұрын
Inheritance, interface, sub classes are good things to know
@erikm976810 ай бұрын
Actual information starts at 6:50, i'm not kidding
@keelanbowker-obrien2222 Жыл бұрын
Love the tutorial. I'm kind of curious how you might extend On-hit effects (and other conditional logic) to this framework. Any advice?
@saqibbro5297 Жыл бұрын
I lob u, that's a great teacher right there!
@cptant7610 Жыл бұрын
Wow, thank you so much , I was looking for this for my Finite State Machine and couldn´t get it to work previously.
@damnpete Жыл бұрын
That was a pretty good question. Your implementation is also very interesting. Maybe a minor tweak is to have the SpellEffects also be ScriptableObjects, so you can reuse the same instances of effects in other spells and also allows you to drag and drop the effects without having to create the ContextMenu entries to add effects (without those ContextMenus you aren't able to add effects since it would add the base class to the array if you use the + button)
@Betruet Жыл бұрын
Great content 👌
@bsdrago Жыл бұрын
Please, elaborate more about this video! =)
@homemacai Жыл бұрын
Very useful stuff!
@alexleonardkrea Жыл бұрын
Very cool, thanks!
@MrTsilipe Жыл бұрын
Very nice video. All the variables it is in public. Can the "class" return each value and the variables to be privet?
@catafest-work Жыл бұрын
good work, but scriptable object can be tricky , I think is more good to use delegate in C#. I would recommend for the learning part a video about the special errors that appear in Unity 3D as a result of the changes between the editor and the scripts or differences between the packets and the old implemented source code. Let's see these errors with ThirdPersonController and all definitions: error CS1061: 'StarterAssetsInputs' does not contain a definition for 'analogMovement' and no accessible extension method 'analogMovement' accepting a first argument of type 'StarterAssetsInputs' could be found (are you missing a using directive or an assembly reference? How about this issue?
@Steve-dd3pt Жыл бұрын
I started with same system but while I expand it this become problematic for example some of spells should deal damage after reach target like fireball. This is depending on needs but I changed whole spell system in my game to one single class Spell and evry spell can have a list of components like deal damage, create effect, targeting or triggering other effects. In this set I can create so far all off spell I can image for example teleport player, create 3 fireballs to closest targets, when they reach targets they will heal a player. Thanks for video!
@inkofthedragon Жыл бұрын
Is what you are describing as Composition?
@christomanosanastasiou5601 Жыл бұрын
Is it like polymorphism?
@morybest Жыл бұрын
Jason ! Its a bit complicated. But thanks a lot for making this .🤩🤩🤩
@dwried Жыл бұрын
Where might I go to dig up more interesting (not sure what to call it lol), things in brackets. I get the feeling there's more germs or there to dig up. Good to have a treasure map though, to know where to start digging.
@AschKris Жыл бұрын
Those are called Attributes, you can find them on the Unity Manual, on the Scripting API under both UnityEngine and UnityEditor.
@johncarlogamboa7331 Жыл бұрын
I think the reason why you couldn't make it an abstract class (though it obviously should) is because behind the scenes when the ScriptableObject gets instantiated as an asset, all of its serialized fields needs to be instantiated, objects of abstract class are not instantiatable.
@JayadevHaddadi Жыл бұрын
Super cool Jason! I just wish the same would work for non-ScriptableObject's... that would have been very helpful and powerful...
@saeedbarari2207 Жыл бұрын
it does! you can use SerializeReference on absolutely any class type
@JayadevHaddadi Жыл бұрын
@@saeedbarari2207 Hmm... sure one can use it but in the normal inspector you will only see the base class or in the case of SeralizeReference one sees only blank... have u tried it?
@hamzafayyaz9303 Жыл бұрын
@@JayadevHaddadi I have not tried it in the inspector but i think you have to mark ur subclass/derived class as Serializable also.
@JayadevHaddadi Жыл бұрын
@@hamzafayyaz9303 i have tried... doesnt work:( will only handle base classes. unless one makes a custom drawer/attribute
@milktea0001 Жыл бұрын
you can use the factory design pattern for your use case. Jason has a video about it.
@Octamed Жыл бұрын
So this is basically the same as using a whole GameObject with the spell base class as a monobehaviour and just adding the spell chunks as components? Then saving each spell combo as a prefab or prefab variant. Other than the slight overhead of making everything monobehaviours, what are the benefits?
@Un4GivNX Жыл бұрын
One benefit is that you could create, edit and access your content in scriptableObjects. You will not have to instantiate your whole gameobject structure just to read some values. The overhead is almost non-existent.
@Octamed Жыл бұрын
@@Un4GivNX Prefabs do that though? I can just read them directly, like an SO
@Un4GivNX Жыл бұрын
@@Octamed Probably because you're not using AssetReference and reference public GameObject myGo directly? That mean that this gameobject is implicitly loaded in ram, including his textures, audio, animations, materials, and so on. That is overhead :)
@Octamed Жыл бұрын
@@Un4GivNX Why would SO be any different? At some point the SO needs to reference real FX like particle systems etc.
@spikebor Жыл бұрын
You can think of Prefab and SO are the same, since they live in the project. But MonoBehaviour carries too many bloat variables and methods that if you don't use them, why bother? Regarding performance overhead, the only way to find out is do a stress test, if you're curious.
@arcday4281 Жыл бұрын
The topic is more complicated than it seems, you first need to think through the structure and sequence of events in your head, and only then build a script... personally, my spells are divided into types and are inventory items like any other objects, the projectile is assigned a type when called, then the behavior is determined through enum...
@Hazzel31337 Жыл бұрын
good one again, thank you :)
@GiftedMamba Жыл бұрын
And when you suddenly rename class all your serialization in Editor will be broken. You can use a workaround with MovedFrom attribute, but it is a pain. And you can forget then about cool things like automatic namespace refactoring in IDE. So does anyone know normal way to deal with renaming and moving to another namespace in case of SerializedReference? Because of this problem I stopped to use this feature. When you suddenly rename something and forgot to add MovedFrom attribute, it is such a pain.
@saeedbarari2207 Жыл бұрын
quick tip. the SpellEffect class could've been an 'abstract' class, with abstract functions. meaning no class will be able to directly instantiate the root SpellEffect itself, and has to choose from one of the children. definitely makes the codebase so much neater, if that's something the team cares about
@MrMagicznyMAG Жыл бұрын
Shift + F6 changes variable name
@abhishekjha3750 Жыл бұрын
First again??...... Supppp!! 😂
@erikm976810 ай бұрын
Dude learn to get to the point, 6 minutes into a 7 minute video you still have not talked aboutj SerializeReference, the whoel reason we are here. Learn to value your subscribers time, gamedev is time consuming as it is!
@harddev9181 Жыл бұрын
bro u r just getting older and older i will cry if a legend like u saids quits. :( like u r work. :)
@DiujLopez Жыл бұрын
Man... You're using AI images now. Bummer.
@scort623 Жыл бұрын
Could you speak more slowly buddy, not everyone who accompanies you is fluent in English. Thanks
@GameDevNerd Жыл бұрын
If he speaks English slowly then the video would be unsuitable for English-speaking viewers ... impossible to cater to both. What you should have done was ask him if he will look into subtitling his videos in some way so you can hear what he's saying and read what it means in your native language, so it's a win-win.
@GameDevNerd Жыл бұрын
Hell, Jason, you can use AI to subtitle the videos in English then translate to every other supported language pretty much instantly. KZbin has some helper services built in as well.
@pa_de_queijo Жыл бұрын
I agree, but you can .75x speed
@Octamed Жыл бұрын
It has subtitles that can auto-translate
@scort623 Жыл бұрын
Aaron Carter, I think quite the contrary, even those fluent in English can have difficulty understanding the content of the video. Follow several other programming channels that speak more slowly and even so the content continues to be of extreme quality even for those who are fluent in English.
@GameDevNerd Жыл бұрын
I like some of the new types of videos you're doing here lately, a bit more episodic and more randomness but very much cool. 🙂 By the way: [field: SerializeReference] public PropType PropName { get; set; } = default; // set an appropriate default