Mina you are just the best, I'm so happy i found this channel, I'm gonna learn so much! I'm so excited. I'm not just gonna learn how to programme in unity but also how to optimize my code. So so grateful. Please continue making more unity/ c# lessons, you teach so well.
@minapecheux6 ай бұрын
Haha you're very welcome, thanks for your nice comment! (And you're in luck: I just started re-posting Unity tutorials like 3 days ago ^^) Cheers!
@LorrahNgobeni-mj2mn6 ай бұрын
@@minapecheux I'm happy, thank you Mina, God bless you!🤗
@carlozuk Жыл бұрын
Im really happy i found your channel, love the way your explain and your accent , ty for switching to black screen to show the code :)
@minapecheux Жыл бұрын
Thank you very much, I'm really glad you like my content and the format! (And yep, I decided to finally switch over to a "dark theme", it required a bit of adjustment on my end but I feel more at ease now ^^) Cheers :)
@solitarygrounds9 ай бұрын
this has to be one ofthe best explainations and use case of scriptable objects ive found
@muzboz Жыл бұрын
Thanks for the great video. I'm glad you explained all the ins and outs, like how Scriptable Objects behave differently in a final build, than in the editor. There are many gotchas! It's quite a complex topic, with nuances to their behaviour in different situations and use cases, and choosing when and how to use them can be fiddly!
@minapecheux Жыл бұрын
Thank you very much! :) SOs are definitely a powerful but tricky tool, and I've actually learnt a lot of these caveats over the years... sometimes at my own expense ^^ But anyway - I'm very happy you liked the sum up, cheers!
@danielgriffin4624 Жыл бұрын
Awesome tutorial! Cheers :)
@minapecheux Жыл бұрын
Glad you liked it, thanks for the nice comment!
@jensadams8873 Жыл бұрын
Thank you for this awesome tutorial!
@minapecheux Жыл бұрын
Glad it was helpful!
@Miura-Anjin Жыл бұрын
Thanks for the great video. I really am gladd to have watched this awesome explain.
@minapecheux Жыл бұрын
I'm really glad it was helpful, thanks for the nice comment!
@AbdullahGameDev Жыл бұрын
Amazing video👋
@minapecheux Жыл бұрын
Thanks, I'm really happy you liked it! :)
@Umblizm Жыл бұрын
I'm not exactly sure what's going on for me. Using your project as example. When i'm trying to declare a value and putting down data.XP or data.health. In return I am being told that my SO doesn't have a definition for that data? I have tried using the value as both an int and float value. declaring it at the start using health = data.health. All of which gave the same error.
@minapecheux Жыл бұрын
Heya! Hmm, I'm not sure about your initialisation (or perhaps I misunderstood your last sentence). To tell a Scriptable Object class "blueprint" that it has a "XP" and a "health" field, you need to: - 1) ensure it derives from the ScriptableObject C# class - 2) declare public variables (e.g. ints or floats) inside, called "XP" and "health" - 3) add a [CreateAssetMenu] attribute above your class so that you can actually instantiate this blueprint. Then, if you create an instance of your blueprint as a new asset (by right-clicking in the Project doc, and navigating to the right sub-menu according to the path defined in the [CreateAssetMenu] attribute), you should be able to select it and see the two variables in its inspector. If that works, you'll also be able to: - 1) create another C# script - 2) inside, create a new public variable "data" of type "PlayerData" (or the name that your Scriptable Object C# "blueprint" class if it's different) - 3) put this new script on a game object and, in its inspector, drag your instance from before - 4) back in the script, use "data.XP" or "data.health" to get/set your instance's values I hope it helps, and if it doesn't - feel free to tell me which step causes errors on your end and we can try to solve the issue! :)
@Umblizm Жыл бұрын
@@minapecheux hey there! I realized the error came from my own rookie mistake. I ended up calling for the SO by just typing public ScriptableObject Instead of the class name
@minapecheux Жыл бұрын
Alrighty!
@josekarnikowski1711 Жыл бұрын
Nice video! :)
@minapecheux Жыл бұрын
Thanks, I'm glad you like it!
@AlbertoFdzM Жыл бұрын
Great content! Thanks for sharing. I'm starting to play with Unity's Scriptable Objects and I didn't consider the use of events to track data mutations, it is a nice approach. When you implement the buttons to update player data from the game logic at 13:20, it's important to invoke the update event once the data is updated in the PlayerManager class, it could be missed since that part is shown a bit fast. Off-topic: May I ask what video editor are you using? Your videos look so clean and smooth, and I'm trying to make devlogs oriented to developers, I feel like years away from the quality of your videos 😅, thanks in advance.
@minapecheux Жыл бұрын
Thank you very much, I'm really glad you liked the tutorial :) Yep I did gloss over this a bit I'll admit... (it's partly because I'm trying to push people who are interested to take a look at the code on the Github, but that's kind of bad on my part^^ - and also, I reworked that part and didn't have time to redo everything :D) But truthfully, you're absolutely right ;) I'm using Da Vinci Resolve (totally free version)! I don't use any of the colour editing tools, it's just for editing. So far (~2+ years in the using), I really like it and I find this amazing the core tool's available for absolutely no charge...! Hope it helps, cheers!
@superdahoho Жыл бұрын
I am having a hard time wrapping my head around this. Is it only good on variables that don't change? For example, let's say your viking is an enemy unit and we're generating 20 of them in game for the player to fight against. SO is good at for referencing the viking's level because instead of 20 INTs, we only need one. But for stats that do change, say viking's HP, because player might attack different vikings at a time, there's no need to put that variable as SO. right?
@minapecheux Жыл бұрын
Hello! In my own experience, SO can be used for two things: - to "expose" some of your data in an easy-to-read and easy-to-modify way: typically, rather than having to write some enemy statistics in an XML file, you could store this data as a ScriptableObject. In that case, you use SO for your data models, and you just pick info from them when the game is running (read-only). - to have some centralised source of truth for a "singleton-ish" piece of data in your game: for example, your player statistics (health/mana/energy/special state...), so that all of your decorrelated systems can access it individually and use it as a global exchange data chunk. In that case, you use SO for an actual data instance, and you both read and write to it depending on which system is accessing it. I hope it clears things out, cheers! :)
@TheKr0ckeR Жыл бұрын
Nice way of explaining SO's! I sometimes find myself over-using SO's that so many SO's to handle with. Its good for to share player's health to store it in SO. But what if we have +100 enemies that spawn in runtime. Should we create another Health system for them. This makes me feel making 2 different health system. Not using a common one
@minapecheux Жыл бұрын
Thanks! :) So yep, I don't think you can always have just one big system for an entire game - SOs quickly have you "specify" and "expertify" your objects, from my experience ^^ And just in case - if you're actually talking about the problem of sharing the same objects between multiple enemy instances, you're absolutely right: we couldn't use just one SO for multiple instances with different parameters! What we could store in the shared data is perhaps the max health, but not the current health ;) (Not sure if it was your question, but anyway :D) Anyhow - thank you again fo the nice comment, cheers!
@semi_jared39 Жыл бұрын
jesus christ the explanation and use cases of scriptable objects is so well done. Even monkeys can understand it
@darkman2379 ай бұрын
If you wanted to pass a scriptable object to a script to have it read, how would that be accomplished? Like in an inventory system and you want to see the properties of a piece of armor or weapon.
@minapecheux9 ай бұрын
Heya! This is typically what we do in the UIManager script (around 12:38) to get info from our PlayerData "data" variable, and use it to update our UI (in the _UpdateDataDisplay() method). So basically, you want to expose a variable in the inspector and drag your ScriptableObject to it (or, alternatively, load it using Resource.Load for example) in your script, and then you can access the public fields in your ScriptableObject as usual in C# :) Hope it helps, cheers!
@darkman2379 ай бұрын
@@minapecheux Thanks! I wanted to send the SO to the script rather than attaching it.
@hiei9793 Жыл бұрын
Hello ! I'm fairly new to unity and i'm trying to create a card game. I tried scriptable objects and it works great. I just create a scriptable object card with mana, attack and health. But I have to drag and drop my scriptable objects to my gameobject script every time I create a new card. Is there a way to call a particular scriptable object card I created with for exemple an ID instead of drag and drop it on my game object ? Thanks in advance !
@minapecheux Жыл бұрын
Hi! I think that the easiest method here could be to load the ScriptableResources as assets from your project in a script. You can actually create an in-editor script (meaning it is not run during the game, but when you click some special button in the UI) to automate this step. You'd need to take a look at Unity's in-editor UI system, and the UnityEditor.AssetDatabase class that lets you load/save/update assets in your project outside of runtime. I hope those pointers help get you started, cheers :)
@hiei9793 Жыл бұрын
@@minapecheux Thanks for taking time to respond ! I will look that way ! :D
@viral-10x Жыл бұрын
ThankYou so much ...
@After_Pasta Жыл бұрын
I find it much easier having my scriptable objects in a setup or start scene this way you can just use the objects you want and make sure they are in the appropriate scenes This also stops you from drag and dropping every scene you need that object