SCRIPTABLE OBJECTS in Unity

แชร์
ฝัง
  • เผยแพร่เมื่อ 2 ม.ค. 2018
  • When making a game you need a good way of storing data. This is where Scriptable Objects come in! In this video we’ll learn how to use them by looking at an example: Making cards for Hearthstone.
    ● Project on GitHub: github.com/Brackeys/Scriptabl...
    ❤️ Donate: www.paypal.com/donate/?hosted...
    ····················································································
    ► Join Discord: / discord
    ♥ Subscribe: bit.ly/1kMekJV
    ● Website: brackeys.com/
    ● Facebook: / brackeys
    ● Twitter: / brackeystweet
    ········································­­·······································­·­····
    Edited by Sofibab & LeBonques.
    ········································­­·······································­·­····
    ► All content by Brackeys is 100% free. We believe that education should be available for everyone.
    ❤️ Donate: www.paypal.com/donate/?hosted...
    ········································­­·······································­·­····
    ♪ Baby Plays Electro Games
    teknoaxe.com/cgi-bin/link_code...
    ♪ Funin and Sunin Kevin MacLeod (incompetech.com)
    Licensed under Creative Commons: By Attribution 3.0 License
    creativecommons.org/licenses/b...

ความคิดเห็น • 1K

  • @Blackthornprod
    @Blackthornprod 6 ปีที่แล้ว +640

    A fantastic tutorial ! Short, down to the point, funny... each video always feels fresh and interesting ! Cheers :) !

    • @codewaffle1138
      @codewaffle1138 3 ปีที่แล้ว +7

      Hi Noa! Love your channel and I agree. This tutorial was great. Brackeys never disappoints.

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

      Second Comment

    • @goblinslayer6375
      @goblinslayer6375 3 ปีที่แล้ว +2

      Ur mom gay

    • @facelessanon
      @facelessanon หลายเดือนก่อน +1

      Hello Noa or Liam! Your channel has immensely inspired me to work hard on my game development endeavors. I love your pass the game videos!

  • @galileemason8813
    @galileemason8813 ปีที่แล้ว +110

    For anyone wondering, you can also reference text mesh pro objetcs (with "using TMPro;") then declaring the text as TMP_Text instead of Text;

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

      Thanks! I was just about to ask that

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

      Just got back to developing and was stressing how to do this. Thank you

    • @NayyarAbbas-sh1vw
      @NayyarAbbas-sh1vw ปีที่แล้ว +2

      Or also :
      using TMPro
      and
      public TextMeshProUGUI text;
      in some cases

    • @monkeyrobotsinc.9875
      @monkeyrobotsinc.9875 5 หลายเดือนก่อน

      I bet TMP Pro was designed by the same genius who made the new input system. what a kewl guy. he should be promoted. to janitor.

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

    - "I hope you guys had an happy new year"
    Me: Oh, this video is recent
    - "and I'm looking forward to an happy 2018"
    Me: ...

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

      And we are here in 2020.

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

      Same

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

      @@dsfmdiya7500 I can relate

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

      you know it's not recent when the mic is on screen. Rip mic.

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

      @Scryptol :thinking:

  • @goehlergamedev
    @goehlergamedev ปีที่แล้ว +92

    Asbjørn, your tutorials are still the top grade, even now, several years after you've stopped. 😊

  • @Copybook
    @Copybook 2 ปีที่แล้ว +48

    Everyone told me that the scriptable objects are pretty hard to learn. But as always you made it much easier to understand and implement. You are life saver, man. Thanks

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

      They are basically models. Don't know why unity gave them a different name and treated them as a new feature. It's baked into c# (and any other OO languages)

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

      Can you explain how this would be used in a game? You can't go writing a new method for every single card you want to display. How do you reference the SO in code?

    • @MrMarans
      @MrMarans 3 หลายเดือนก่อน

      ​@@Kathayne636late comment, but you can always at least go with a switch case of the name of the card.
      So switch (name"):
      Case "Minions": doMinionFunction();
      Break;

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

    Whenever I need help with anything unity-related, it turns out Brackeys already did that specific thing. Thanks Brackeys!

  • @gregburks9328
    @gregburks9328 6 ปีที่แล้ว +32

    I love how quick you teach a subject. I see other tutorials on subjects like this that people spend an hour teaching. I am usually not looking to spend an hour learning a new piece of Unity, unless it really deserves it. But what you get across in under 9 minutes is perfect! Keep the videos coming.

  • @Jabrils
    @Jabrils 6 ปีที่แล้ว +195

    aha whoa. What great timing, I just started working on a card game prototype & never knew how to use Scriptable Objects, now I am debating if I should use this or JSON... or both!? 😦 THANKS BRACKEYS!

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

      Jabrils oh damn this is the real Jabrils

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

      Hey you, Yes you .

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

      I recommend using nothing other than brackey's save and load system tutorial for your saving. (Just search it up).

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

    This is blowing my mind! I can't wait to test this out in some of my own projects. Had no idea this was a thing you could do.

  • @dcircuit8518
    @dcircuit8518 6 ปีที่แล้ว +2

    You made scriptable objects amazingly simple to understand. I love your tutorials! Simple and too the point with relevant examples. Thank you for the amazing work you do!

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

    Ohmygod, this took me months to figure out and this video has months of my experience compiled into 9 minutes. I no joke made the exact same project, with the same class names. I wish i just watched everyone of your videos before I ever touched a keyboard 😭

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

    It's amazing how much value can one pack in 9 minutes. Thank you!

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

    This is honestly one of the most helpful tutorials you've made so far! Now that I know what I can do with scriptable objects, my life will be sooooo much easier!!!

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

      Yeah, I felt like this was something really important that I learned lol

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

    I have never ever even heard of this before and I’m already thinking about the possibility’s! Thanks brackeys

  • @NebulaCoding
    @NebulaCoding 6 ปีที่แล้ว

    Perfect timing on this for me. I was just looking into scriptable objects the other day and I wasn't sure if I had fully understood them. I definitely do now! I'll be using these for the shop in my current project. Thanks for the great video!

  • @MrUgleh
    @MrUgleh 6 ปีที่แล้ว +3

    As someone that used to get paid to produce programming tutorials on Tuts+ I have to say your screencasting is top notch. Its amazing you can even do it live. I'd have to go through a script and just do different takes if I make a mistake.

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

    Seriously this guy is the man. Explains concepts in a straightforward manner.

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

      we wish him the best...

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

    Please more tutorials on ScriptableObjects! Maybe you'll show us some advanced features and techniques to use them? For example it's non obvious for me how to actually code those cards so they will behave differently from each other in actual gameplay
    And yes thanks for your tutorials, I watch you for a long time and I LOVE your straight and fast delivery of information. Though you usually don't go as far as we need it, just scratching the surface

  • @Crisisdarkness
    @Crisisdarkness 6 ปีที่แล้ว +1

    This knowledge is really powerful, and I feel that many programmers are not using it within Unity, thanks Brackeys, you are the best instructor.

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

    Brackey so many years after, you’re still saving my life (currently building a card/ only ui game) THANK YOU

  • @sparrowhawk81
    @sparrowhawk81 6 ปีที่แล้ว +60

    I'm not sure what version of C# you're using but string interpolation is really useful for showing #s as text. You can do stuff like: Text.text = $"{numberVariable}"; You can even add stuff like :F2 after the number value or variable name to specify decimal places. It makes forming strings that have placeholder variables in them really nice looking. For example: Debug.Log($"{itemName} costs ${itemCost:F2}." as opposed to a bunch of concatenation or the old style where you include variables as parameters to some function.

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

    I was thinking on how to do enemies for a rpg, and remembered this video. Seems to be working perfectly, so thanks!

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

      lol exact same here

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

      Exact same here just for different characters

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

    i spent all day watching videos on scrriptable objects, this is by far the easiest and clearest. thank you so much!

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

    Thank you so much. I have been trying to learn about SerializableObjects for a few days now and this is the best thing ever! Clear and concise. Thank you!

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

    0:18 The subtitle "Heavenly Choir" made me giggle a bit :D

  • @thebeastypriest
    @thebeastypriest 6 ปีที่แล้ว

    Great tut! I've been wanting to learn S.O's for a while. Thanks for making it approachable!

  • @JMiguel12
    @JMiguel12 6 ปีที่แล้ว

    I was just now searching how to define the properties of a scriptable object on a game object or if you can instantiate a scriptable object - Android notification: "Brackeys uploaded SCRIPTABLE OBJECTS". I've made use of your videos before but this time is a new level of professionalism. Good job and keep it up!

  • @Gathrey
    @Gathrey 6 ปีที่แล้ว +20

    BEST game dev tutorial creator on youtube!

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

    I wish I knew about this a year ago when I was trying to make an rpg battle system.

  • @ivanturtle9384
    @ivanturtle9384 2 หลายเดือนก่อน +1

    this guys S tier material, literal genius and he gives it away for free

  • @morphyngames
    @morphyngames 6 ปีที่แล้ว

    Happy new year to you too, thank you for the tutorials and hopefully your year will be blissful and filled with goodness

  • @Justin113D
    @Justin113D 6 ปีที่แล้ว +42

    *looks at my current item system*
    *shoves everything down from desk*
    welp, time to update this shit
    Great video btw, helps me a lot :D

  • @nikolacvejic6550
    @nikolacvejic6550 6 ปีที่แล้ว +3

    I think dat everybody want to see you making new series for making card game like hearthstone or yugioh

  • @nathanajhar8359
    @nathanajhar8359 6 ปีที่แล้ว

    Excellent video, thanks! I had watched the Unity made tutorial on scriptable objects a couple of times and followed that, getting a few pieces I understood. But now after watching your video, I actually understand scriptable objects instead of just getting components working without the needed knowledge to adapt it to my development needs, and your video is like 10x shorter!

  • @Definitely_a_Fox
    @Definitely_a_Fox 6 ปีที่แล้ว +2

    This is overpowered!!! Thank you for gifting us with this beautiful knowledge!!!

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

    I wonder how this is affected by the new ECS scripting system.
    And how well would it be to use structs in scriptable objects when making new guns and such?

  • @toasted2262
    @toasted2262 6 ปีที่แล้ว +160

    Make a tutorial on how to say in the best way possible that BRACKEYS IS THE BEST.

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

      Make a donation, or talk about him to your friends, and so on

    • @Malicos
      @Malicos 6 ปีที่แล้ว

      Mr.K We will need several tutorials each one of those things

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

      That's a fact!

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

      Use the UI functionality and emission based materials ( if materials are in unity)

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

    I've just watched two videos about Scriptable Objects, including the official 1 hour long Unity video on their website, and they both just hurt my brain. You explained this so well, I'm going to be checking out the rest of your videos for sure. Thanks!

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

    A bit late to the party here, but awesome video!
    Really great information here for a beginner!
    I've been subscribed for about 2 weeks now, and I've been going through all the old content. I've learned so much already!

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

    more than his coding skills in general I'm more scared that Tirion is 6 mana 6/8..

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

      I was like woah, Edwin is weak. Than I was like woah Tirion is OP, must Nerf.

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

      @@MrSirFluffy you dont play hearthstone, do you :P

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

      @@Hoichael I play lots of Heartstone, a 6 mana 6/8 is off the power curve. A 3 mana 3/2 is under the power curve.

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

      @@MrSirFluffy I was referring to Edwins card text. I know that the cards in the video are only supposed to be examples and not represent the actual cards they are based on, but Edwin (who's a 3 mana 22) is bc of his text one of the most powerful cards in the game.

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

      @@Hoichael Im aware, im reffering to the video version.

  • @Stevey_B
    @Stevey_B 6 ปีที่แล้ว +23

    thanks M8

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

    Been looking at a lot of camera tutorials for Unity, this is so far the best by far. You explain things well, and the camera mechanics are more advanced and better coded.

  • @Schpok
    @Schpok 6 ปีที่แล้ว

    Excellent video, vero pro. I was looking for a good explanation of ScriptableObjects, now it's done. Good job !

  • @Hamentsios10
    @Hamentsios10 3 ปีที่แล้ว +30

    I have a few questions this is great information and all all much appreciated but I want to know for example if I want to make a 2d game will the enemy NPCs derive from a scriptable object and how exactly am I going to organize their information and their functions as a monobehavior or as a scriptable object? Also another question by the way can I change color of some specific sprite image layer through code?

    • @hudademirtas3144
      @hudademirtas3144 3 ปีที่แล้ว +2

      He cant answer this question look at his Last video

    • @Hamentsios10
      @Hamentsios10 3 ปีที่แล้ว +8

      @@hudademirtas3144 I know.. im just asking to anyone who might answer. And the fact that they won't make new videos doesn't mean they will never answer to comments. It's always possible.

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

      @@Hamentsios10 they left the channel ther are not lookşng at comments anymore

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

      @@hudademirtas3144 Understood, then anyone else who would see it will do.

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

      @@Hamentsios10 About the Sprite changing color via code, what you can do is get a reference to that image, then use this command,
      sprite.color = new color(r, g, b, alpha);
      Here, r g b means red, green and blue. If you see a pixel, it is composed of these colors and from them, we get different colors by changing the saturation, hues, contrast or something which is not important to know. And alpha is the level of opaqueness or transparency, of the color.
      And the question about enemy NPCs, to manage the data, which would be a lot, so better idea would be to use ScriptableObject, as if you would want to make any changes to them.in the future, it would be modular and so, east to work with. It's a very powerful stuff for Unity. Using game manager like Singletons or Toolbox are sometimes tedious, if the scale of the game is BIG. So, better to get better with ScriptableObject.
      I am a beginner, and still learning, and that's what I came up with after doing some research.
      ScriptableObject makes your game manageable, modular (object oriented paradigm friendly) and easy to make changes when in the future if we need to, without much refactoring.
      Hope that helped a little.

  • @CrunchyPie
    @CrunchyPie 6 ปีที่แล้ว +3

    Can you please make a tutorial on Easy Save or perhaps make a script or tutorial about how to save your games! By the way,thanks for helping i always support the brackeys team!

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

    An excellent tutorial. Easy to follow. One of the best explanations I've seen on the topic of scriptable objects. 👍

  • @DexterDLopez
    @DexterDLopez 6 ปีที่แล้ว

    I love Scriptable Objects! It's crazy how this video comes out around the time I'm looking up more info on SO!

  • @Krifix
    @Krifix 6 ปีที่แล้ว +395

    Pause at 0:00 xDDD. I love learning from you. ;)

    • @HelpingPanda
      @HelpingPanda 6 ปีที่แล้ว +28

      Learning*
      Teaching is what the teacher does, learning is what the student does. :)

    • @Krifix
      @Krifix 6 ปีที่แล้ว +27

      Erk thanks. I'm from Poland so I'm not Perfect with English. Really thanks.

    • @nomomon
      @nomomon 6 ปีที่แล้ว

      Krifix! Ui

    • @samzgadnij
      @samzgadnij 6 ปีที่แล้ว +1

      Polish language isn't very complicated at all, it is incredible embroiled. The best example with a word "read". We have like 40 or even 60 versions :P
      BTW. The best channel to learn for me at this moment, THANK YOU very much!

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

      Compared to English, many languages are complicated.

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

    5:30 I die a little inside each time I see a space between the function name and parenthesis

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

      true

    • @Gamer-uf1kl
      @Gamer-uf1kl 4 ปีที่แล้ว +6

      I always do that

    • @Gamer-uf1kl
      @Gamer-uf1kl 4 ปีที่แล้ว +2

      @@shinryusaiha i mean auto correct does that to me and i dont care changing

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

      @@Gamer-uf1kl you can change that in VS settings, as well as other similar settings

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

      @@shinryusaiha Does it causes any issues?

  • @shadoninja
    @shadoninja 6 ปีที่แล้ว

    Very useful info! This is why I browse your channel. You teach me things I didn't even know I wanted to know!

  • @lewisbirkett4428
    @lewisbirkett4428 6 ปีที่แล้ว

    Very nice, looked at a few scriptable object tutorials but this makes it easy to understand

  • @holmbergen
    @holmbergen 6 ปีที่แล้ว +20

    Great start for 2018! ScriptableObjects are saints sent from Unity heaven!
    I use SO's to keep information about weapons, weapon lists, weapon attachments, ammunition, sounds, configuration setups, localization (very basic though), powerups.
    But the best thing is I have float variables that I can easily change to change how e.g. a weapon handles its recoil. I highly recommend watching Ryan Hipples Unite Austin 2017 talk (link: th-cam.com/video/raQ3iHhE_Kk/w-d-xo.html)!

    • @MrKraignos
      @MrKraignos 6 ปีที่แล้ว

      Yep great for own organization, and even better to allow artists and designers to add and change content themselves while you're busy adding new features or smashing those bugs =)

    • @adamz6580
      @adamz6580 6 ปีที่แล้ว

      How do you store and assign values like sounds that would normally be components? Brackeys only shows how to assign child gameObjects, not components :|

    • @MrKraignos
      @MrKraignos 6 ปีที่แล้ว

      You simply declare in your ScriptableObject an AudioSource property for example. Unity will correctly display default components in the editor, and you can even write your own editor override to serialize custom components likeyou wish. But not sure I understand well your problem honestly so sorry if that does not answer your question, feel free to ask again..

    • @promant6458
      @promant6458 6 ปีที่แล้ว

      Eu Jeen It's simply much faster

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

      Thanks a lot for sharing this Unite talk. * opens scriptable third eye *

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

    Yeah... Thank you very much for the information. It looks like everyone talking about Scriptable Objects take the "lazy" approach of plugging the reference for the object assets manually directly in the inspector. What about if the card is created at run-time and you don't have the possibility to drag and drop that asset in? Can you reference an Scriptable Object from the assets folder (without using the Resources.Load, since Unity discourages its use)?

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

      Hey Gerardo!
      I am just after the same thing, if you can change the object attributes runtime based on user input. Lets say change the artwork based on the user input.
      Have you figured it out?

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

      Same thing here. Even with using Resource.Load I can't figure out the correct type for loading the created assets. Resources.Load("xyz.asset"); would come naturally to me, but there is no type Script allowed.

  • @guilleacq
    @guilleacq 6 ปีที่แล้ว

    Wow, thank you for this brackeys. I always wait for your content, it's amazing

  • @Rose-ez9vf
    @Rose-ez9vf 3 ปีที่แล้ว

    JavaScript programmer here starting with Unity... was super excited to see this video!!! I personally think objects are one of the best things in coding, so glad they are so easy in Unity!!!

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

    But how would i make it that each card does something special on the board, like edwin damaging all enemie cards when he is played but tirion destroying a random card

  • @antonwyrowski5006
    @antonwyrowski5006 6 ปีที่แล้ว +110

    Hey can you make a video about how to optimize a Game for mobile devices (Canvas Scaler)?!

    • @YasserSedrati
      @YasserSedrati 6 ปีที่แล้ว +7

      +1

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

      I recommend Unite Austin's video about writing high performance C# scripts - th-cam.com/video/tGmnZdY5Y-E/w-d-xo.html

    • @seifmustafa2004
      @seifmustafa2004 6 ปีที่แล้ว +1

      +1

    • @mr_wormhole
      @mr_wormhole 6 ปีที่แล้ว +1

      +1

    • @ashirali8041
      @ashirali8041 6 ปีที่แล้ว +1

      +1

  • @jasiekthejester7764
    @jasiekthejester7764 6 ปีที่แล้ว

    Yeah, the angelic choir singing was totally appropriate for this tutorial as it is AWESOME!!! Great tip and lesson Brackeys! Thanks a million!

  • @mattsponholz8350
    @mattsponholz8350 6 ปีที่แล้ว

    BRILLIANT! Thanks for doing a Scriptable Objects Vid, Sir :]
    Seriously, that was the simplest and most direct video I've watched on this xD

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

    7:30 music starts playing. It scared the shi* outa me.

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

    I would like to hear about implementing complex skill interaction logic rather than just basics on organizing data members.

  • @YannSchmidt
    @YannSchmidt 6 ปีที่แล้ว

    I love Scriptable Objects ! I watched a video about those from the Unite Austin 2017 conferences. And it was awesome. Gave me so much idea to work with Scriptable Objects. So now, I'm just waiting for the Unity 2018 releases with C# Jobs, ECS in Scripts and some more stuffs to be fully operational !

  • @xdboterham
    @xdboterham 6 ปีที่แล้ว

    Dude, you honestly helped me so much. For two hours straight I tried to create a scriptable object (using code instead of the unityUI). This is way more convenient.

  • @Butterbroetchen
    @Butterbroetchen 11 หลายเดือนก่อน +3

    and another time the Unity god safed me 100 hours of my life :D

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

    Hello, Is there a way to put the ScriptableObject in Array? Instead of manually assigning ScriptableObjects in the screen how about you get a randomizer and those ScriptableObjects in the array and let the randomizer choose?

  • @klikfusion
    @klikfusion 6 ปีที่แล้ว

    Brilliant as always. You are the best on TH-cam for learning Unity. :)

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

    Wow, I was just learning about scriptable objects and you made a video about it only 2 years ago! What a coincidence!

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

    Me: haha I'll just make Monobehavior variables
    Unity: you can't serialize Monobehavior
    Me: BRACKEYS HELP

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

      just make the game object into variable and give it the monobehaviour.

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

    How would you do to execute different things for each Card?

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

      Make an abstract class of "CardEffect", Give CardEffect an abstract method of ActivateEffect( );
      Create all the Effects you want, as sub-classes (extend to CardEffect), then define the ActivateEffect( ) method for each different sub-class
      Add the CardEffect class into the Card like he did for cardName, damage, health, and etc, as a variable
      Then just drag and drop in whatever CardEffect sub-class you require for your various ScriptableObjects, like he did for the different Sprite images for the card
      ---
      If the above doesn't make sense, lookup how to use abstract classes, and everything will begin to make sense.

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

      @@kserra9112 i know its been 7 months but thank you this helped me a lot

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

    i don't normally like youtube videos, even if i like them. Brackeys is an exception. Always with quality content. so helpful

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

    Great guide thank you so much, really taught me a lot as a noob to unity, I have 1 question however, at 8:08 you mention that you can easily update these scriptable objects while the game is running, because you are just swapping out simple informaton.
    I can see this to be true myself, as I can drag and drop a new scriptable object into the field in the editor while the game is running, and I can see it update instantly. (Using OnValidate() )
    My question is, how can I achieve this with script, so that I do not have to drag and drop?
    I would like to create a UI button that the user (who does not have editor access) can click, and have the object updated to show a new image. I am sure this is very simple to achieve, but as a total noob I have been having some real trouble finding the proper syntax to write this. I would be very grateful for any help you or anyone reading this can provide, thanks again for the great vid!!

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

      Did you figure this out already?

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

      @@suldra915 Did you in turn figure this out?

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

    can i please use those "aww" sounds at the beginning in a game

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

    That offers some interesting possibilities. I have to try it. Great video as usual 😀

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

    Great Video.
    I watched many videos to understand this concept, but this video is the best.

  • @mikhailchetverkin5722
    @mikhailchetverkin5722 6 ปีที่แล้ว +3

    But what about unique properties of each card? How would you implement it with scriptableObjects?

    • @mikhailchetverkin5722
      @mikhailchetverkin5722 6 ปีที่แล้ว

      László Juhász so, basically you'll still need to create a script for every card that has some unique properties? I thought that maybe scriptableObjects had a better way of handling it but thanks!

    • @sh0ker
      @sh0ker 6 ปีที่แล้ว

      Creating a class for each unique card is not recommeneded and will probably won't work well as you add more cards in the future. Instead try to create classes for effects and reuse them on cards (like drawing, dealing damage, healing and so on)

    • @mikhailchetverkin5722
      @mikhailchetverkin5722 6 ปีที่แล้ว

      I thought about that already but still, look at the hearthstone, there are so many cards that have unique effects that you can't really reuse

    • @sh0ker
      @sh0ker 6 ปีที่แล้ว

      Is it really that many though? yes some cards really do have unique effect that only they can use and no other card can but when you think about it it's only small portion of the cards, most cards are using the same effect and even cards with more than one effect you can just have a queue of effects that will execute in order

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

      +Mikhail Chetverkin You are trying to solve a problem that has nothing to do with ScriptableObjects.
      A ScriptableObject holds information that is relevant to its GameObjects implementation behavior. That is it.
      What you want the GameObject to do beyond that point (of what is can do within its lifetime) depends on what you give it.
      Create all the UniqueProperty sub-classes you need, then...
      Give each Card the ability to hold a List and define the call requirements of this
      ---
      Again the ScriptableObject will not only allow you to inject this behavior into the Object at runtime, but also edit the injection of data within the Unity Editor.

  • @leonardogomes907
    @leonardogomes907 6 ปีที่แล้ว +10

    What's the difference between this and making a prefab for each card and changing its values in the prefabs?

    • @prenomnom2253
      @prenomnom2253 6 ปีที่แล้ว +2

      Leonardo Gomes he answered your question in the first 16 seconds

    • @leonardogomes907
      @leonardogomes907 6 ปีที่แล้ว +2

      prenom nom He didn't really answer it. Why this may cause errors or is incovenient?

    • @D_RockBottoms
      @D_RockBottoms 6 ปีที่แล้ว +10

      The biggest difference is that prefabs also have transform and gameobject data on them which is not needed if the object is only used to store persistent data. ScriptableObjects are created just for that purpose and have alot less overhead.
      Also, if you change a scriptable objects parameters during runtime. The changes will be saved and not lost when you exit play mode and that is very helpfull for designers

    • @leonardogomes907
      @leonardogomes907 6 ปีที่แล้ว +3

      Haim David Thanks!

    • @KhashayarJan
      @KhashayarJan 6 ปีที่แล้ว +3

      Thanks a lot for the explanation!

  • @LetYourMindPlay
    @LetYourMindPlay 6 ปีที่แล้ว

    I wish I could thumbs this up multiple times. Awesome job at explaining this concept!

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

    I could not wrap my head around this topic when I first used them while following MisterTaft's Zelda-like tutorials. I finally get it now. Thank you so much!

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

    Would be cool if he expanded upon this and showed us how to add cards to a deck and then once you purchase the deck with ingame currency or real money you click it and it randomly picks 3 cards based on rng....

    • @DefinitelyAPotato
      @DefinitelyAPotato 2 ปีที่แล้ว +1

      Should be easy to figure out. A deck of cards is just going to be a List of cards. Pick 3 cards- just random range between 0 and deck length 3 times, being sure to remove the picked card from the List each draw.

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

    Would it be possible to display the information about the card in the editor as well? Not just when you run the game

    • @JanTuts
      @JanTuts 6 ปีที่แล้ว

      MegaMiley (I'm just commenting to get updated on the answer)

    • @StereoPT
      @StereoPT 6 ปีที่แล้ว

      Yes there is.
      You use Start for when the Game Starts. However you can create a Script that extends from the Editor to Update it when the information changes.

    • @azizgassara2399
      @azizgassara2399 6 ปีที่แล้ว

      Editor Script ;)

    • @AnthelmeDumont
      @AnthelmeDumont 6 ปีที่แล้ว

      MegaMiley just add "[ExecuteInEditMode]" above your class : docs.unity3d.com/ScriptReference/ExecuteInEditMode.html

    • @darkbibni
      @darkbibni 6 ปีที่แล้ว +1

      Or the "OnValidate" method as I say in an another comment ^^

  • @ToniPlays_
    @ToniPlays_ 6 ปีที่แล้ว

    Great! Keep teaching us. I have really liked the tower defense series past days.

  • @yuk_simhyeon
    @yuk_simhyeon 6 ปีที่แล้ว

    This is amazing!!! I have been searching ways to make database and I was just about to search about XML things. I think scriptableobject is waaay better. Thanks for great video!!

  • @JosephChancey
    @JosephChancey 6 ปีที่แล้ว +134

    I like to imagine that the people over at Blizzard watched this and said "Why didn't we think of that?" and immediately went hard at work to changing their setup of the game xD

    • @Codetrix
      @Codetrix 6 ปีที่แล้ว +90

      Captain obvious here - they already have even more advanced setup of how they store card info. In fact the card designers are provided with tools of their own to edit card data without ever getting involved with Unity (game part)

    • @JosephChancey
      @JosephChancey 6 ปีที่แล้ว +48

      You took a joke too seriously

    • @Codetrix
      @Codetrix 6 ปีที่แล้ว +124

      I know it was a joke and you will comment with "took it too seriously", that's why started with "Captain obvious here" implying I know it was meant to be as joke.
      Still shared the info since it fits in well with the video.

    • @Malicos
      @Malicos 6 ปีที่แล้ว +23

      Gotta give the thumbs up to Parveen on this one. The cap'n is right all around.

    • @Fiilis1
      @Fiilis1 6 ปีที่แล้ว +3

      You forgot to mention that Ben Brode is laughing hard while copying the script. Lol

  • @Emil.Nilsson
    @Emil.Nilsson 6 ปีที่แล้ว +9

    How do you recreate the mechanics of a boat in Unity? And can you show us a easy way to save things like positions and the progress in the game!

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

      I am not the best in programming, but maybe just saving the Transform of a object in an variable. An progress you can handle, what i can think of:
      1. In an rpg you save the complete number of quests in a variable and the number of completed quests also in one an use simple math to calculate the percentage, or
      2. you use an array of zones -> you go trough one and the counter for passed zones goes up.
      All in all i think it is not that difficult. Bit in terms of the boat i cant help you, im to bad for this

    • @razveck
      @razveck 6 ปีที่แล้ว +1

      Emil Nilsson There are good tutorials for boats/water online. There are also some free packages you can download and see how they did it

    • @jdib
      @jdib 6 ปีที่แล้ว +2

      I'd suggest you look into PlayerPrefs in Unity. It's far from elegant, but it's a great & super-simple way to save game progress!

    • @mateboer8779
      @mateboer8779 6 ปีที่แล้ว +1

      1. Create a plane for the water, trigger collider. 2. Create a boat out of very primitive objects, and add a rigidbody. 3. Write a script, that estimates the how much of the boat's bulk is under the water (in cubic meters), and add force to the boat scaling with the estimated bulk. 4. Adjust rigidbody mass, drag, angular drag and the force you add, and maybe add a little randomized force. Here u have a boat.

  • @jeanprofite4341
    @jeanprofite4341 6 ปีที่แล้ว

    Best quality game development tutorials on everything from Unity !!!!

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

    Nicely Done! i love learning from you. you motivate me, I was going to shift to web due to recession in game dev field in my country but i am staying because of you. Because i know game dev is Awesome!!!!

  • @toasted2262
    @toasted2262 6 ปีที่แล้ว +35

    Can you make save games using ScriptableObjects?

    • @toasted2262
      @toasted2262 6 ปีที่แล้ว

      Ok thanks :)

    • @Blind56
      @Blind56 6 ปีที่แล้ว +2

      No, you can't. you're not able to modify the data at runtime

    • @bigjiggly7490
      @bigjiggly7490 6 ปีที่แล้ว +9

      To save data I use Binary Formatting.
      Here's a quick run through on the MS website: msdn.microsoft.com/en-us/library/system.runtime.serialization.formatters.binary.binaryformatter(v=vs.110).aspx

    • @MrChick1984
      @MrChick1984 6 ปีที่แล้ว +14

      That is not true, you can modify data in SO at runtime and those changes will remain even after you finish the runtime ie. it will override data you filled in the editor.

    • @dylanhansen69
      @dylanhansen69 6 ปีที่แล้ว +2

      Is there a way to create saved data for all platforms using a Unity script rather than having to save a different way depending on the platform? Example: Windows 10, PS4, WebGL ...

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

    I don't really understand how these differ from normal Objects.

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

      What do you mean a "normal Object"?, you mean a prefab? Or maybe an Abstract sub-class?
      What ScriptableObjects is trying to make simple is a design pattern known as Dependency Injection.
      "The goal of the dependency injection technique is to remove this dependency by separating the usage from the creation of the object. This reduces the amount of required boilerplate code and improves flexibility." - Google Search: goal of dependency injection
      If you want to use other coding models to achieve your goal, you're welcome to do so, but keep in mind you are using Unity. It makes the most sense to use ScriptableObjects, because it streamlines the development, version control, and overall management of your games data objects.
      ---
      If you still don't get it then I suggest you try to create a game that uses a large amount of items(and create different version of these items). Do it without SerializedObjects, then do a version utilizing this tool. You will quickly understand why Scriptable Objects are essential to anyone working in Unity.

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

      I think what the question is asking here is, in the way that he used this Card class (Object) in this video he could've also just created a class that inherits from nothing that stores primitive values. Stored the actual values like name, etc. In a json file and loaded them at runtime. But the benefit of scriptable objects here is the editor helping do all the setup.

  • @ernestj8000
    @ernestj8000 6 ปีที่แล้ว

    Great tutorial on the use of Scriptable Objects. Thank you Brackeys.

  • @Gregasaurus
    @Gregasaurus 6 ปีที่แล้ว

    awesome tutorial. clear, to the point, and with good usage example. keep up the work.

  • @bigjiggly7490
    @bigjiggly7490 6 ปีที่แล้ว +45

    2 + 2 is 4 minus 1 that's 3 quick maths

    • @JS03
      @JS03 6 ปีที่แล้ว

      BigJigglyNutSack Skraaaa

    • @toasted2262
      @toasted2262 6 ปีที่แล้ว

      I said babe, the mans no't' ho't'

    • @StealerSlain
      @StealerSlain 6 ปีที่แล้ว +9

      Everyday man's on the code, smoke script

    • @bigjiggly7490
      @bigjiggly7490 6 ปีที่แล้ว +7

      See your C in the IDE, that C is a ukers

    • @StealerSlain
      @StealerSlain 6 ปีที่แล้ว +9

      When a ting went void void void, you man were public

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

    Lol, literally every variable he makes is public 🤣

  • @harold.geronimo
    @harold.geronimo 6 ปีที่แล้ว

    Just in time! Really needed this right now. Thanks!

  • @ColinHalbmaier
    @ColinHalbmaier 6 ปีที่แล้ว

    Great introduction to scriptable objects. Thanks for sharing!

  • @portlandorgan
    @portlandorgan 6 ปีที่แล้ว

    This. This is a perfect tutorial style. Thank you, sir!

  • @fabianainu3984
    @fabianainu3984 6 ปีที่แล้ว

    OMG you explain so well, your video is so easy to understand, thank you so much!

  • @Beikenost
    @Beikenost 6 ปีที่แล้ว

    Hey Brackeys! I started coding because of you, and you've been a lot of help! Thanks for your great explanations for us beginners! I recently started working with multiplayer and was wondering if you could do some tutorials on network libraries.

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

    It took me a year to get to this. Thank you for being so far ahead of me please keep uploading so I can't keep trying to catch up 😂❤.

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

    Wow i watched soooo many tutorials and couldnt understand then stumbled upon this video and guess what i understood. i wish u came back to youtube you really helped me a lot.

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

    Thank you so much! This will help me a lot in making level editors!