What are Scriptable Objects? (EXTREMELY Useful, Make your games Designer Friendly)

  Рет қаралды 118,057

Code Monkey

Code Monkey

Күн бұрын

Пікірлер: 186
@CodeMonkeyUnity
@CodeMonkeyUnity 4 жыл бұрын
Scriptable Objects! Have you used them? They have so many awesome possible uses! 🌐 Have you found the videos Helpful and Valuable? ❤️ Support on Patreon www.patreon.com/unitycodemonkey or get the Game Bundle unitycodemonkey.com/gamebundle.php
@matrettr8037
@matrettr8037 4 жыл бұрын
After this video i will use them at 100%. Nice video like
@waterfan3399
@waterfan3399 4 жыл бұрын
Hey, I saw that you are online. Please make a series on C# for Unity in which you may tell about commands like addforce etc. Please make a playlist.
@GameDevExperiments
@GameDevExperiments 4 жыл бұрын
You explained it very well. I made a tutorial series for a Turn-Based RPG like Pokemon, where I stored the data of pokemons and their moves using scriptable objects. Now, I can point people who are unfamiliar with it to this video, so they can understand the basics before following my series.
@huyopo
@huyopo 4 жыл бұрын
Scriptable Objects can not only store data, they can also used for things like communication between entities. Its often a better alternative to use scriptable objects than to use Singletons (witch you shouldn't use that much, only in really rare circumstances, some say you shouldn't use them at all). Also, ScriptableObjects can contain logic. If you make them abstract, you can use derived scriptable objects to implement the logic of a gameobject. Its more flexible than using different MonoBehaviours and you can hot swap behaviours without destroying and replacing MonoBehaviours.
@lanefaulhaber1824
@lanefaulhaber1824 25 күн бұрын
How can you use them to communicate between different entities? Do you mean through writing to them and observing their change, kind of like an event? Or how is the best way to communicate using scriptable objects?
@harrison298
@harrison298 3 жыл бұрын
This is the only tutorial I've seen that actually made a distinction between the Scriptable Object Definition, and the Scriptable Object asset files that are instances of it. Everyone just refers to all of the various files as "Scriptable Objects" which was really confusing to me at first.
@dmytrosavostianov3055
@dmytrosavostianov3055 4 жыл бұрын
Duuuuuude, firstly you save me with your DOTS videos, now you do with this one! Muuuuch love for you!
@KrazyKain
@KrazyKain 4 жыл бұрын
I'm really going to have to rethink how my rpg engine handles characters and items after watching this :D
@laodes
@laodes 3 жыл бұрын
Yes. This. I always find a new way to refactor everything and If I can manage the transition it always makes further extension easier.
@laodes
@laodes 3 жыл бұрын
But I've never managed the transition successfully. Something always ceases to work and have to reimplement.
@mattjclay
@mattjclay 3 жыл бұрын
I started using them for everything. It makes everything so much easier.
@danieloxor
@danieloxor 2 жыл бұрын
Yup, sounds perfect for player statistics, quests, inventory, loottables and so on :D
@ZukuseiStudios
@ZukuseiStudios 4 ай бұрын
One of my many go to Code Monkey videos, you have a lovely repository now of great tips and tutorials that is super helpful. Your voice/manner is also very encouraging and reassuring with confidence and you get to the point quickly. I love how you give just enough info quickly so we can go "oh yeah that's how it worked, I remember now" to also adding more detail. You deserve great things my friend!
@CodeMonkeyUnity
@CodeMonkeyUnity 4 ай бұрын
Thanks for the kind words! I'm glad my videos have helped you!
@xkittencatx
@xkittencatx 3 жыл бұрын
I loved how you explained it! It made it very easy to understand! I think I can use Scriptable Objects a little bit more intuitively now; when I first read about them they seemed SO complicated!
@skye734
@skye734 4 жыл бұрын
Man you're really doing great job!!!You are using your time and skills to make our journey easy.Huge Respect and love for you.🤗
@CodeMonkeyUnity
@CodeMonkeyUnity 4 жыл бұрын
Thanks! I'm glad you like the videos!
@arrain4737
@arrain4737 4 жыл бұрын
I've never worked with scriptable objects. I would say let's expand our horizon! :)
@b5fan504
@b5fan504 6 ай бұрын
Still the best video on this topic to be found anywhere.
@lanceroygames
@lanceroygames Жыл бұрын
Thanks this helped with some data issues I was having when changing scenes. I needed the data to persist through scene change, but I needed it to reset upon starting the game. Seemed like Scriptable Objects are the solution!
@CodeMonkeyUnity
@CodeMonkeyUnity Жыл бұрын
That is one approach, just be careful you fully understand how persistence works with regards to scriptable objects. They will act persistent in the Editor but not in a Build unitycodemonkey.com/video.php?v=5a-ztc5gcFw unitycodemonkey.com/video.php?v=CjJNeyyhsKs
@rickloyd8208
@rickloyd8208 4 жыл бұрын
Really awesome video and good tip regarding SO are sent by reference. That will definitely save the memory. Cannot wait to see next part about custom editor. That makes scriptable objects ideal for custom Editor tool! Thanks for you job and sharing your experience with us!
@mrbananaman8032
@mrbananaman8032 4 жыл бұрын
Yes but this actually a bad thing if you want to be able to enhance an item or ability only for one player or enemy, not all of them
@dspartan007
@dspartan007 4 жыл бұрын
Definitely gonna give this a try some day. Thanks, very useful video, as always.
@Gonzakoable
@Gonzakoable 4 жыл бұрын
One quick thing, they can also be other stuff than just data. A scriptable object is pretty much the same as a monobehavior but without an update method
@CodeMonkeyUnity
@CodeMonkeyUnity 4 жыл бұрын
Yup, I plan to explore using Scriptable Objects for handling logic in a future video
@nanito0071
@nanito0071 4 жыл бұрын
your videos are a huge help to my videogame, ill try to support in every way i can. Thank you!
@pamalott5
@pamalott5 4 жыл бұрын
Oh I waited so long for this!😊
@CodeMonkeyUnity
@CodeMonkeyUnity 4 жыл бұрын
🌍 Get Code Monkey on Steam! 👍 Interactive Tutorials, Complete Games and More! ✅ store.steampowered.com/app/1294220/
@arcday4281
@arcday4281 4 жыл бұрын
Cool! As always. We are looking forward to the next video.
@CyberStudios
@CyberStudios 3 жыл бұрын
Thank you for this! I have been binge-watching all your videos.
@CodeMonkeyUnity
@CodeMonkeyUnity 3 жыл бұрын
I hope you liked them! Thanks!
@TinyDeskEngineer
@TinyDeskEngineer 3 жыл бұрын
70% of the projects I've started since learning how to use scriptable objects use scriptable objects for basically every single thing out of the still very small amount of things I did
@Andrew90046zero
@Andrew90046zero 4 жыл бұрын
I wish unity could redo the "asset creation context menu" so it would be more like the "add component menu" that you can search and it oly displays 1 tree layer at a time. That would make scriptable objects way much better. I use Odin Inspector, and I found this script that one of the devs of Odin released where It creates a "super list" of all of the scriptable objects regardless of it having a "CreateAssetMenu" attribute. So you can just search it up and create it, much smoother workflow. Also, I'm afraid to click the like button 😬 666 likes lol
@CodeMonkeyUnity
@CodeMonkeyUnity 4 жыл бұрын
Yeah that menu does start to become massive as you add more packages, making it like the component menu would be great
@farfi55
@farfi55 4 жыл бұрын
can you link please?
@Andrew90046zero
@Andrew90046zero 4 жыл бұрын
@@farfi55 If you're talking about that scriptable object script thing. Yes. I actually had to dig for the original link for a minute. And it turns out there is a list of different custom scripts on their website. odininspector.com/community-tools/540/scriptableobject-creator odininspector.com/community-tools
@halivudestevez2
@halivudestevez2 2 жыл бұрын
the cleanest explanation and demo, thank you!
@rickloyd8208
@rickloyd8208 4 жыл бұрын
I have a question, what makes scriptable object more attractive than public properties of the component? They are both editable... the only advantage I see is that scriptable objects could be places in some config folder and designer may not need to search to which object the controller component is assigned (I saved your video and liked in advance, I will watch it tomorrow, sorry if you answered this question within video)
@CodeMonkeyUnity
@CodeMonkeyUnity 4 жыл бұрын
The main point is they are stored as asset files in your project. They have the same type but different data. So a programmer can create the scriptable object definition for a weapon and make the game work with that definition and then a designer can very easily create more weapons by just creating more objects and setting their data. What you're describing would be doable with a Prefab and a script attached to it, but at that point you have exactly a scriptable object but in a more dirty way. In the next video I will cover a use case of adding SCriptable Objects to the Crafting System
@rickloyd8208
@rickloyd8208 4 жыл бұрын
@@CodeMonkeyUnity Thank you so much for your awesome videos! I will watch this video and the next one =) So may be I will come back with some clarification questions later!
@RandomShowerThoughts
@RandomShowerThoughts Жыл бұрын
@@CodeMonkeyUnityah this definitely makes a ton of sense
@sekker2k446
@sekker2k446 4 жыл бұрын
I love your videos. Simple you are the best.
@RodsOnly1
@RodsOnly1 4 жыл бұрын
i can't wait for the steam app!!!!
@FM_GOBi
@FM_GOBi 4 жыл бұрын
I love your videos man!! How come you like saying "yup" so much?
@CodeMonkeyUnity
@CodeMonkeyUnity 4 жыл бұрын
No idea, it just sounds good! I like constantly testing and verifying that the code works so I ended constantly running the game and going "yup the code runs!"
@FM_GOBi
@FM_GOBi 4 жыл бұрын
@@CodeMonkeyUnity Thank you for the tutorials. I always watch them with my Evernote on the other monitor, so I can take notes. It's a huge help. Good luck with your work!
@KM-zd6dq
@KM-zd6dq 7 ай бұрын
Great video, if you use "will not/will" instead of "wont" it will make it even better
@McFlyT28
@McFlyT28 3 жыл бұрын
Watching this video, I can't help but think of well this would apply to RPGs
@CodeMonkeyUnity
@CodeMonkeyUnity 3 жыл бұрын
Yup, RPGs are full or data so this is extremely useful
@santiagogonzalez7291
@santiagogonzalez7291 4 жыл бұрын
What keyboard do you use? Or at least what color keys. The key sound is very good XD
@CodeMonkeyUnity
@CodeMonkeyUnity 4 жыл бұрын
Not sure, I've had it for 10+ years, it's a Samsung something
@mehmedcavas3069
@mehmedcavas3069 4 жыл бұрын
Please make the video with a custom editor. Maybe you could also make a video with this scriptableobject custom editor to make levels. Like a 32x32 grid system where we can paint levels on the SObject and create the level by reading the data. Like making a texture2d based level editor but one which is dynamic
@CodeMonkeyUnity
@CodeMonkeyUnity 4 жыл бұрын
Yup I covered Custom Editors here kzbin.info/www/bejne/mH7YhaZ3osZnqs0 And here kzbin.info/www/bejne/qIGleoaGr9Kbpck I'll be using that in the next video to make a custom editor for the Crafting Recipes. Making a Scriptable Object to hold Level Data would be a great example project, I'll look into it, thanks!
@algs5483
@algs5483 4 жыл бұрын
Thanks. I really needed a good tutorial/ lesson. And you alwalys ( or almost alwalys) do so.
@omoloni
@omoloni 2 жыл бұрын
one from of bests channels
@preflopstore9718
@preflopstore9718 4 жыл бұрын
Fantastic Tutorial!
@WelbyCoffeeSpill
@WelbyCoffeeSpill 4 жыл бұрын
Also,..not sure I want like 80 item objects filling up my project directory. I usually do the excel csv thing. And store new instances of 'item' in a list. I don't understand the big advantages,...yet, to be honest. I guess editing is easier?
@CodeMonkeyUnity
@CodeMonkeyUnity 4 жыл бұрын
If all you have is text then yes using a Excel spreadsheet would be better. But if you have a more complex data structure where you want to store text and images and videoclips and anything else then scriptable objects are very useful. In the next video I'll show a use case of applying this to the Crafting System
@sundarakrishnann8242
@sundarakrishnann8242 4 жыл бұрын
Hey! Is it possible to create stuff like rogue like generation using bolt? If yes, it would be cool if you could make a tutorial on it!
@sundarakrishnann8242
@sundarakrishnann8242 4 жыл бұрын
@@bezoro-personal hi ! Thanks a lot for your reply...i was just learning about rogue like generation and hence I got a doubt if it could be implemented in bolt..since bolt became free I just had a thought of using it..anyway thanks for thr reply..
@CodeMonkeyUnity
@CodeMonkeyUnity 4 жыл бұрын
Sure it's possible, if you go the simple route of just having a bunch of premade level sections and randomly placing them to build your level it can be quite easy. If you want to go more complex it becomes more difficult and the more complex you go the easier it becomes to do it through code.
@sundarakrishnann8242
@sundarakrishnann8242 4 жыл бұрын
@@CodeMonkeyUnity thanks a lot sir! You have replied exactly what I had wanted to know😊( about which could be preferred)...Again thanks a lot!
@ZiplawDev
@ZiplawDev 4 жыл бұрын
Can you make a video on Graph View? There's basically no videos online on the topic (or at least ones that explain the API step by step) It's the API that shadergraph uses, and it'd be really useful for dialogue systems for example
@r1pfake521
@r1pfake521 4 жыл бұрын
Check this kzbin.infovideos there are some videos about Graph View they show everything you need to get started. Should be easy enough to create your own dialog editor after watching these videos.
@sundarakrishnann8242
@sundarakrishnann8242 4 жыл бұрын
What is the library (using CodeMonkey.utils) which is seen in many videos? How did you create? Is there a video on it?
@CodeMonkeyUnity
@CodeMonkeyUnity 4 жыл бұрын
There's no video but you can download the complete package with all the source code and inspect it all yourself
@dasmaffin1633
@dasmaffin1633 2 жыл бұрын
When I use a scriptable object, and change a value (like "isHeld"), then it changes that for the prefab of it, and not for the instance. How do I fix that?
@chuckdude514
@chuckdude514 Жыл бұрын
I don't like them that much because they feel like singletons. For instance, in the enemy weapon example you mentioned, if I were to modify the damage of the weapon of a single enemy (weapon curse debuff or something), every other enemy holding that weapon would also be affected. However, just like singletons, if you plan ahead and know in what ways your game might be extended, then you are good to go.
@CodeMonkeyUnity
@CodeMonkeyUnity Жыл бұрын
My general rule is to only ever use Scriptable Objects for static data. So in that case I would store the weapon base damage in the SO, but for any modifiers I would store them in the enemy/weapon instance and would not modify the SO at all
@chuckdude514
@chuckdude514 Жыл бұрын
@@CodeMonkeyUnity Yeah, that's a nice way of putting it into words and a good example of planning ahead! In my current case, I searched for this video because I was thinking of using SO's to create string managers (one instance to save keys for ES3/PlayerPrefs, another to store tags, and so on). This way, I will be able to keep the codebase more modular, rather than using a MonoBehaviour singleton that can be referenced by any system at any time.
@AsasinoManik
@AsasinoManik 4 жыл бұрын
I am a designer myself, so I just clicked it.
@nosamyd9474
@nosamyd9474 3 жыл бұрын
(laughing noises here) WHAT A GOOD COMEDIAN! 10 OUT OF 10!
@matrettr8037
@matrettr8037 4 жыл бұрын
Can you please make some more advanced tutorial in bolt? Like for crafting system or inventory.
@superdahoho
@superdahoho 6 ай бұрын
hi code monkey, can you do a tutorial on how to make abilities with scriptable objects that have unique functions? I've seen several videos on youtube but they way everything is set up, each new ability is a new KIND of scriptable object. if you were to have 100+ different skills, it takes up so much space in the editor, it's hard to organize them. because when a SO is made, you cannot go in to override the function, therefore each SO has to be it's separate entity. I've been stuck on this for quite some time now.
@CodeMonkeyUnity
@CodeMonkeyUnity 6 ай бұрын
If you have custom logic then one option is indeed like that, make a new type of scriptable object that contains the logic for that new skill Alternatively you could have a that takes in a scriptable object, checks the type and does the specific logic for that object. But in that case you then have logic separate from the scriptable object Yet another option is to go with a much more modular system. Make a scriptable object type for each "effect". Like "projectile", "fire", "dealsDamage"; where each of those would have that logic, and then you construct your skills by composing those different scriptable objects in some array inside the main skill scriptable object. I covered a modular character controller that might help point you in that direction kzbin.info/www/bejne/o3u1lGyhgd15ic0 Or simply use Interfaces with default function implementations, that way you don't need to write tons of code for each SO, just implement the interface, which can make it simpler. But whatever option you choose you are always going to have some amount of complexity if you want hundreds of skills, there's really no special pattern that makes a system like that super simple, just more manageable
@WelbyCoffeeSpill
@WelbyCoffeeSpill 4 жыл бұрын
So many questions! Lol. If it is a reference to the SO,..and three orcs get a sword item SO, but only one Orc uses the sword and decreases its "durability" stat , will that alter the other two sword's durability?
@CodeMonkeyUnity
@CodeMonkeyUnity 4 жыл бұрын
Yes Scriptable Objects are meant for shared data, in your case you would either store the durability in a different way, like as a member variable in each Orc script, or instantiate a new Scriptable Object for each Orc.
@mrbananaman8032
@mrbananaman8032 4 жыл бұрын
@@CodeMonkeyUnity this is exactly why I dont get the point of SOs. Why would I ever want to save every enemy's weapon to disk? Its like a weird niche way of saving your game data if something happens to be an object, yet you'll still have to save everything else in a typical fashion anyways. Another way to look at it is that a SO really wants something to be an object (a sword here), yet in this orc example, you have to remove critical aspects of it like durability from the item and put it somewhere else. This just makes my brain twist in half.
@Juan-lj4pi
@Juan-lj4pi 4 жыл бұрын
By any chance are you going to make a IEnumerator tutorial? either way, thanks a lot, I've learn a lot from your videos :)
@CodeMonkeyUnity
@CodeMonkeyUnity 4 жыл бұрын
I'm usually not a fan of Coroutines but it is a subject I should probably cover sometime
@hawns3212
@hawns3212 4 жыл бұрын
@@CodeMonkeyUnity Why are you not a big fan of them? Is it a specific reason or just habit?
@CodeMonkeyUnity
@CodeMonkeyUnity 4 жыл бұрын
@@hawns3212 Just because they force you to use a very specific pattern of returning IEnumerator, doing yield returns and using a GameObject, that's not something I use anywhere else in my codebase
@supertenchoo4271
@supertenchoo4271 4 жыл бұрын
thank you so much new thing added to my back pack
@mcbvideogames
@mcbvideogames 4 жыл бұрын
Question! I am making a game which has a set of spells. I didn't know of ScriptableObjects beforehand, so what I did is: I created an abstract SpellBase class script (extending monoBehaviour). It contains common attributes between spells, such as name, description, cost, and cooldown, and an abstract void (UseSpell()). For every new spell script, it extends said SpellBase, adds new atts if necessary, and implements the UseSpell() void. Lastly, a SpellManager script, which makes a List out of all Spells, excluding SpellBase, and on certain key presses cycles thtough the list, and when pressing another key, will trigger the selected Spell's UseSpell() void. Is scriptableObject worth extending instead of monoBehaviour? If so, how can I retain this hierarchy without making a drastic change in code?
@CodeMonkeyUnity
@CodeMonkeyUnity 4 жыл бұрын
You can just swap our MonoBehaviour for ScriptableObject and everything will work mostly the same, only difference is functions like Start() and Update() wont be called automatically. Having a Scriptable Object for each spell type and and making Scriptable Objects for each spell action is indeed a valid way to go
@mcbvideogames
@mcbvideogames 4 жыл бұрын
@@CodeMonkeyUnity Hey, thanks for your reply! Unfortunately, I have run into a bit of a problem. Scriptable Objects can't reference scene assets, so my healing spell gets a nullPointerException when trying to interact with the healthbarManager script. Any ideas on what should I do?
@user-vs7qg8vi2d
@user-vs7qg8vi2d 4 жыл бұрын
What unity are you using? Unity hub? Or some other unity? And where do i have to go to find the script programming place that you are using right now? :D
@CodeMonkeyUnity
@CodeMonkeyUnity 4 жыл бұрын
Unity Hub is simply the program to manage all your Unity versions and projects, I'm using 2019.4 For the code I'm using Visual Studio Community
@user-vs7qg8vi2d
@user-vs7qg8vi2d 4 жыл бұрын
@@CodeMonkeyUnity thank you!
@pistoleta
@pistoleta 4 жыл бұрын
The only things that annoys me is how they keep the runtime changes when running on editor. Changes dissapear after restarting unity but sometimes is a hustle specially if youre using Unity Collab
@hhgnehcom7672
@hhgnehcom7672 3 жыл бұрын
Hi Im doing a Card game,and I store Magic card(just run the method of that card then it destroy) method by ScriptableObject, but Its ugly to write a if Or switch(just traverse all type of magic card) method in ScriptableObject ,Is any way to just hook different method in inspector like Enum
@HuGGmaN
@HuGGmaN 4 жыл бұрын
Hi, here is a question of something i can't find. Is there anyway to drag and drop an image INGAME, recognizing the 3d object more closest to the drop site and changing the skin of the object for the imported image?
@CodeMonkeyUnity
@CodeMonkeyUnity 4 жыл бұрын
When you release the mouse, fire a Raycast and if it hits something get that renderer and change the material. You need to break that problem down into simpler parts, first handle dragging and dropping, then identify whats under the mouse, and lastly change the material.
@r1pfake521
@r1pfake521 4 жыл бұрын
Do you mean drag & drop the image ingame from for example a ingame menu or from the outside of the game for example from the PC desktop or folder?
@HuGGmaN
@HuGGmaN 4 жыл бұрын
@@r1pfake521 Exactly
@HuGGmaN
@HuGGmaN 4 жыл бұрын
@@CodeMonkeyUnity Thanks for the answer, i'll try that part, but idk how the program will recognize the image and import it :(
@EDMFanChannel
@EDMFanChannel 2 жыл бұрын
You can make video about ScriptableObject + Tile map , Please!
@mr.jsingh2384
@mr.jsingh2384 4 жыл бұрын
Are you not going to make bolt tutorials
@CodeMonkeyUnity
@CodeMonkeyUnity 4 жыл бұрын
Yup, I'm working on more Bolt videos
@brockormond4131
@brockormond4131 4 жыл бұрын
So a couple of questions... 1) Does scriptable objects ONLY contain data? Meaning they can't run any method calls on their own... if so, 2). Can scriptable objects be useful in conjunction with ECS?
@CodeMonkeyUnity
@CodeMonkeyUnity 4 жыл бұрын
They can have methods as well, I'll cover an example of that in the next video when I add them to the crafting system. Sure, they can be used in ECS, you just need to grab the reference somehow and then you can use them for whatever you want. Although keep in mind they are objects used by reference, not value structs.
@silverdragon711
@silverdragon711 7 ай бұрын
@CodeMonkeyUnity - In your current tutorials you mention always making things private. Is that not true in a scriptable object?
@CodeMonkeyUnity
@CodeMonkeyUnity 7 ай бұрын
Yup scriptable objects are the exception, the reason being because I only ever use them as read-only data containers, I never modify them. However scriptable objects do not enforce that rule, that's just a personal rule that I follow, if it's public you can write to it which might break all sorts of things. So if you don't trust yourself to manually follow that rule or if you work as part of a team and aren't sure if everyone is going to follow it, then you can indeed make them private and expose Get() functions like for normal fields.
4 жыл бұрын
Eu gosto dessa prática. Muitos pensam nela como uma forma de facilitar a configuração de objetos, mas como apontado em 7:45, isso é bem útil para ter um melhor uso de memória. Como sempre, um ótimo vídeo.
@callmedeno
@callmedeno 2 жыл бұрын
So they aren't really designed for setting up references between objects?
@CodeMonkeyUnity
@CodeMonkeyUnity 2 жыл бұрын
Depends if the object exists in the scene or as a prefab, you can reference prefabs since those are not connected to any scene
@lokosstratos7192
@lokosstratos7192 11 ай бұрын
what does onbeforeserialization/onafterserialization mean in scriptableobjects? i dont understand the whole concept of serialization
@CodeMonkeyUnity
@CodeMonkeyUnity 11 ай бұрын
Serialization is basically taking the scriptable object with all it's data and converting it into a format that is saved. For example JSON serialization converts it into a JSON string. Those functions run before or after that process happens You don't really need to use them unless you're making some really custom logic where you want to process some data in some special way before/after Unity does the default serialization
@lokosstratos7192
@lokosstratos7192 11 ай бұрын
@@CodeMonkeyUnity can you help me understand it a bit deeper. when does the serialization process happen? is it when we create a scriptableobject in our asset folder? or when its instantiated in the game ? Im using dictionaries and i need to have isrealizationcallbackreceiver to get an id for the SO Im using a SO for my inventory and SO for my inventory items so the id reference changes. it becomes a bit tricky to save scriptable objects within a scriptable objects
@strooja9032
@strooja9032 4 жыл бұрын
Thanks for this awesome video. I have one little question. If i use a scriptable object for an object(for example bottle of water) and i buy three of them in the game. I can't store the amount in the scriptable object ,right? Because then it will overwrite the asset. How would you save the amount of the item? Thanks again for you great videos and i am looking forward to everything on this channel.
@CodeMonkeyUnity
@CodeMonkeyUnity 4 жыл бұрын
You would create an Item class that would hold a reference to the ItemScriptableObject as the type and a simple int amount. Stay tuned for tomorrows video where I will cover exactly that.
@lanefaulhaber1824
@lanefaulhaber1824 25 күн бұрын
What if I want to use a scriptable object to manage something like enemy stats. And one of the stats is health. Should I have the Monobehavior of that specific enemy change its health when taking damage from the player? Or should I create a unique instance of a scriptable object for every enemy and change the health in the scriptable object? Trying to understand the best use for scriptable objects, if they are mostly a reference for monobehavior, or if they are to be written to more often than not.
@CodeMonkeyUnity
@CodeMonkeyUnity 23 күн бұрын
Personally I like to only use SOs as read-only data containers, so in my case I just don't store the current health on the SO, I only store the starting health or max health. The current health is stored in a normal MonoBehaviour But that's not a requirement, you can use them for read-write data, there is a famous talk all about that pattern kzbin.info/www/bejne/qJK0ZJx-naqSgc0&pp=ygULcnlhbiBoaXBwbGU%3D But keep in mind this possible problem kzbin.info/www/bejne/a5KQq6eZasyWfNk
@lollol-zk8dh
@lollol-zk8dh 4 жыл бұрын
Is this possible to be made in say like roblox? which uses LUA
@anonymoussloth6687
@anonymoussloth6687 4 жыл бұрын
Please correct me if I am wrong: so the benefit of scriptable objects is suppose I have and an enemy script that is attached to each enemy in my game. That script will have data like sprites, animations, etc which are the same for all enemies but because each script is attached to a gameobject, it will create duplicates of that data. However, with scriptable objects, I can create only one container for that data and use that to reference the data in each enemy script. That will in turn save memory. Correct?
@CodeMonkeyUnity
@CodeMonkeyUnity 4 жыл бұрын
Yes, although not everything stored in a MonoBehaviour will be duplicated, only value types kzbin.info/www/bejne/gXipcqGtoLRjhs0
@p1no_839
@p1no_839 4 жыл бұрын
Do you think it's a good idea for a beginner to copy code from stack overflow until you learn them?
@CodeMonkeyUnity
@CodeMonkeyUnity 4 жыл бұрын
It's definitely a good idea to use stack overflow to help you solve your problems, but when you find the solution don't just blindly copy it. Instead take the time to understand why it works.
@r1pfake521
@r1pfake521 4 жыл бұрын
Can you make a video about the TreeView Editor with basic editing features (like undo/redo and drag&drop to move the nodes up/down). Or can someone post me a link to some other video which shows these features, because I couldn't find any. Im not even sure about the current TreeView situation because it looks like they will make a new TreeView with the new UIElements API, but im not sure if it is already out or not, because I asked in the Unity forum and they sent me github links which are either dead or private and I didn't get any other answer from them yet.
@gower1973
@gower1973 4 жыл бұрын
So it’s just like a struct or class with just member variables and no methods?
@CodeMonkeyUnity
@CodeMonkeyUnity 4 жыл бұрын
The main point is that it's an asset stored in your project files. It can be used for data but it can also hold logic, you can add any type of functions you want. I'll cover that a bit in the next video when I add Scriptable Objects to the Crafting System.
@mrbananaman8032
@mrbananaman8032 4 жыл бұрын
Yeah, I still don't understand the advantage over the added complexity. I don't understand what problem SO's fix besides being able to let non programmers mess with item stats in the UI or something.
@arcday4281
@arcday4281 4 жыл бұрын
Hello everyone Tell me how to make it easier and more practical: data Exchange between scripts. For example: Get position(). Create a script containing all the others-inheritance - get-set...? Use interfaces for each necessary function ? Or are there other options ?
@CodeMonkeyUnity
@CodeMonkeyUnity 4 жыл бұрын
You could implement an interface, IHasPosition then implement GetPosition() => transform.position That's what I used in some scripts on Battle Royale Tycoon
@arcday4281
@arcday4281 4 жыл бұрын
@@CodeMonkeyUnity Thanks a lot. I'm still surprised by your superpower to respond to all subscribers)) It probably takes so much time...
@davidcalderwood7041
@davidcalderwood7041 2 жыл бұрын
Is it possible to nest scriptable objects? For example I am working on weapon rarity in my game. So would it make sense to have a scriptable object for each type of weapon rarity? Legendary vs Common weapons vs any other rarity. I want all weapons of the same rarity to have certain things in common, like the weapon card and color base. Should those be scriptable objects that I then drag onto each weapon scriptable object? Or what would be the best way to set that up?
@CodeMonkeyUnity
@CodeMonkeyUnity 2 жыл бұрын
Yup you can make a scriptable object to define the rarity and a weapon scrpitable object that has a field for that rarity. That would be a good way to do it.
@anonymoussloth6687
@anonymoussloth6687 4 жыл бұрын
I am using scriptable objects to create different types of guns and store some data about them. Also, I am using your concept from the interface video to make a IGun interface and have a shoot function in it. The only issue now is how do I make scriptable object have a function that is specific to that gun so that in the main game program, i just need to pass a IGun variable and call the shoot function?
@CodeMonkeyUnity
@CodeMonkeyUnity 4 жыл бұрын
That depends on how you handle shooting. Is it spawning a bullet prefab? If so you can store it in the scriptable object. Or do you need to do some complex logic that is not just data? If so then you need to write that code somewhere, maybe do a switch on a WeaponType run that code. It all depends on if you can abstract your shooting logic so that it is fully data driven.
@anonymoussloth6687
@anonymoussloth6687 4 жыл бұрын
@@CodeMonkeyUnity I use raycasts to do shooting and each gun has a different shoot method depending on different logic that is related to their data such as range, fire rate, is automatic, etc. Currently I have a unity event in my scriptable object to which I have linked each of the shoot functions of the gun but I was wondering if there is a better way to do this
@Igor-rd2fb
@Igor-rd2fb 2 жыл бұрын
Greetings. How do I reset ScriptableObjects after each play?
@CodeMonkeyUnity
@CodeMonkeyUnity 2 жыл бұрын
You should never modify them so they should never need to be reset.
@aboukris
@aboukris 4 жыл бұрын
Hi @CodeMonkey I tried to register on your site, the sending configuration email does not work please check
@marushirudesu
@marushirudesu 4 жыл бұрын
Should i use Scriptable Objects when it comes to individual ability of the enemies? or I use Inheritance instead
@CodeMonkeyUnity
@CodeMonkeyUnity 4 жыл бұрын
Both approaches are valid depending on your particular case. do a quick prototype to test both methods.
@marushirudesu
@marushirudesu 4 жыл бұрын
@@CodeMonkeyUnity woah ,thanks brother
@nahulseyon54
@nahulseyon54 4 жыл бұрын
3nd like 3rd view 3rd comment and 3rd party...😆😆😆 Bro how to patch an app using lucky patcher? Plz tell me if any one knows.
@CodeMonkeyUnity
@CodeMonkeyUnity 4 жыл бұрын
That's a pretty complex topic, you should probably let someone else like Steam or the AppStore handle versioning and updates.
@nohypelarx
@nohypelarx 4 жыл бұрын
CodeMonkey: Can I use scriptable objects to change your simple SpriteAnimator animations at runtime. If not how could I dynamically change de sprites that can be played by the SpriteAnimator? Let say i have idle and walk animations for a unit and play them with the simple Sprite Animator from your video but i want to change the sprites of each animation at runtime to show other unit skin
@CodeMonkeyUnity
@CodeMonkeyUnity 4 жыл бұрын
Sure, that sprite animator is just an array of Sprites so you can store the array of sprites in the ScriptableObject and modify the sprite animator to read the array from the scriptableobject instead of its own field.
@nohypelarx
@nohypelarx 4 жыл бұрын
​@@CodeMonkeyUnity I would like to create something similar to what you do in Simple Turn Based RPG of changing the sprites and animations on runtime. Thanks for answering. I really like your tutorials
@osmanpekaydn4070
@osmanpekaydn4070 4 жыл бұрын
I don't understand differance between structs and scriptable objects
@CodeMonkeyUnity
@CodeMonkeyUnity 4 жыл бұрын
A Scriptable Object is an asset that stores data and lives in your project files. A Struct can store data in memory
@watercat1248
@watercat1248 Жыл бұрын
In my opinion scriptable object is just Data based I don't even know why they called scriptable object But i discover recently the nested scriptable object and I'm curious what is the difference and how this new type I will be useful
@giangbuitam4868
@giangbuitam4868 4 жыл бұрын
can i change the data of scriptable objects in run time ?
@CodeMonkeyUnity
@CodeMonkeyUnity 4 жыл бұрын
Yup, but be careful of the issues I mentioned regarding Editor saving vs Standalone saving
@giangbuitam4868
@giangbuitam4868 4 жыл бұрын
Code Monkey how can i change data of them ? I don’t know how to do that
@Alzimovich2
@Alzimovich2 4 жыл бұрын
@@giangbuitam4868 Never used SO, but they are simply scripts with public fields... so I assume SOinstanceName.fieldName = newValue; should do the job.
@nosamyd9474
@nosamyd9474 3 жыл бұрын
im pretty new to unity i mean by this is posted unity isnt even installed yet! gimme some uhhh idk?
@sudhanshlone8284
@sudhanshlone8284 4 жыл бұрын
Is using scriptable objects more performant?
@CodeMonkeyUnity
@CodeMonkeyUnity 4 жыл бұрын
Really depends on the situation. For example if you have tons of duplicated memory in use and you replace that with Scriptable Object references then yes. But in general they are not necessarily more performant by default, it all depends on what you're doing and your implementation.
@shalihrizal9433
@shalihrizal9433 4 жыл бұрын
Well, kinda shocked to see the .ass extension at the thumbnail xD
@CodeMonkeyUnity
@CodeMonkeyUnity 4 жыл бұрын
Oh yeah I guess in some cases the time overlay will obscure the text
@bilbostabbins1882
@bilbostabbins1882 4 жыл бұрын
@@CodeMonkeyUnity mmmmm .ass ets, Liked and Subscribed!
@thehacknologist1692
@thehacknologist1692 4 жыл бұрын
Can you make a game with bolt in unity.
@CodeMonkeyUnity
@CodeMonkeyUnity 4 жыл бұрын
Sure, Bolt is extremely powerful and you can build anything with it
@johnpatrickjuni945
@johnpatrickjuni945 4 жыл бұрын
Pls help me I'm just a student and know very little (almost nothing) about programming can you help me where to start, I'm just starting so pls help.
@CodeMonkeyUnity
@CodeMonkeyUnity 4 жыл бұрын
Learn the Basics of Unity here kzbin.info/www/bejne/e2ekZYqsqKmYgqc And C# Basics here kzbin.info/www/bejne/f3fEqoSfpKxqZ6M
@johnpatrickjuni945
@johnpatrickjuni945 4 жыл бұрын
@@CodeMonkeyUnity thanks
@carlabalos3884
@carlabalos3884 2 жыл бұрын
Thanks!
@kingofgame2762
@kingofgame2762 4 жыл бұрын
Please tutorial for unity particle system 2d and if the video 2 hours I will watch the video
@topievan190
@topievan190 4 жыл бұрын
Indonesia here
@Naufal12948
@Naufal12948 4 жыл бұрын
Why untity not in phone
@zed538
@zed538 4 жыл бұрын
HI there folks
@thg1nrediar
@thg1nrediar 2 жыл бұрын
Thanks
@myelinsheathxd
@myelinsheathxd 4 жыл бұрын
another level of json file😉.......
@JoligonOne
@JoligonOne 4 жыл бұрын
Please Dotween video
@semithegamedeveloper6995
@semithegamedeveloper6995 4 жыл бұрын
i want to become a proffesional indie developer. do you believe me?
@CodeMonkeyUnity
@CodeMonkeyUnity 4 жыл бұрын
Go for it!
@semithegamedeveloper6995
@semithegamedeveloper6995 4 жыл бұрын
@@CodeMonkeyUnity You are best youtuber in world. there is no youtuber answering the comments.
@andylockhart257
@andylockhart257 4 жыл бұрын
Debug.love()
@eduardo-cat
@eduardo-cat 4 жыл бұрын
1 view :0
@daleodorito
@daleodorito 4 ай бұрын
I have seen a bunch of stuff about scriptable objects and... I don't fucking get it. Like why should I save that as an scriptable object instead of a prefab? You save memory and it's supposed to be easier to use? How? I don't get it. Let's say you want to have a bunch of items that just use a "weapon" class, so they have like name, damage and speed. That seems exactly the use case for a scriptable object. But I could just create a Monobehaviour for that and I would save an object with that script and some default data as a prefab. Why it is better to use a scriptable object there? You are just passing by the same amounts of references, you are either searching for a prefab of that script or the scriptable object. I don't see how you are using any duplicate data there.
@CodeMonkeyUnity
@CodeMonkeyUnity 4 ай бұрын
A prefab doesn't define a "type", it defines an "object". So while technically you can do that it's the same thing as how you can hammer a nail with a proper hammer or with your fist. Both will work but you should really use the proper tool for the job.
@Pedro_Marangon
@Pedro_Marangon 4 жыл бұрын
First!
@y01cu_yt
@y01cu_yt Жыл бұрын
Thanks!
How to Craft Items with Scriptable Objects! (Unity Tutorial)
19:46
SCRIPTABLE OBJECTS in Unity
8:57
Brackeys
Рет қаралды 1 МЛН
Мен атып көрмегенмін ! | Qalam | 5 серия
25:41
路飞做的坏事被拆穿了 #路飞#海贼王
00:41
路飞与唐舞桐
Рет қаралды 26 МЛН
What are Interfaces? (C# Basics)
13:54
Code Monkey
Рет қаралды 214 М.
ScriptableObject в Unity на примере информации о сундуках
10:05
Лавка Разработчика
Рет қаралды 20 М.
Scriptable Objects: What are they? How do you use them?
10:38
Be CAREFUL with Scriptable Objects!
8:27
Code Monkey
Рет қаралды 85 М.
What are Events? (C# Basics)
15:05
Code Monkey
Рет қаралды 404 М.
I Made the Same Game in 8 Engines
12:34
Emeral
Рет қаралды 4,3 МЛН
The Ultimate Introduction to Scriptable Objects in Unity
20:45
3 Interesting Ways Scriptable Objects can fix YOUR Unity3d project now!
24:29
Jason Weimann (GameDev)
Рет қаралды 87 М.