The Ultimate Introduction to Scriptable Objects in Unity

preview_player
Показать описание
In this video I'll introduce you to ScriptableObjects (SOs), show you what they are, how they work, how to make one, and why you should use them.

ᐅGet the full Source Code Bundle to my Unity Tutorials 🤓

📥 Get the Source Code 📥

🤝 Support Me 🤝

Try out Machinations for FREE today!!

►🔗 Relevant Video Links 🔗
ᐅUnity Forum - ScriptableObject behaviour discussion (how Scriptable Objects work)
ᐅScriptable Object API Unity Documentation

I go over the Scriptable Object creation, instantiating them through code dynamically, showing the functions you can call within them, and will mention additional uses with them such as event based messaging and replacing enums. I will be making another video going more in-depth with the event based messaging. Scriptable Objects are scene and play-mode independent assets that live in the project scope and are used to contain data. This makes it great for rapid iteration for both developers and designers and allows for easier testing due to reduced dependencies (can isolate testing features).

Small Fix, in the video I said to put SerializeField and a private setter, but make sure to add the field tag as so
[CreateAssetMenu]
public sealed EnemyData : ScriptableObject
{
[field: SerializeField]
public Int32 MaxHealth { get; private set; } = 100;
}

►⏱️ Timestamps ⏱️
0:00 Intro
0:38 Machinations Sponsorship
1:55 What are Scriptable Objects
3:47 How to make a Scriptable Objects
7:11 Enemy Scriptable Object Example
11:16 Scriptable Objects Overview
11:53 Scriptable Object Functions and Execution Order
14:47 Instantiate Scriptable Object in Code
16:33 Event Based Messaging with Scriptable Objects
17:07 Sidenote - Don't destroy original Scriptable Object
17:21 Replacing Enums with Scriptable Objects
19:11 Outro

💖💖THANK YOU TO ALL MY PATRONS 💖💖

❯❯❯ My Links ❮❮❮
💗 Patreon 💗
💬 Discord Server 💬
🐦 Twitter 🐦
📚 Facebook 📚
🎵 Music 🎵
Ambient Gold
👍 Like and Subscribe! 👍

🖥️ Computer Setup 🖥️
*As an Amazon Associate I earn from qualifying purchases.

Disclosure: This post may contain affiliate links, which means we may receive a commission if you click a link and purchase something that we have recommended. While clicking these links won't cost you any money, they will help me fund my development projects while recommending great assets!

#madewithunity #gamedev #unity
Рекомендации по теме
Комментарии
Автор

Small Fix, in the video I said to put _SerializeField_ and a _private setter_ - but make sure to add the *field:* tag, like so:
—————————
[field: SerializeField] // Notice the field: part. Adding this inside any attribute will make it work with Properties.
// Others you might want to use are [field:Range(min: 0, max: 100)], [field:Tooltip("description")], etc
public int MaxHealth { get; private set; } = 100;
—————————

samyam
Автор

This is a good video, and I approve of it, but you forgot a very important part of ScriptableObjects: They can run code. Which means you can use them to alter behaviour of stuff. As an example, you can create different ScriptableObjects for different types of AI, and just switch out the "brain" of an enemy to try out different behaviours. I once made a game where we used ScriptableObjects to alter the behaviour of text, so when the player read to a certain point in the text, stuff such as particle effects, screen shakes or sound could play. This is a very powerful tool for your Designers. You should at least mention that it's possible, although all the possibilities would probably require its own video.

danielvindhjarta
Автор

This is by far the best scriptable object video I've seen!

neenaw
Автор

The thing I like, is that you mention how important these are when working with designers
So many tutorials forget that game development isn't just about programmers showing off their programming skills but cooperating with non programmers ( designers, artists, etc... ) and making sure they can work autonomously

Xxnightwalk
Автор

While I follow and really like your channel, I want to give humble advice. Your tutorials start easy and very understandable, it becomes really hard so quickly. I totally got lost on "Enemy Scriptable Object Example" part.
Your presentation skills are great, and I really want to learn with your content.
All the best!

onatozdemir
Автор

Samyam, I am Incredibly grateful for your channel's inspiration during tough times. My game is hitting Steam after two years of learning!

BlackPanzerYZ-pqnd
Автор

Easily my new favourite unity tutorial channel. The way your videos are organised is freaking perfect. Most other tutorials are jumping all over the place.

TheAgavi
Автор

i am amazed by how much your channel has evolved. Congrats :)

antontheyeeter
Автор

I have been using SOs (Scriptable Objects) for all of my projects now (been a year or 2). I use it for the Handling GameManager States such as if the game is starting, running. If the player is dead etc

I am looking forward to Event-Based SOs as I use Unity Events and C# Events (Delegates and static events) but I have never figured it how it works with SOs.

GRENADEable
Автор

An ESSENTIAL Unity tutorial. Thanks again for such an awesome video!

emilyhorton
Автор

Thanks for actually showing how to create one unlike all the other videos I have watched where it just explains bunch of stuff instead of showing how to create a scriptable object lol

Ylaid
Автор

This woman is a hero ❤️🙌🏼 thank you so much for this Sam ❤️

rebarius
Автор

normally i dont give reviews but maam youre amazing like i tried 2 videos on 2020 and one on 2022 but it wont work but i saw yr video today and it worked as being both content creators i respect your hard work and keep it up

gopalravi
Автор

Thank you so much for this video! I had a bunch of data in scriptable objects but was struggling to connect them to actual objects in the scene, this was a massive help!

marinemanaphy
Автор

This is perfect! I needed a new introduction to scriptable objects lately

FireJojoBoy
Автор

Every time I stumble with your channel I read Saiyaman instead of Samyam so, with this and your useful tips I guess.. 🤔you're kinda my hero 😅

sergiosdf
Автор

this is really the best video about SOs, that i found today)
thank you so much, waiting for new tutorials in your style :)

semenshchepkin
Автор

New subscriber ... I really wish I had seen this video a year ago when I was digging into SOs. This was just so much better, clearer, and contains way more info, than all the other videos I watched last year. Such a simple example but the first part of the video explaining how its an asset really made it pop.

kyleme
Автор

TNice tutorials was a fantastic beginner's guide, straight to the point, very clear. As a long-ti teacher I can tell you are quite apt at teacNice tutorialng!

jakariarafi
Автор

Great video but I want to clear one thing that scriptable Object are not used for save system, because they don't persist data in build runtime i.e. the game runtime, they persist data only in the editor and any other scene which has reference to that specific scriptable object, if there is no reference to it on other scene the data will lost.

jmikleo
visit shbcf.ru