How To Use Scriptable Objects in Unity

แชร์
ฝัง
  • เผยแพร่เมื่อ 16 พ.ย. 2024

ความคิดเห็น • 102

  • @IOSAppCrazy
    @IOSAppCrazy 5 ปีที่แล้ว +220

    This is EXACTLY the channel I was looking for. As someone with a software engineering background being able to find concise, straight to the point videos about Unity features I didn't know existed without the pandering "here's how you erm... assign variables... and uh inheritance is a concept where" bs is great. Having these videos should be helpful for those learning too. You could either A: follow along exactly from a tutorial and learn nothing but make it work, or get an idea and learn it along the way, which is what this type of content is geared towards. Great stuff.

    • @tyler7268
      @tyler7268 4 ปีที่แล้ว +2

      Couldn't have said it better myself! These videos are great!

    • @dantescanline
      @dantescanline 4 ปีที่แล้ว +2

      THIS! A thousand times over!!

    • @yourzombiemop8259
      @yourzombiemop8259 4 ปีที่แล้ว +2

      Yes!
      This has been an issue for me tenfold in looking for quality Unity references!
      You said it perfectly 💯%

    • @johndoubleub
      @johndoubleub 4 ปีที่แล้ว +2

      Couldn't agree more, videos that are just like: "this is a thing, this is how its used" Are gold. Now to go and do some experiements with scriptable objects

  • @TheNamesJT
    @TheNamesJT 5 ปีที่แล้ว +136

    would love to see a more in depth tutorial series about scriptable object

    • @enolya
      @enolya 4 ปีที่แล้ว +1

      Same here

    • @dogsareyum1996
      @dogsareyum1996 4 ปีที่แล้ว +1

      Same here

    • @DayOfCasual
      @DayOfCasual 4 ปีที่แล้ว

      @Alvin When you need to reuse a certain data structure in many game objects that can base their behaviour on that set of data. The example was in the video: Different cars with different speeds and accelerations, even sprites or materials.

    • @robosergTV
      @robosergTV 4 ปีที่แล้ว +9

      @Alvin One of the main use cases for ScriptableObjects is to reduce your Project’s memory usage by avoiding copies of values. This is useful if your Project has a Prefab that stores unchanging data in attached MonoBehaviour scripts. Every time you instantiate that Prefab, it will get its own copy of that data. Instead of using the method, and storing duplicated data, you can use a ScriptableObject to store the data and then access it by reference from all of the Prefabs. This means that there is one copy of the data in memory

    • @javonyounger5107
      @javonyounger5107 2 ปีที่แล้ว

      @@robosergTV So let's say you want the same set of stats for all the actors in your game Player and NPC alike, instead of giving each their own stat block you can make a stat block as a scriptable object have each actor reference it and then assign their own values to it.

  • @CausticCatastrophe
    @CausticCatastrophe 2 ปีที่แล้ว

    This is the most concise explanation of scriptable objects.

  • @Adidaas
    @Adidaas 4 ปีที่แล้ว +34

    Oh wow, this sounds crazy useful. Can't believe I never knew about this one before. Here I was hardcoding data into my classes like a fool.

  • @Rand00mThing
    @Rand00mThing 4 ปีที่แล้ว

    I have nothing to do with game development but still... I'm intrigued by all of those guides. They are so fascinating and straight to the point without any bullshit. Such a rare breed of guide, here on youtube out of all places, it's refreshing to look at.

  • @halivudestevez2
    @halivudestevez2 3 ปีที่แล้ว

    This is the best tut about Scriptable Objects. Now I almost understand it.

  • @vizion4724
    @vizion4724 3 ปีที่แล้ว +1

    Can't believe that you don't have more subscribers than this. This channel is absolutely fantastic keep up the good work!

  • @baconchaney
    @baconchaney 5 ปีที่แล้ว +5

    I have to say a big thank you for the examples in this. I'm coming back to Unity after a long break and it's been a great refresher as well as some advice/examples that I've not come across in my previous learning.
    Great job!

  • @RaoulWB
    @RaoulWB 4 ปีที่แล้ว +4

    Wonderful video! It's surprising how much valuable information you were able to cram into 4 minutes. Extremely useful for those who might already know about the subject but don't know the neat more advanced use scenarios like nesting and doing more than just storing variables.

  • @dekosoft
    @dekosoft 3 ปีที่แล้ว

    It took me a while to grasp that a gameObject using SO has to reference it as public, but after inspecting your code I figured it out.

  • @rickloyd8208
    @rickloyd8208 4 ปีที่แล้ว +1

    So sad that such an awesome channel did not get enough attention so the owner would kept publishing more video tutorials, thanks for this one, I will give it a try in real project.

  • @Artistica3D
    @Artistica3D 4 ปีที่แล้ว +1

    great simple and direct intro to the nature of SO

  • @xXTheivesGuildXx
    @xXTheivesGuildXx 4 ปีที่แล้ว

    Bro you are so much more practical and basically like the adult show version of Brackeys I love you

  • @brandons2501
    @brandons2501 4 ปีที่แล้ว +3

    Wow, I only discovered your channel today. You are seriously a Godsend. thank you! all your videos are so clear and concise and the way you edit your videos make it so it's not some boring video.
    Thanks! Subbed :D

  • @DadCodeTrainSleep
    @DadCodeTrainSleep 4 ปีที่แล้ว +2

    Wow, you did a great job explaining this topic I have been struggling with. Thank you.

  • @huyopo
    @huyopo 4 ปีที่แล้ว

    Scriptable Objects can be used for components to talk to eachother if they have the same Scriptable Object.
    Scriptable objects can also hold the logic of a Monobehaviour. Enabling you to share behaviours or quickly change between behaviours without changing the component.
    Using Custom Property drawers and reflection you can make a popup field that shows all scriptable objects that derive from a given base scriptable and automatically creates that objects for you in a defined folder(that also saves you the tedious work of everytime creating an asset menu, even if you just need the object once)
    Scriptable objects also can save Playmode Data (only in editor)
    There are a lot more usecases than just using them as dataobjects, and it's quite a shame that not more people use them or just use them to a limited degree.

  • @JonesSeries
    @JonesSeries 5 ปีที่แล้ว +5

    (new to unity) I would love to see more about Scriptable Objects, I have been thinking of an easy way to add, remove and organize content in a game idea I have.
    Basic idea is that each character would be a scriptable object, all having the same required assets and info, then with a character manager scriptable object would store all of the characters in a single list that would make it easy to set the cost and if the character is visable in the store.
    idk how far this could go, but I could also create a Store manager Scriptable object that connects all of the managers like character manager, weapon manager, banner/avatar manager, etc. this could have even more up level controls like 50% discount on all weapons.

  • @LaCreArthur
    @LaCreArthur 4 ปีที่แล้ว

    Really loved to see so much informations delivered in 4 minutes yet in an extremely chill way

  • @MrTybex
    @MrTybex 3 ปีที่แล้ว +1

    Very concise!! That's good, but I would like to know more! Love your videos.

  • @DJLKM1
    @DJLKM1 4 ปีที่แล้ว

    You should have far more subs, the content is clear, understandable & easy to follow. Thanks.

  • @HuddledEragon
    @HuddledEragon 4 ปีที่แล้ว

    I have been using scriptable object with more of inventory but I've been looking into more of using scriptable object in AI and I will say that from testing it out with AI find it quite interesting.

  • @gavn2185
    @gavn2185 2 ปีที่แล้ว

    I’m currently using Scriptable Objects for a dialogue system in my RPG game! I’ve made a custom editor for them, too!

  • @alidemorg
    @alidemorg ปีที่แล้ว

    Amazing! can we get the code for the audio preview script?

  • @enolya
    @enolya 4 ปีที่แล้ว +1

    Is it possible to have more in depth tutorial for hot topics like Scriptable Object please? Your tutorial videos are so nice thank you!

  • @brodakarat6340
    @brodakarat6340 2 ปีที่แล้ว

    if i have a nav mesh agent with a movement, targetting, health etc scripts attached would it be benificial to make a scriptable object as each unit of the same type and upgrade will behave the same

  • @PsychoGoose
    @PsychoGoose 3 ปีที่แล้ว

    Hi, Thank you for this video, Why do you put "override" in Play at 3:08?

  • @Arcann_bhp
    @Arcann_bhp ปีที่แล้ว

    But what if I want to change health as well? And how do you override the base data?

  • @sommmen
    @sommmen 4 ปีที่แล้ว +2

    looking through the docs i was like wut? but this video gave me a clear overview. Thanks!

  • @DanCreaMundos
    @DanCreaMundos 4 ปีที่แล้ว

    Got here right in time for another amazing video!

  • @shirosurfer8864
    @shirosurfer8864 4 ปีที่แล้ว

    That copy and pasting option so deceptively simple but I forgot about it, wonder full!

  • @mcbvideogames
    @mcbvideogames 4 ปีที่แล้ว

    Don't know if anyone can answer me this, but I just discovered this and I am wondering if you can make custom voids with this. Context: I am making a game where you have a number of Spells. What I did was: Create an abstract SpellBase class, extending Monobehaviour. It shares all the attributes every spell has, such as cost, cooldown, name, description... and an abstract void called UseSpell(). Then, I create other scripts that inherit SpellBase and implement UseSpell(), such as a HealingSpell class, which also adds attributes such as the amount you heal, or a SpeedBuff class, that has a multiplier variable. Then, another script (SpellLogic) gets a list of all existing spells and when certain key is pressed, you cycle through that list and have a certain spell selected. Another key will trigger said Spell's UseSpell() implemented method. Is there anyway for, instead of SpellBase extending MonoBehaviour, it can extend ScriptableObject? Could I even extend both? Can it still be an abstract class?

  • @HAWXLEADER
    @HAWXLEADER 3 ปีที่แล้ว

    Don't nested prefabs make it kinda optional?

  • @sickchain
    @sickchain 5 ปีที่แล้ว +1

    If i make a base scriptable object class and then a sub-class from that one, once the derived class is created in the inspector, changing default values in the base class won't affect the ones in the sub-class already packed in the asset file. Could you explain what you meant by changing health on the base SO and affecting all the derived ones? Just don't see it working that way. It will work but for new created assets.

  • @jackpeterson1909
    @jackpeterson1909 5 ปีที่แล้ว +6

    I want in depth scriptable object. Like enemy character attachment

  • @entertainmentoverloaded5700
    @entertainmentoverloaded5700 2 ปีที่แล้ว

    Thank u very much..nice demonstration

  • @Allan1291
    @Allan1291 4 ปีที่แล้ว

    Thanks for the video it was pretty concise and informative

  • @magnusm4
    @magnusm4 4 ปีที่แล้ว

    So for example if I wanted a player character I not only could add health and damage but also functions for attacks they should all be able to use, and make them virtual, so the script that uses the scriptable object can either use the base attacks or override them.
    But does this mean for example that I must create a scriptable object for every single enemy that should be unique?
    What if you remove a scriptable object from the project?

  • @andershofsten6142
    @andershofsten6142 5 ปีที่แล้ว +1

    Would love to take a look at that whole audio preview thing though.

  • @quantumpanic
    @quantumpanic 4 ปีที่แล้ว +3

    But i've always been using plain old Game Objects for having a "static" data holder! (Like in the race car example)
    I'm still trying to figure out how scriptable obj is superior besides being used as a runtime instantiable script

    • @robosergTV
      @robosergTV 4 ปีที่แล้ว +2

      One of the main use cases for ScriptableObjects is to reduce your Project’s memory usage by avoiding copies of values. This is useful if your Project has a Prefab that stores unchanging data in attached MonoBehaviour scripts. Every time you instantiate that Prefab, it will get its own copy of that data. Instead of using the method, and storing duplicated data, you can use a ScriptableObject to store the data and then access it by reference from all of the Prefabs. This means that there is one copy of the data in memory

    • @jcaique
      @jcaique 4 ปีที่แล้ว +1

      @@robosergTV unless you're making a total war game with hundreds of units on the screen, I doubt it'd make much of a difference.

  • @random_precision_software
    @random_precision_software 4 ปีที่แล้ว

    Yes I would like to use them in my big games in in the middle of..but need more videos on them.

  • @jamesfang8381
    @jamesfang8381 4 ปีที่แล้ว +1

    That sound FX preview thing looked really cool. Would you be able to share the code for that?

    • @Hello-qg4yk
      @Hello-qg4yk 4 ปีที่แล้ว +4

      Didnt he already in the video?

  • @xXNickPXx
    @xXNickPXx 4 ปีที่แล้ว

    What's the difference between a scriptable object, and a prefab'd empty game object with the transform removed and a script slapped on?

  • @kantallive
    @kantallive 4 ปีที่แล้ว

    There will be more about them?

  • @Michael-hj9fx
    @Michael-hj9fx 4 ปีที่แล้ว

    Hmmm, can't you already do this with prefabs though? Would it be better to have the race car stats on a race car prefab?

    • @GameDevGuide
      @GameDevGuide  4 ปีที่แล้ว +1

      Prefabs allow you to store hierarchy structures of game objects you can use elsewhere in your projects. Scriptable objects are best used for easily managing and controlling data structures. They're also a lot lighter to use than GameObjects. So, if you're just trying to store data, there's it's not very efficient or scalable to use GameObjects/Prefabs.

  • @LuRybz
    @LuRybz 4 ปีที่แล้ว

    could I use it with interactables?
    Set different actions, animations, sounds in a single scriptable object

  • @lauch8844
    @lauch8844 4 ปีที่แล้ว

    But i could also simply use a static class to do this, right?

  • @Noztra22
    @Noztra22 3 ปีที่แล้ว

    I've used ScriptableObjects as DAO, to access an SQLite DB as I don't quite like the Unity saving system.

  • @dantescanline
    @dantescanline 4 ปีที่แล้ว +13

    This video: "Put simply, they're a data asset"
    From the unity docs: "A ScriptableObject is a data container that you can use to save large amounts of data, independent of class instances. One of the main use cases for ScriptableObjects is to reduce your Project’s memory usage by avoiding copies of values. This is useful if your Project has a Prefab that stores unchanging data in attached MonoBehaviour scripts. Every time you instantiate that Prefab, it will get its own copy of that data. Instead of using the method, and storing duplicated data, you can use a ScriptableObject to store the data and then access it by reference from all of the Prefabs. This means that there is one copy of the data in memory" ????!?!?!?!?!??! guys

    • @457Deniz457
      @457Deniz457 4 ปีที่แล้ว

      xD

    • @VenusAviation
      @VenusAviation 4 ปีที่แล้ว

      So what's your point? This video explains all of that with a concrete example.

  • @my_namejeff9770
    @my_namejeff9770 4 ปีที่แล้ว

    Better than brackeys. Subscribed

  • @DerClaudius
    @DerClaudius 4 ปีที่แล้ว +5

    Blob's your uncle ^^

  • @muhammadtarek4933
    @muhammadtarek4933 4 ปีที่แล้ว

    SO are amazing for game design but disaster in saving as they cannot be serialized, could you please post a tutorial for that?

    • @davidsanchezplaza
      @davidsanchezplaza 4 ปีที่แล้ว +1

      in my opinion, so contains game design info, is not something you need to adapt for each player. e.g. level of the final boss is always the same for every player, but different than previous subboss.
      if you want to save player progress, you store those variables by serializing

  • @ozanyokuva6930
    @ozanyokuva6930 4 ปีที่แล้ว

    Inspiring , but there is an issue about how you handle the audiosource on scriptable objects with editor scripting. You need a live object with audiosource to play the sound even in editor mode. You are creating the object but there is no evidence that you are handling it later or destroying after the playback , which I could not make yet. Sound part is just thrown in but not explained properly . Can you please open it up alittle.

  • @SunnyOst
    @SunnyOst 4 ปีที่แล้ว +1

    So it's just a script that has everything static by default?

    • @SunnyOst
      @SunnyOst 4 ปีที่แล้ว

      Actually, wait.. If you have to assign a reference to this object, it's not even static. Just a script that doesn't need to sit on an empty gameobject in the scene? Not sure if it adds anything really

  • @anntakamaki1960
    @anntakamaki1960 ปีที่แล้ว

    Where’s the music from?

  • @Atulkumar-sz6tg
    @Atulkumar-sz6tg 4 ปีที่แล้ว

    Amazing tutoring

  • @fatiherolmuhendislik
    @fatiherolmuhendislik 3 ปีที่แล้ว

    Thanks a lot

  • @alchemist_dk
    @alchemist_dk 4 ปีที่แล้ว

    This is so cool, thanks for the info.

  • @mehmedcavas3069
    @mehmedcavas3069 4 ปีที่แล้ว

    Please use them and show them more :)

  • @d1a9n8a8
    @d1a9n8a8 4 ปีที่แล้ว

    thank youuuu

  • @kannpai
    @kannpai 3 ปีที่แล้ว

    Really feels like scriptable objects properly split up the Components and Systems for ECS

  • @danamuise4117
    @danamuise4117 2 ปีที่แล้ว

    Before they had this we used json text file to store the data

  • @v-sc3bc
    @v-sc3bc ปีที่แล้ว

    감사합니다.

  • @CraftBasti
    @CraftBasti 4 ปีที่แล้ว

    Why didn't you show how to do the inheritance of scriptable objects? This would have been the most interesting in the video

  • @Lumord
    @Lumord 5 ปีที่แล้ว

    Thanks!

  • @amiya_s
    @amiya_s 4 ปีที่แล้ว

    This seems similar to prefab variant in many ways.

  • @tomtomkowski7653
    @tomtomkowski7653 3 ปีที่แล้ว

    If only SO could keep data when the project was build and not only in RunTime mode in the Editor :/
    Yeah, I know... just store the data in the file and let SOs read them when a game is starting...

  • @Amar-lv1yw
    @Amar-lv1yw 3 ปีที่แล้ว

    So simply said: scriptable Objects can be used when many objects behave completely the same, right?

  • @mohit8773
    @mohit8773 4 ปีที่แล้ว

    Nice video

  • @cuttlas2955
    @cuttlas2955 4 ปีที่แล้ว

    hey , thank u ,

  • @Popart-xh2fd
    @Popart-xh2fd ปีที่แล้ว

    The source code isn't available anymore!

  • @F0r3v3rT0m0rr0w
    @F0r3v3rT0m0rr0w 4 ปีที่แล้ว

    So ... They are like ... Visual Lists ?

  • @DoubleRaw
    @DoubleRaw 4 ปีที่แล้ว

    So just public class data with a prefab instance. I think I will never use them.
    Speed, health, attack, damage are public values in your class. Just make a new instance and then a prefab of it. Same problem solved.

  • @chigonzales6824
    @chigonzales6824 5 ปีที่แล้ว +1

    Why I can't download this awesome video for offline viewing :(
    Anyways good explanation! 🙃

    • @Marcusvcbr
      @Marcusvcbr 5 ปีที่แล้ว

      you can before que youtube on the link in you browser, just put a ss, like ssyoutube...

  • @turoreal
    @turoreal 4 ปีที่แล้ว

    Why do they always put complicated code on their scriptable object tutorials? :( it confuses the hell out of me.

  • @SnaveSutit
    @SnaveSutit 4 ปีที่แล้ว

    Blobs your uncle.

  • @zipzorp8858
    @zipzorp8858 4 ปีที่แล้ว

    A bit fast. There's people who don't understand what this is.

  • @foundev
    @foundev 4 ปีที่แล้ว

    too fast

  • @RiorXD
    @RiorXD 4 ปีที่แล้ว

    3:34 yikes on the repeated code.