Scriptable Objects: What are they? How do you use them?

  Рет қаралды 95,829

Sirenix

Sirenix

Күн бұрын

Scriptable objects can help keep your code base clean by separating your design data from your runtime data. This can make adding new features or simply maintaining your Unity project far easier than only using monobehaviours. What are they? (0:34) Creating Scriptable Object (2:08) Adding Fields to SO (3:23) Generic Enemy Script (4:00) Abstract Scriptable Object (6:00) Scriptable Objects as Variables (7:20) Pros and Cons (8:30)
Blog Post on Scriptable Objects:
odininspector.com/blog/script...
Video Files (Github)
github.com/onewheelstudio/Dev...
Scriptable Object Videos
Unite '17 Seoul: • Unite '17 Seoul - Scr...
Unite '17 Austin: • Unite Austin 2017 - Ga...
Unite '16 : • Unite 2016 - Overthrow...
Buy Odin Inspector: odininspector.com/pricing
Odin Inspector: odininspector.com/
More Odin Tutorials: odininspector.com/tutorials
Odin Attributes: odininspector.com/attributes
Devdog Discord: / discord
Odin Project Validator: odininspector.com/odin-projec...
Assets Used in the Video (Affiliate Links)
Low Poly Toon Battle Arena: assetstore.unity.com/packages...
RPG Monster DUO PBR Polyart: assetstore.unity.com/packages...
#devdog #odininspector #unitygamedevelopment #scriptableobjects

Пікірлер: 129
@beri4138
@beri4138 4 жыл бұрын
"This can create problems if you add 100 enemy types" YandereDev: "Those are rookie numbers"
@scratchy996
@scratchy996 3 жыл бұрын
This video is gold. I like it when a game dev video contains concrete examples instead of generic explanations.
@ZorrroUK
@ZorrroUK 3 жыл бұрын
This video just reinforces that I need good examples to learn a concept aha, thanks a bunch!
@dionsandy935
@dionsandy935 2 жыл бұрын
I've heard of scriptable objects but never considered how useful they could be until now. Very informative and well explained.
@sammi7971
@sammi7971 Жыл бұрын
Really helpful, I feel a lot more confident in using Scriptable Aaaahbjects now.
@CreepYoutube
@CreepYoutube 4 жыл бұрын
5:20 your waterfall goes up
@parboilrice
@parboilrice 4 жыл бұрын
I really appreciated these examples. Great video.
@alejmc
@alejmc 4 жыл бұрын
Yes to the value/reference switch. Reminds me of a Scriptable Objects talk by Ryan Hipple. Glad to see more of these. Edit: amazing videos, loving these concise pill sized videos.
@nil7444
@nil7444 Жыл бұрын
BEST explanation in KZbin for Scriptable Objects in Unity, hands down.
@aresthemyth3010
@aresthemyth3010 4 жыл бұрын
Great Tutorial! I never understood the usefulness of the Scriptable objects unitl now. Thanks
@lama0344
@lama0344 3 жыл бұрын
Omg thank you so much. Your explanations are so clean!
@nareshbisht7620
@nareshbisht7620 3 жыл бұрын
Best Video on scriptable objects and great build-up for next tutorial on "Scriptable object with odin inspector".
@Frank_G_Finster
@Frank_G_Finster 3 жыл бұрын
Excellent video. While i know the practice of using ScriptableObjects, i really learned something more here. Thank you very much for this practical and easy to understand tutorial.
@whitefang8329
@whitefang8329 2 жыл бұрын
I wish my professor had the same lectures explanations as your video tutorials.
@imheretosleep
@imheretosleep 2 жыл бұрын
Dude thank you so much, I'm very thankful and happy that I found your channel. I love you man! Thank you so much. I really appreciate the effort❤️
@j.c.4316
@j.c.4316 2 жыл бұрын
thank you very much for this. been coding my project and spinning wheels it feels like for 4 years. but i am able to look back and see how much better i am than when i dropped out of college. i had just begun using a method of gameobjects with custom System.Serializable behaviours to do this exact thing. Ive watched a bunch of videos explain scriptable objects before, burgzergarcade being one. but his implementation was more confusing for whatever reason but now... im super excited to implement them now. great vid
@jacobs.7925
@jacobs.7925 Жыл бұрын
Fantastic video, thanks for sharing - everything is still very up to date!!!! We have a small company, around 10 devs.. it took us a couple years to understand when and what to use scriptable objects for - it's not that straightforward mostly because there's no "right" or "wrong" answer. Game systems architecture is on constant loop with deciding what to use SOs for (need to go back and refactor lots of features if you decide to add them later).
@chicao.do.blender
@chicao.do.blender 2 жыл бұрын
crazy good video, the Apllication library and the "isEditor" utility is so good. Thank you
@hernandonj
@hernandonj 3 жыл бұрын
Great video and great explanation! Thank you very much!
@johnx140
@johnx140 3 жыл бұрын
This is SO GOOD, thanks bro!
@coldcloudmedia2106
@coldcloudmedia2106 3 жыл бұрын
Excellent video. One of the best I've seen on Scriptable Objects.
@sirenix7891
@sirenix7891 3 жыл бұрын
Glad it was helpful!
@TheAbeinG
@TheAbeinG 2 жыл бұрын
thanks for this incredibly useful explanation !
@billyheinrich3279
@billyheinrich3279 2 жыл бұрын
Best video on SO! Thanks for explaining it so well! New Sub
@justinbennett9998
@justinbennett9998 2 жыл бұрын
Im just learning game development. Unity is so far the only studio program i have used. I had NO IDEA what scriptable objects were but i was already planning on using a callback script for my magic system. Good to know unity fixed this me before i ever got this far.
@non_da
@non_da 3 жыл бұрын
Awesome video. Thank you!
@Oliver_Koppert
@Oliver_Koppert Жыл бұрын
Fantastic video, great usecases to explain it too. Thanks!
@stazzadev3532
@stazzadev3532 4 жыл бұрын
Amazing video, thank you.
@andrebertier
@andrebertier 2 жыл бұрын
Very useful! Great video!
@TricoliciSerghei
@TricoliciSerghei 10 ай бұрын
Very useful! Thank you ;)
@bugbystudios
@bugbystudios 2 жыл бұрын
Thank u. That was great
@vivekgamedev
@vivekgamedev 3 жыл бұрын
Hey, thanks for the video...awesome content. But the best thing was the list of pros/cons and in both talks of Unite 2016 & 2017, no one talked about it in this manner. ...+Bonus tip about the data not being saved in "Standalone" build and just in "Editor"..saved me from falling in "appear's to be a save system" category. Thanks, man.
@user-cx1vt1kp1j
@user-cx1vt1kp1j 3 жыл бұрын
I found a little life hack how to make Save System From ScriptableObject. I am using serialization with JSON (JSON from newtonsoft), I load data in OnEnable method and store data in OnDisable method.
@bykush24
@bykush24 4 жыл бұрын
You saved my project while I'm stuck at somewhere and this video come out of nowhere like a miracle thanks. ❤️❤️
@sirenix7891
@sirenix7891 4 жыл бұрын
We're glad it was helpful! SOs are superful.
@bykush24
@bykush24 4 жыл бұрын
@@sirenix7891 you earn a new sub ❤️
@bykush24
@bykush24 4 жыл бұрын
@@sirenix7891 why you guys don't have join button I would like to support you when I have money
@rStarStudio
@rStarStudio 4 жыл бұрын
Nice video. I love it.
@vnone3578
@vnone3578 4 жыл бұрын
Good job!
@kennethbailey9802
@kennethbailey9802 2 жыл бұрын
thank you sir
@StigDesign
@StigDesign 3 жыл бұрын
i have started on using Scriptable Objects for my Track info but also car info :D
@bassfight2936
@bassfight2936 2 жыл бұрын
So, do I understand right that SO cannot / should not be changed at runtime since this can only be done in the editor, and not in a deployed build? What about if I make a copy/instantiate the SO, can I do it then? With your example of RPG characters, could you create the characters during game development and have them level and change/save stats at runtime in a build, or would you need to make a seperate object for that that only receieves the data contained in the SO's fields rather than the SO itself? I like SOs as lot but feel like I often mismanage them and don't understand them fully yet.
@carlabalos3884
@carlabalos3884 Жыл бұрын
Thanks!
@xxfazexx4376
@xxfazexx4376 9 ай бұрын
Thanks
@Felewin
@Felewin 4 жыл бұрын
The switching between value and reference is great - I had that idea myself right before you showed it. I think a video on it would be nice, although the way I'm thinking of implementing it, it's a fair-sized chunk of code to add to any particular property. While the goal of our idea is to reduce the redundancy of inputting values, I suspect we are trading it by redundantly putting the same boilerplate code everywhere, for every property we want to be able to toggle between those modes. I wonder if we could create a simple attribute instead, that takes the appropriate type of scriptable object as a parameter and then it would automatically set the inspector up that way. Something like [ReferenceValue(ScriptableObject scriptableObject)] Effectively dodging the need for another tutorial and duplication by programmers of its resulting boilerplate code on every property they want to behave that way.
@OneWheelStudio
@OneWheelStudio 4 жыл бұрын
The way I did it, stole it from Unity, is to create two classes. One is the actual SO that holds the data and the second is a reference class that handles all the boilerplate. Then when you want to use it, you can create a field that matches the type of the reference class with no need to add attributes. It could clutter up your project files a bit, but the actual code stays pretty tidy. The reference class for the "ColorData" SO I showed in the video is on GitHub: github.com/onewheelstudio/DevdogTutorialFiles/blob/master/ScriptableObjects/Color%20SOs/ColorReference.cs
@OneWheelStudio
@OneWheelStudio 3 жыл бұрын
We ended up making a follow up video on the value/reference idea. We didn't create a custom attribute, but with the use of generics it's pretty easy to implement for just about any type. You can check it out here: kzbin.info/www/bejne/iIutiKqkaZWHbqc
@hhgnehcom7672
@hhgnehcom7672 2 жыл бұрын
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
@ekagaurangadas
@ekagaurangadas 4 жыл бұрын
Unrelated question. I see that you have both OBS and Camtasia... Do you record with OBS and then put together the vid with Camtasia? BTW great Video.
@OneWheelStudio
@OneWheelStudio 4 жыл бұрын
I've mostly transitioned to using OBS for recording and Davinci Resolve for editing. I used to exclusively use Camtasia for recording and editing, but found that it didn't deal with 'large' projects well. DR creates and handles proxy files well and I've seen no slow down or instability with larger projects. DR also can export 4k video which I appreciate. That said, I keep Camtasia around as the quick screen capture for a GIF for quick share is hard to beat. I do sometimes miss the simplicity of Camtasia, but DR is a better solution for me.
@mastertomi01
@mastertomi01 3 жыл бұрын
Great video, very well explained A question at 6:35 : How can I overwrite DoTurn() for each enemy if I only write the script once? Do I not have to rewrite the script for every enemy to overwrite DoTurn()?
@sirenix7891
@sirenix7891 3 жыл бұрын
If I understand, yes you'd need to create a new SO for each enemy that needs it's own unique DoTurn() You could look into the "Strategy Pattern" and implement that? It might do what you want without having to make more SO definitions.
@TheLugiaSong
@TheLugiaSong Жыл бұрын
Woah, cheers! This is really well presented, especially for noobs like me. Also, is that waterfall flowing... upwards?
@CleosetricVlyers
@CleosetricVlyers 2 жыл бұрын
How to do attack pattern in enemy ovveride Attack method, i mean you can't doing coroutine, or invoke since its not monobehaviour, and also you can't get object transfrom position without passing the gameobject of asset
@yudnai5577
@yudnai5577 Жыл бұрын
how do you make scriptble objects persist between scenes in a real Build mode?
@TheSlimHim
@TheSlimHim Жыл бұрын
When would I use a SO vs base + child classes?
@DashzRight
@DashzRight 4 ай бұрын
Gold video
@dethedethsen347
@dethedethsen347 10 ай бұрын
Isnt that almost exactly what an abstract class (aside from storing the data in the project) does? Also with abstract classes you can even inherit MonoBehaviour from the base class thus giving you access to Update() and FixedUpdate(), which can make your enemies even more modular. Or am I missing something important here?
@TheNamesJT
@TheNamesJT 4 жыл бұрын
So, in order to drop and drag a game object into the game object variable on the scriptable object it has to be a prefab?
@OneWheelStudio
@OneWheelStudio 4 жыл бұрын
Yeah, it does. Generally SO's are assets in your project folders (you could create an instance during runtime, but that's unusual) so they can't connect with scene objects. You'd find the same if you try to drag and drop a scene object into a slot on a prefab.
@sirenix7891
@sirenix7891 3 жыл бұрын
For those of you who would prefer to see this in blog form check out this link. odininspector.com/blog/scriptable-objects-tutorial
@odo432
@odo432 4 жыл бұрын
Thanks for the video. Not that it's important but I couldn't help but notice your waterfall is flowing against gravity. :D
@OneWheelStudio
@OneWheelStudio 4 жыл бұрын
Yeah. I wondered if anyone would catch that. Good eyes!
@parboilrice
@parboilrice 4 жыл бұрын
It bothered me all video :O
@shieldgenerator7
@shieldgenerator7 3 жыл бұрын
6:37 what do you put in the DoTurn() function? Do you put a big long switch depending on type? Do you put code specific to one enemy type? Are you supposed to extend EnemyData in a new class for every enemy type? This is the one thing about ScriptableObjects that I haven't figured out yet.
@sirenix7891
@sirenix7891 3 жыл бұрын
I would likely extend the SO for each type of enemy that has a different behavior. But this can get out of control in a hurry. You might check out the "strategy pattern" which is a way to swap behaviors at runtime. Or you could even go further down the worm hole and create SOs for different behaviors and then drop those into the SO for the enemy to create custom behaviors that way :)
@MsSnoozable
@MsSnoozable Жыл бұрын
I'm really confused how you could implement an overridden function in the SO like you've shown. I followed most of the architecture you have, but when I tried implementing my attack() function for each unit type, I realized that they can't reference anything from monobehavior. How exactly are you actually do things relevant to attacking without the monobehavior?! I can't call animations or reference other scripts. All i can do is debug.log and return values. Even in your example I'm struggling to imagine what DoTurn() would even look like. If I have it call a function externally it just makes the code even messier. Like Call the SO enemy.DoTurn() which itself has a defintion to call enemyManager class which has a the DoTurn()!? this doesn't make sense. I can't find anyone else using SO functions either so I don't get it. At best I could return a tuple with relevant info on how to attack, but I'd still have the problem like you said for needing an if for each unity type.
@carlabalos3884
@carlabalos3884 Жыл бұрын
Thinking of that as well. I think it is better not to include an abstract function in that needs monobehaviour.
@maxinai_
@maxinai_ 4 жыл бұрын
Please tell me if I understood this correctly: Scriptable Objects are basically instances of classes/objects that any monobehaviour-script can pull data from. Kind of like using a prefab (for enemies for example) except you only have one instance of the data and can change every entity from there, right?
@sirenix7891
@sirenix7891 4 жыл бұрын
I think you've got it! They are super useful. The more you use them the more ways you find to use them :)
@maxinai_
@maxinai_ 4 жыл бұрын
They are awesome. I decided too give them a try in a VoxelTerrainGenerator (kinda like Minecraft) to store the BlockData (ID, Name, UVs(of where to find the texture)) and i can see now how usefull they are because if i want a new Block i just have to right-click>create>Block, fill out the information and done! Definitively gonna use them more in my projects. Thanks for making this great video, it really helped me to understand what SOs even do bevor i dive into Tests and the Documentation for hours on end (literally that all I did for this entire day 11am - 12pm :D)
@justadaniel
@justadaniel 4 жыл бұрын
‪Do you know of a way to have a event on the SO and ‬bind to it from a reference in a script as well as invoke it? I’ve been wondering if there’s a way to do that “properly”
@OneWheelStudio
@OneWheelStudio 4 жыл бұрын
I don't see any reason you can't have an event on a SO. As for invoking it, I'm about 99% sure only the class that the event is on can invoke an event. To get around this you could have a public function on the SO that invokes the event and then calls the function from another class. This feels really messy. My inclination would be to put the event (and invoke the event) from the class that is handling the SO. This (in my eyes) keeps the 'design data' separate from the 'runtime code.' Does that help or answer your question?
@lizkimber
@lizkimber 4 жыл бұрын
I havent tried but try it and see, id expect unity events or normal events to work
@justadaniel
@justadaniel 4 жыл бұрын
One Wheel Studio that definitely helps a lot! I’ve been working on an SO dialogue system broken up into conversation assets and was wondering of a way to bind to when a conversation started and ended, etc
@lizkimber
@lizkimber 4 жыл бұрын
@justadaniel well I tried it, and it works incredibly successfully - today I made a fully operational but basic quest system out of scriptableobjects, the events kick in allow hook ins for change in quest state to allow for dependancies on quests
@rStarStudio
@rStarStudio 4 жыл бұрын
I tried this and work very well. kzbin.info/www/bejne/qJK0ZJx-naqSgc0
@Yumenoki99
@Yumenoki99 2 жыл бұрын
Thanks for the concise tutorial and showing examples! As someone who has neither heard of abstract nor override before I have a question: let's say two different enemies are trying to attack at the same time, one shooting arrows to my knee for a few seconds and the other one spitting fire for a few seconds as well, the arrow shooting one attacks just a little bit earlier than the fire enemy, but since every enemy's DoTurn() is overridden until their attack is finished or until something else overrides it, they would for a brief moment both be shooting arrows at me, did I understand that correctly? Or would they both spit fire? Or would each one still just do their thing? I hope I made sense. The abstract is literally still a bit abstract to me haha ':)
@sirenix7891
@sirenix7891 2 жыл бұрын
So each enemy will do it's own thing. Each enemy has it's own "instance" of the class - which is why this all works. So each enemy has it's own version of DoTurn. Even enemies of the same type will each have their own instances. You can create static classes and static functions in which case there is only one instance. Just to give you another term to learn about ;)
@Yumenoki99
@Yumenoki99 2 жыл бұрын
@@sirenix7891 i see, will write that down, thank you!
@HaniSharif
@HaniSharif 2 жыл бұрын
I have a simple question. By this method, where do i store animations? to be clear, Let's say i have a dumb enemy and a smart enemy. Now both are supposed to walk. But the animation for both are different. How do i do this? Btw, you have a great video and u got a sub!! Thank you so much.
@mnnm1989
@mnnm1989 16 күн бұрын
I hope its not too late to suggest video ideas: A Video about the TableMatrix or serialized 2D arrays would be helpful for me. Maybe each cell of the array showing some cusom inspector stuff. If anyone knows a good resource for that it would be much appreciated. Edit: And i like your pronounciation, like scriptable ooobject.
@Arcann_bhp
@Arcann_bhp 9 ай бұрын
Ok but I wish he explained how to use the scriptable objects with the enemy data instead of saying “here’s a simple enemy script” like thanks
@drinksanddice9528
@drinksanddice9528 2 жыл бұрын
Im having a hell of a time swapping out child prefabs using scriptable objects in 2D. Anyone have any tutorial recommendations?
@CrazySovietIngeneere
@CrazySovietIngeneere 4 жыл бұрын
Do you have text version of this video? Hard to translate by voice///
@OneWheelStudio
@OneWheelStudio 4 жыл бұрын
There are captions in English for the video. Are you looking for something more than captions?
@CrazySovietIngeneere
@CrazySovietIngeneere 4 жыл бұрын
@@OneWheelStudio yes. I am looking for a something like article or manual
@OneWheelStudio
@OneWheelStudio 4 жыл бұрын
@@CrazySovietIngeneere Sorry there's nothing written up in the form of an article. I have a script that is 90-95% the same as the video.
@CrazySovietIngeneere
@CrazySovietIngeneere 4 жыл бұрын
@@OneWheelStudio well if can share it would be good)
@OneWheelStudio
@OneWheelStudio 4 жыл бұрын
@@CrazySovietIngeneere Some of the images might be not 100% match what's in the video, but things should mostly line up. Here's the 'story board' let me know if its useful. docs.google.com/presentation/d/13pp8wQs5akEeQG7GzCfs2rD5mKKvOXs13q_xRVQK8uo/edit?usp=sharing
@ThatFrostMourne
@ThatFrostMourne 3 жыл бұрын
Great video, BTW I'm in a track of finding a solution to my problem, but can't find it anywere, my problem is as it follows, I got a inventory system base on ScriptableObjects, items are also S.O., it works smothly but I can't find a way to drop the "item" on my scene, on the ground in front of the player when removing from inventory(which is also a S.O.) I can't get it to instantiate this Item (which is also a S.O.) do you have any idea how I could make it drop from inventory and instantiate this Item using scriptable Objects(btw I have "itemDataBase" containing all items id's from my game). Thanks for the awesome video, and Keep up the Great Work!!!.
@sirenix7891
@sirenix7891 3 жыл бұрын
In my experience, the SO should just be the data. So the object that gets instantiated would have a reference to the SO, but be the actual SO (which I don't think will work anyways). The object can then pull the needed data (model/sprite) from the SO and load data into itself to appear to be that object - but in reality the instantiated object is pretty generic. In other words, create a generic "inventory object" prefab. Then instantiate the object and load the SO. Does that help?
@ThatFrostMourne
@ThatFrostMourne 3 жыл бұрын
@@sirenix7891 Thanks for the reply!, yes, that should give me something to work for, I appreciated your help broh!
@notu483
@notu483 10 ай бұрын
Rather than using abstract methods, you can instead use interfaces... That way if one of your futures enemies won't include a DoTurn() for some reason, you don't have to break the entire code. This is using composition over inheritance.
@donjohnson4347
@donjohnson4347 3 жыл бұрын
Is scriptable objects safe and better for tcg game or is it just easier to use
@sirenix7891
@sirenix7891 3 жыл бұрын
They are easier that for sure. "Better" thats tougher, better than what? In general we tend to think that SOs are under used.
@StevesRepairs54
@StevesRepairs54 3 жыл бұрын
I would say better. In a tcg game you are going to need the card information in multiple scenes and you may not want to display the whole card every time. You may want a smaller book of collected cards and another book of cards in your deck. Then you will need cards for when the game is playing and so on. So if you store the card information in one spot you can change it all once instead of changing it on multiple card prefabs. Then you can create generic cards that pull in the card data and display it on the cards. So you have 1 card prefab that takes the card information and display's it. Then if you want to change the card layout you change it once for all cards. Hopefully that all makes sense.
@Valdyr_Hrafn
@Valdyr_Hrafn Жыл бұрын
I have started using this for enemies, but came to the conclusion it doesn't really have any reason to be scriptable objects over prefabs. why would I choose Scriptable Objects over Prefabs? aren't prefabs easier and faster to load in game too?
@sirenix7891
@sirenix7891 Жыл бұрын
SOs are similar to prefabs, but there is only one copy or instance. There is only one "blue enemy" SO and one "red enemy" SO. Whereas you could have lots of "blue enemy" prefabs instantiated into a scene. With SOs ALL of those blue enemies have access to the same SO. The UI or other systems could also have access to that SO. Meaning the same data can be shared with mutliple objects and your KNOW there is only one copy. It really depends on the use and the desired outcome, but SOs and prefabs each have their place. Hope that helps.
@halivudestevez2
@halivudestevez2 3 жыл бұрын
scriptable object vs regular objects, classes: Inpector? visually able to define and store data?
@sirenix7891
@sirenix7891 3 жыл бұрын
Sorry, I'm not sure I understand what you are asking? SOs can be used to store information, but not during runtime as any values set during runtime will be lost.
@gunbuckybucketman4578
@gunbuckybucketman4578 4 жыл бұрын
The Scriptable Objects are some how seems similar to Overriding method.
@AurrenTV
@AurrenTV 2 жыл бұрын
Tbh, I prefer just inheriting from a base class with virtual/ abstract functions and putting all the unique functionality in that script. Feels a little bit more OOP to me
@TheSlimHim
@TheSlimHim Жыл бұрын
I've been trying to understand when to use inheritance vs SO. The start of this video acts as if inheritance isn't a thing. I really want to know when to use one vs the other.
@AurrenTV
@AurrenTV Жыл бұрын
@@TheSlimHim From my experience using Scriptable Objects I've found that their best use comes from creating data holder objects such as different items/ enemy stats etc then just being able to plug those into different things when you use them. The main downside I've found from them is that whatever data you change in the object at runtime changes it for everything using the scriptable object as you are referencing the scriptable object and not creating a new one when you use it. So you need to create your own clone functions inside the scriptable object to not accidently change data in the original scriptable object.
@TheSlimHim
@TheSlimHim Жыл бұрын
@@AurrenTV thank you for the reply! I suppose I just don't see why not just add those states to the Enemy class. I guess because then you'd need to make them public to change in the inspector? I'm not experienced so really just thinking out loud here trying to learn.
@AurrenTV
@AurrenTV Жыл бұрын
@@TheSlimHim They're good if you want a nice clean folder with all these different scriptable objects you could easily hook up to unity menus to create new ones easilly intead of having to create a new script each time. But I do prefer using inheritence when it comes to programming different behaviours. Scriptable Objects are best for different stats, things like that.
@TheSlimHim
@TheSlimHim Жыл бұрын
@@AurrenTV Thank you for your perspective!
@kibou5832
@kibou5832 3 жыл бұрын
wahts means the _ in "_data"?
@sirenix7891
@sirenix7891 3 жыл бұрын
Nothing much, just another way to name a variable.
@kibou5832
@kibou5832 3 жыл бұрын
@@sirenix7891 thank you. So mich ppl do this but i found no Information why. Any i just wonder waht that do.
@sirenix7891
@sirenix7891 3 жыл бұрын
In some worlds its a way of showing that a variable is private or local... I think it's going out of favor, but it can still be useful.
@danamuise4117
@danamuise4117 2 жыл бұрын
Before scriptable objects we used JSON files
@danylarge
@danylarge 3 жыл бұрын
+1 Likes from me, sorry to break the 666 likes
@jayocaine2946
@jayocaine2946 Жыл бұрын
Why couldn't you just make all that data a separate component? A component would even allow you to use callbacks
@sirenix7891
@sirenix7891 Жыл бұрын
There can certainly be reasons to put data in a component, however one of the big advantages to SOs is that the data is then an asset and is accesible projet wide and is therefore accessible to any object in any scene. So it really depends on your needs and your project.
@jayocaine2946
@jayocaine2946 Жыл бұрын
@@sirenix7891 so basically, it can be static persistent data? I can't see a reason other than passing messages, which there's already so many C# ways of doing.
@sirenix7891
@sirenix7891 Жыл бұрын
SOs aren't necessarily static, as there can be multiple instances of a given type of SO in the project. The common example is say stats. There would be one "Stats" SO class and then many instances (assets) for each unit that might need individual stats defined. But yes, they can be thought of as data and logic container - but as project assets so they don't belong to a prefab, gameObject or a even scene which opens some doors compared to using traditional component. People get pretty creative with how they get used. There's lots of uses for them! Jason Wienmann made an interesting video a while back on using SOs along with events that could be worth watching to see other functionality. He also did a video on using them to transfer data from one scene to another. Code Monkey also make a recent video showing potential downfalls to SOs when people try to use them as a save system. Hope that helps.
@TearscapeSE
@TearscapeSE 9 ай бұрын
Did you read your stuff from a paper or why do you sound so strange?
@nemesis8508
@nemesis8508 4 жыл бұрын
THIS DOES NOT MAKE ANY SENSE! You showed how to make override functions for enemies with different actions, but how tf do you actually make different code for each ScriptObj?! It will be the same for all the ScriptObjs!
@sirenix7891
@sirenix7891 4 жыл бұрын
If you need different code that can't be overriden in a given function then you will need to make an additional scritpable object class. For example you may have a SO for enemies, another for weapons, and another for npcs. Each can make use of an abstraction and override functions but each will need it's own base class. Does that help?
@nemesis8508
@nemesis8508 4 жыл бұрын
@@sirenix7891 thanks for responding. Let me clarify a bit. You said in the video you can use override functions for enemies who have different actions for turn based combat. I have a scriptobj class called EnemyData that stores info and has the function inside of it. I made a base scriptobj that enemydata inherits from to override tye functions. But whateve code you put will be used by every enemy. So how do i make different code for each enemy?
@sirenix7891
@sirenix7891 4 жыл бұрын
I think I understand. So you'll need a class that's not just enemyData, but maybe enemyData_Melee that controls for melee units and then another class maybe enemyData_Ranged (that also inherits from the base scriptable object) that controls ranged units. You will need a new class for each type of enemy - but what this buys you is that each of those classes has the same "action" function that can be called from a manager or other script. Which means the script calling the "action" function doesn't need to know what type of enemy it is (this is huge). This can also be done with say a "do damage" function so that the player, the environment or anything can call the "do damage" function on an enemy with out caring what type of enemy it's damaging. This allows the addition of new types of enemies without having to change all your code. Does that help or clarify more?
@nemesis8508
@nemesis8508 4 жыл бұрын
@@sirenix7891 yes! That helps alot. Thank you
@DarkHolm-er5bt
@DarkHolm-er5bt 2 жыл бұрын
@@sirenix7891 How would you go about doing this, calling the attack action from the different types of enemies. Cause to be able to use the attack action what type would the variable you are calling the attack function be?
@pyro6822
@pyro6822 Жыл бұрын
Scriptable OOObject 😂
How to Create a Custom Inspector with Odin?
7:44
Sirenix
Рет қаралды 34 М.
ДЕНЬ РОЖДЕНИЯ БАБУШКИ #shorts
00:19
Паша Осадчий
Рет қаралды 6 МЛН
Final increíble 😱
00:39
Juan De Dios Pantoja 2
Рет қаралды 15 МЛН
UFC 302 : Махачев VS Порье
02:54
Setanta Sports UFC
Рет қаралды 1,2 МЛН
Sigma Girl Education #sigma #viral #comedy
00:16
CRAZY GREAPA
Рет қаралды 90 МЛН
Rethink Everything with Scriptable Object VARIABLES
15:28
ScriptableObjects, Explained | Unity Tutorial
19:27
LlamAcademy
Рет қаралды 10 М.
The Power of Scriptable Objects as Middle-Men
17:41
samyam
Рет қаралды 116 М.
Be CAREFUL with Scriptable Objects!
8:27
Code Monkey
Рет қаралды 74 М.
Game Architecture Tips - Practical Uses Of Scriptable Objects
14:45
Unity 2021 Use Scriptable Object instead of Enum
10:57
Sunny Valley Studio
Рет қаралды 36 М.
How I use Odin in my own project!
7:13
Sirenix
Рет қаралды 8 М.
SCRIPTABLE OBJECTS in Unity
8:57
Brackeys
Рет қаралды 988 М.
Better Data with Scriptable Objects in Unity! (Tutorial)
5:12
ДЕНЬ РОЖДЕНИЯ БАБУШКИ #shorts
00:19
Паша Осадчий
Рет қаралды 6 МЛН