3 Interesting Ways Scriptable Objects can fix YOUR Unity3d project now!

Black Friday - game.courses/blackfriday
Join the Group - unity3d.group
Become a Member! - / @unity3dcollege
Patreon - / unity3dcollege

Пікірлер: 175

  • @razeenag8478
    @razeenag84782 жыл бұрын

    Nothing can save my unity project, helpful video though :)

  • @Braneloc

    @Braneloc

    2 жыл бұрын

    Try Ctrl-S (sorry) :)

  • @razeenag8478

    @razeenag8478

    2 жыл бұрын

    @@Braneloc finally someone who understands

  • @mohammadsadeghlavaie5560

    @mohammadsadeghlavaie5560

    2 жыл бұрын

    @@Braneloc You outsmarted his outsmarting lmao

  • @SpencerYonce

    @SpencerYonce

    2 жыл бұрын

    Idk why, but this made me laugh so hard. Too relatable

  • @Rhysman30

    @Rhysman30

    2 жыл бұрын

    @@Braneloc Take your up-vote... you animal.

  • @_ironrose
    @_ironrose2 жыл бұрын

    I'm using SO's for enemy AI's for my rts game also. Each scriptable object represents a different AI behaviour. For example one for aggressive, one for defensive, one for constructor AI etc. Great stuff indeed.

  • @itsslugg3637

    @itsslugg3637

    2 жыл бұрын

    whaaat? How? sounds dope how do you do it?

  • @bohdandete8705

    @bohdandete8705

    2 жыл бұрын

    is there a way to check in your game?;)

  • @NameUnknown-

    @NameUnknown-

    2 жыл бұрын

    Its a great idea, that allows you to have a pluggable ai

  • @tPlayerioT

    @tPlayerioT

    10 ай бұрын

    thats actually genious and more organizable

  • @kyoai
    @kyoai2 жыл бұрын

    For those familiar with Unreal: While not being exactly identical in functionality, overall Monobehavior is very similar to UActorComponent and ScriptableObject like UObject.

  • @leonardoraele
    @leonardoraele Жыл бұрын

    00:00 Intro 00:34 Summary 01:27 Merchandise/Black Friday Bundle 01:55 Storing Data (Multiple Levels, Player Data, Score) 13:12 Game Content (Items, Quests, Collections) 21:14 Event System

  • @duuze4853

    @duuze4853

    Жыл бұрын

    pin this man!📌

  • @JBtheWARVillain
    @JBtheWARVillain2 жыл бұрын

    Thank you Jason for your tutorials and sharing your knowledge. As a relatively new Game Developer, I've been employed for 11 months now and I'm still just scratching the surface. A whole lot to learn but am excited about the journey, just wanted to say thanks for all your tips.

  • @gammafoxtbg
    @gammafoxtbg2 жыл бұрын

    The biggest thing I use them for, especially for jams, is a SO-based audio system. Created it so that my sound designer can set up sound SOs with clips, settings, and some other custom stuff like pitch variation and such independently. Then I also have 'audio channel' SOs connected, that will pass on 'Play' calls from the sounds to the audio manager via events, which subscribes to said calls upon creation. This way, everything is decoupled, and nothing blows up if the AudioManager doesn't happen to be in the scene, but nothing else in the game has to deal with anything but the Sound SOs. Not necessarily a great solution for larger projects, but it works great for small stuff/jams.

  • @FireHo57

    @FireHo57

    2 жыл бұрын

    Are there any tutorials you could point to to get a handle on how to set this sort of thing up? I'm fairly new with SO's and this sounds like something I'd like to know more about.

  • @contot4084
    @contot40845 ай бұрын

    As a newbie in game development, this video opened my eyes to a new horizon in controlling game components! Beautiful video! Thank you so much for sharing.

  • @RappierX
    @RappierX2 жыл бұрын

    Great video as usual! Some of the ways I use Scriptable Objects: Ones that you've mentioned: - Globally accessible data (scores, stats, player information, audio...) - Object definitions, like items, skills, etc. Great for the Flyweight pattern! I use this everywhere I can - Events! Others, more specific: - AI brains: easy to change brains when needed - Channels: I need to change scene but I need some information to go along to the new one, that will be used to initialize it. Similar to the globally accessible data, but more specific usage - Saving / Loading, using serialization - Enumerators with data: Let's say we want an enum for the months of the year, where we also want to store the number of days the month has. We create the MonthSO script with the int _days field. Then we create 12 SOs, using the file name as the enum value. It becomes a quite flexible enum and can include data - Sets: Let's say I have a monster that only spawns during summer. If I want to define seasons as set of months, I can have a ScriptableObjectSet, create 4 SOs and group the files in the point above respectively. The monster spawner can then reference the Summer SO which checks if the current month matches an element in the set. . another example: I can group player condition status to check if they are able to perform an ability. If I have the "Normal" "Stunned" "Asleep" "Slowed" statuses (using SOs as enum values), I can have for example a set called "AbilityDisabled" and include "Stunned" and "Asleep". The player/ability will have a reference to the Set and check if the current status matches an element. - Types in general (think of pokemon): Have an "ElementTypeSO" script. Create 3 SOs, "Fire" "Water" "Grass". Each of them can reference which others they have weakness or resistance. Now each monster and ability can reference one or more element type SOs. The ability damage can be modified by that SO, based on the enemy monster type Bonus: Scriptable Object Singleton You can have Scriptable Objects that are also Singletons. Have the SingletonSO base class create an instance using Resources.Load(typeof(T).Name) Then create your class: [CreateAssetMenu(fileName = nameof(ItemLibrary), menuName = "Game/Item Library")] public class ItemLibrary : SingletonSO { } Create the new file and put it in the resources folder. The file name must exactly match the name of the class

  • @pmoneyish6869

    @pmoneyish6869

    Жыл бұрын

    Why use SO for some of these vs say a database? Curious as I'm new to SO's but not DB's.

  • @TheIanLux
    @TheIanLux2 жыл бұрын

    I use SOs mostly for storing data such as items, equipments, characters and enemies. Then I apply those as references on other scripts (mostly MonoBehaviours) that read the data and do something with them!

  • @AnikenSkiwalker
    @AnikenSkiwalker2 жыл бұрын

    Bought your black Fri deal and absolutely loving it! I actually dropped out of game school because it was extremely expensive and and tried to teach you multiple languages and game engines. None of the people I know who graduated from these schools are working for AAA studios.

  • @Sulihin
    @Sulihin2 жыл бұрын

    This was exactly what I needed right now. Thanks!

  • @mpbMKE
    @mpbMKE2 жыл бұрын

    I'm prototyping a board game concept, and each square you can land on has a different effect. In fact, most of them have multiple different effects, and I landed on the idea of using SOs to manage the various ways they can affect the player. There are also three categories of draw cards which I'll probably handle similarly, but I haven't quite gotten to mapping out that mechanic yet.

  • @0pMarK
    @0pMarK2 жыл бұрын

    Events and runtime anchors are by far the most common uses for me. And then it's more project dependent. I also use them for commom actions like move to, rotate towards target, etc. Basically things to avoid rewriting code.

  • @Xankill3r
    @Xankill3r2 жыл бұрын

    I use scriptable objects in almost all of my game jam projects for storing SFX and related settings. I make a Scriptable Object class that represents an SFX "event" (let's say a footstep) - and it has a list of AudioClips and some floats representing volume and pitch ranges. I use it to easily allow audio variations.

  • @bischoffdev
    @bischoffdev2 жыл бұрын

    In the last game I used SOs as storage for complete levels. This worked extremely well with custom Odin editors and allowed us to create levels in edit mode that would normally be dynamically created at runtime.

  • @qiangpanchen6785
    @qiangpanchen67852 жыл бұрын

    really nice! Thank you Jason for the clear tutorial!

  • @BBdaCosta
    @BBdaCosta2 жыл бұрын

    I use exactly for these 3 cases, but one thing that I use Scriptable Objects too is to replace enums on the code. I implement a SO to hold the type and make the relationship on the Monobehaviours and C# classes using the instances of these SO that I created, I think this way I have a more flexible architecture by not having to change the code every time that I modified or delete an enum.

  • @flamingpenny
    @flamingpenny2 жыл бұрын

    I built a 2d tilemap movement system where the scriptable objects define how a player moves on a specific tile. So for instance if the tiles are Icey, the scriptable object define it as RB movement and slide characters and objects that walk over them around. Then if it's sandy the SO tells the player to move slower with transform move. Works for moving platforms and other stuff too!

  • @llareia
    @llareia2 жыл бұрын

    Thanks for describing how you use them to save game state! The issues with the editor saving values across plays always made this too confusing for me to figure out. Using OnDisable to reset it really cleared up how to use this without confusing myself about what will actually happen in a game session. (Also, OnValidate cannot be shown enough. That's a huge time saver that hardly anyone talks about!)

  • @DevDunkStudio
    @DevDunkStudio2 жыл бұрын

    Great video! I barely use them atm, right now only for storing item-data

  • @CRUMVIII
    @CRUMVIII2 жыл бұрын

    Looks like this could be very useful for an inventory system maybe. Thanks for this.

  • @pixelroutine4609
    @pixelroutine46092 жыл бұрын

    I wasn't using scriptable objects. A programmer (who works in Unity professionally) told me about it and now I use them. They have been very useful.

  • @thiago_590
    @thiago_5902 жыл бұрын

    Currently using SOs to comunicate objects within lists with Events. This way I can have something like.. An enemy counter on screen, whenever an enemy spawns, comunicate with UI without the need for FindObject or the UI have reference for that enemy (or dirting classes with connection code). Enemy and UI comunicate within SO like EnemyList. Enemy prefab asset and UI prefab asset has reference to EnemyList Asset, became decopled and can exist / be used / tested separately.

  • @dbweb.creative
    @dbweb.creative2 жыл бұрын

    Should I store/use scriptable object for something like a "database" dictionary of effect ids and their support data/args? In gameplay these would be only read-from, but during development these could be adjusted? Oh, and can scriptable objects store references to functions, or maybe lambda expressions?

  • @Onslaught73
    @Onslaught732 жыл бұрын

    thumbs up for just seeing your face and knowing you will improve my skill!

  • @PeterAlexay
    @PeterAlexay2 жыл бұрын

    Tank you Jason for this great video!

  • @skizooooooooo
    @skizooooooooo2 жыл бұрын

    A single instance of a scriptable object > Singleton Monobehaviors fight me :p

  • @L1ghtOn3
    @L1ghtOn32 жыл бұрын

    Don't know if you have a tutorial yet on the new starter assets especially the ThirdPersonController using the Joystick sliding down slopes, but I am having GREAT difficulty in trying to get the player slide down the slope on the terrain at the slopelimit on the character controller, seen lots of vids on YT and on the forums but just can not put it all together with the starter assets TPController Character Controller. This is one tutorial for once I am really needing to see a full fleshed out demo on normals at the ground angles that pushes the player downwards down the slope and that the code it fits nicely into the Starter Assets TPController, 3 weeks now I've been at it, the longest it has taken me figuring code out, longer than learning loading and saving, quests with Inventories, scriptable objects etc, this one is really getting to me, I need that downward slide on steep slopes! Anyway great series as usual, keep up the good work Jason you help a lot of indie devs like myself that only have one brain and 10 digits to do all that work :D

  • @sunalharbi
    @sunalharbi2 жыл бұрын

    Really great content. many thanks

  • @chunkyquail
    @chunkyquail2 жыл бұрын

    I use them for events and as a kind of constants that can be easily set up in the editor by our designer.

  • @rapideye101
    @rapideye1012 жыл бұрын

    Hey Jason, nice tutorial. I was wondering how the material color change in your Item.cs does not affect all coins? I through changing the color of a material affects all objects that also use the same material.

  • @Eckster

    @Eckster

    2 жыл бұрын

    When you access the sharedMaterial property of a renderer you get a reference to the original material they all use, but if you use the material property, a new instance of the material is automatically made, and changes to this won't affect anything still using the sharedMaterial.

  • @misa8286
    @misa8286 Жыл бұрын

    Woah. Without that arrow at 3:15. I wouldnt know where to even find the coins in the ui element. thank you :)

  • @zeggxr1539
    @zeggxr1539 Жыл бұрын

    ive used it once for skill system, which every skill was deriving SkillBase abstract class with simple method like abstract void Getact() and has a prop named cooldown as float

  • @GaryParkin
    @GaryParkin8 ай бұрын

    Thank you for the tutorial. I'm new to Unity but not coding. At 4:08, why would you use SetActive(false) over Destroy object? And I was totally on board with SO until I watched all of the "DON'T USE THEM" videos for holding data between scenes. Please tell me what options do we have?

  • @0Mindmachine0
    @0Mindmachine02 жыл бұрын

    helpful as allways. thanks.

  • @farghostable
    @farghostable2 жыл бұрын

    I use scriptable objects for all of the above and also use them like a virtual UI or UI data provider. This stays independent of current UI implementation, and I was able to quickly drop the UI and make a new one 3 or 4 times for experiment purposes.

  • @EricWilliamsCG
    @EricWilliamsCG2 жыл бұрын

    One thing I've used Scriptable Objects for is localization. Seven scriptable objects, one for each language, has translations for all the buttons and descriptions, when the app starts you can pick a language and it will use that scriptable object to fill in all the fields.

  • @Good.Idea.Zlovakia

    @Good.Idea.Zlovakia

    Жыл бұрын

    Good idea! Thank you

  • @DavidZobristGames
    @DavidZobristGames2 жыл бұрын

    Configs, object/item Data, currency data and manager object (increase,decrease logic with events to subscribe), events... They are easy to use with the addressable assets system to load maybe new created/ patched assets from your remote bundle.

  • @KillerGameDev
    @KillerGameDev2 жыл бұрын

    I use scriptable objects for character base swaps, cards when making a tcg, and monsters like in a pokemon like game. I mostly use them when I want the code and functionality to be the same with minor swapping of stuff like a mesh or an image. It helps me to create a template-like structure. I wrote this before watching the video like you asked - I hope im on-point. lol

  • @Tarodev
    @Tarodev2 жыл бұрын

    Great video Jason 👍 You don't just show the benefits of the strategies, but also the shortfalls and gotchas to give a full picture.

  • @anthonyspano7139
    @anthonyspano71392 жыл бұрын

    How does your CountOf function work exactly? (17:36). How can you pass anything as a parameter when the docs say it's a simple get function?

  • @BehindTheFXTuts
    @BehindTheFXTuts2 жыл бұрын

    Can you please tell me how i can get the "greyed out" tips in my script just like yours? Thanks!

  • @burakakay6632
    @burakakay6632 Жыл бұрын

    Thank you!

  • @cq5857
    @cq58572 жыл бұрын

    I use scriptable objects and actions to replace singletons (USUALLY) by putting an object with some actions to invoke and subscribe to. Makes managing multiple scenes and systems cleaner

  • @dmas7749

    @dmas7749

    Жыл бұрын

    i don't like GameObject singletons either

  • @tk8628
    @tk86282 жыл бұрын

    Hello, I mainly use SOs for Items or abilities in my games. Weapons, rings, cards, equipment, etc...

  • @KrzychuMixu
    @KrzychuMixu2 жыл бұрын

    valuable knowledge

  • @this-is-gamedev
    @this-is-gamedev2 жыл бұрын

    Events, Events, Events and Items! I am not convinced using SOs for saving data across levels. I feel that it's better to write a separate save/load system so you can support game restarts. In the Unity Editor, SO's persist, but when the game is built, SO's reset to their default state after each game restart. That was confusing at first...

  • @Unity3dCollege

    @Unity3dCollege

    2 жыл бұрын

    For larger scale projects that definitely makes sense. I personally prefer to bind my data into serialized objects and keep anything that's going to be 'saved' there, and instead use the SOs as data objects or long lived data pointers.

  • @masterytyrantfuture
    @masterytyrantfuture5 ай бұрын

    I'm currently building a game based on "Kindergarten" and "Kindergarten 2" - I'm using SO's to store game events that have happened, and the player's inventory and cash held at the start of each chapter, so that they may replay from the start of any chapter if they mess up. These persist between each chapter (which are different scenes). I'm also using them for shared configuration of my objects.

  • @mfatihbarut
    @mfatihbarut2 жыл бұрын

    Hi Jason, can you make a video about "How can we protect our compiled game pack (.apk etc.) when we register it to a store like PlayStore, from being theft, copied, reverse engineered, sold in a pirate .apk web sites? etc."

  • @videogamedevelopmentseries2706
    @videogamedevelopmentseries27062 жыл бұрын

    at 17: 16 I'm getting a cannot use Non-invocable member 'name' cannot be used like a method. Only methods and delegates can be invoked. This error is generated when you try to use empty parentheses to call something other than a method or delegate. For this method on the itemCollection script: I tried it without parenthesis and still get the error: public int CountOf(ItemType itemType) { return _collectedItems.Count (t: ItemType => t == itemType); } Any ideas?

  • @Popart-xh2fd
    @Popart-xh2fd11 ай бұрын

    3:56 Why the use of out keyword if the variable player of type Player is already passed by reference?

  • @xuecheng3914
    @xuecheng39142 жыл бұрын

    thank you!

  • @lambjalfrezi
    @lambjalfrezi2 жыл бұрын

    Scriptable object for a global event switchboard. Any event that is not getting passed from parent to child goes via a global event switchboard. It has massively reduced spaghetti code and spaghetti events. Example: Player dies. Method gets called on the global switchboard to trigger an onPlayerDead event. The game manager, audio system & score board all listen for that event (each keeps a reference to the global switchboard). It means that the player doesn't need to reference those systems at all, nor do the systems need to reference the player.

  • @anthonyspano7139
    @anthonyspano71392 жыл бұрын

    Nice top! (Bottom right). I have that same one.

  • @megasoniczxx
    @megasoniczxx2 жыл бұрын

    I think the method your gonna look at in the item script is the method that controls the points addition to the score. Edit: Well...I was close xD On a serious note though, i'm kinda curious about something. I'm still pretty beginner-ish at Unity despite how long i've been using it since I still code in a pretty relatively straight forward way. A lot of this stuff still confuses me quite a bit and while I have used SO's before, I haven't used it enough to get a firm grasp of different ways to apply it. If you were to give a recommendation, what would you say would be a good way to practice with these?

  • @shoco2
    @shoco22 жыл бұрын

    From what I know, the unity messages on a scriptableobject are called in very weird and specific scenarios. For example, the awake and onenable messages get called if you just click on it in the inspector. There's a lot of weird behavior like this with unity messages and scriptableobjects, and personally im not a fan of storing persistent data on it, but I definitely use them for your other 2 points!

  • @ROUGETHEBAT456
    @ROUGETHEBAT456 Жыл бұрын

    Do u know what to do if a character runs or moves in place what do i do to fix this

  • @masterytyrantfuture
    @masterytyrantfuture2 жыл бұрын

    I use SOs for storing settings and state that persists between scenes.

  • @andythedishwasher1117
    @andythedishwasher11172 жыл бұрын

    This event system concept reminds me of the Elder Scrolls Construction Set where the devs at Bethesda made what seems like an event system to enable players to do design work with essentially the same tools they gave to their native designers at Bethesda.

  • @andythedishwasher1117

    @andythedishwasher1117

    2 жыл бұрын

    I think that whole thing was written in Ruby, but I wouldn't be surprised if they were using some feature of it that was analogous to these scriptable objects in order to create the files accessed in the construction set. They had all the same kinds of public properties you're referring to with the same kind of independent stability when instantiating them. You can also edit their properties in the scene and rename them to create entirely new base objects from existing assets in the editor. That was my first foray into coding as a kid.

  • @twoboxtoofurious
    @twoboxtoofurious2 жыл бұрын

    I really like using scriptable objects to store public variables related to gameplay. Like enemy line of sight range, angle, walk speed, etc. I think it's much easier to adjust them that way, and it's also neat to have them all pointing at a single object instead of each enemy having it's own values. I don't know what else I could use them for. My friend uses them and makes instances of them so that he can modify them at runtime, but I don't like that approach

  • @skyppex4076
    @skyppex40762 жыл бұрын

    I use ScriptableObjects a lot. My general rule of thumb is to use them whenever i want multiple of the same object, but with different information related to it. Also, they must not have different functionalty. An example of something that would have different functionality are abilities. Every ability does something different than the other so using ScriptableObjects wouldn't really work, as its only one class. I'd rather use abstract class : MonoBehaviour. An example of something i'd use scriptable objects for are Stats! All stats generally do the same thing, but with a different name attached to them. Health decreases when damaged and increases when healed. Mana has decreases when you cast a spell and increses, let's say, periodically. This might seem like different functionality at a glance, but it really isn't. Because the Stat itself shouldn't control how it changes. Thats for other systems to determine. The Stat just simply allows itself to be changed by other systems. On a different note, i also use it for stuff like settings (not a settings menu exactly, but i can see that working too). Lets say you're making a hero shooter. Each hero is vastly different in how they operate, but they all have some common stuff, such as Stats or Cosmetics. I would make a ScriptableObject in order to pass in that information in the Editor and that way i can reference it other places if i need to or just create a few different settings objects in order to test them all out really quickly.

  • @pierredalaya444

    @pierredalaya444

    2 жыл бұрын

    You can make abilities in scriptable object . Data and logic at the same place and any new team member can create a new ability by simply creating a new scriptable and writing the ability logic in there ;). This makes it very clean and easy to add content and logic without touching an existing game core. Its a bit sneaky and not straightforward but its very useful.

  • @gabornemeth7174
    @gabornemeth71742 жыл бұрын

    All data, that doesn't need to change during gameplay. I also use a global Cache of them, to make them usable as part of the save data (the game saves the ID, then looks it up on load).

  • @cahydra
    @cahydra2 жыл бұрын

    *Question* if i have a scriptable Object item named 'bowl' and inside this bowl exists 'x' amounts of marbles can i then have two bowls with diffrent amounts of marbles inside them at the same time?

  • @firebiscuitgaming7624

    @firebiscuitgaming7624

    2 жыл бұрын

    To expand on Sanjo's answer: yes. the SO is just an asset template you can create multiple instances of your item following the same template one with 5 marbles the other one with 3 or something.

  • @xtraterastrielrede5513
    @xtraterastrielrede55132 жыл бұрын

    HEY JASON, are you familiar with this note I wrote myself, I need to identify the extension. ~ There is an extension that allows you to add an actual visual image aka a photograph into your code for the boundaries framework of the application being programmed itself, like adding a photo from your camera as a background image of the game snake if you were programing snakegame. that image coding can also be coded into a 3d net framework to add the image into the framework as an object, thus creating a game such as a first person shooter like ARMA battlefield2 or GTA5 from complete scratch.

  • @MaZyYTube
    @MaZyYTube2 жыл бұрын

    For the last gameevent part I wrote my own event system which can be accessed from everywhere in the code without doing a reference to each other. Also works for your UI example For instance: 'SmartEvent.Broadcast(new DamageEvent(30) { Attacker = "Soldier" })' and the receiver 'SmartEvent.OnReceiveEvent(OnReceiveDamage)'. For receiver you can wrote also own listener component with unity event. So they can work with drag and drop. Why I do not like use SO like that way? Sometimes in larger projects you gonna change often large scenes and multiple scenes with same scriptableobject. Or remove it what ever. You always need to go one by one on all scenes. It is hard to find the so. With prefabs it is working. There are multiple examples. So it is hard to manage after a while all those SOs. I use them most time only to manage simple things like maybe the ui thing. In multiplayer it even gets harder, hehe. While with CODE ONLY you just refactor or localize very fast where you need to change things because the error will bring you to that position. Also IDEs like Visual Studio can show reference to that object so you find all connections. I was also researching to do that with reflections. For example I have a method like Heal() with attribute [ButtonAction, ButtonActionLabel ..] etc. This will automatically create buttons in menu. It is working but would to like have better way.

  • @jerms_mcerms9231
    @jerms_mcerms9231 Жыл бұрын

    I'm using SO for a fighting game where I can have multiple characters that can run on a single implementation without a bunch of inherited classes.

  • @polygoncrafter
    @polygoncrafter2 жыл бұрын

    Hi i am trying to se the amount of coins but when i load into a new scene my coins count is off by one. Its like the event doesnt update until i collect the second coin after loading into a new scene. I am using the same Event "Changed".

  • @polygoncrafter

    @polygoncrafter

    2 жыл бұрын

    In case anyone runs into this issue I decided to store an integer for my coin count in the script referencing the SO > on Start I return the coin int from my SO and assign that value to the UI Manager script. This way the coin count is accurate.

  • @DaElfer
    @DaElfer11 ай бұрын

    The dialogue system i create uses scriptable objects for each run of dialogue between two or more characters.

  • @habibyahya788
    @habibyahya7882 жыл бұрын

    I mainly used SO for content/items. Already tried using it for events, but I am not a fan of it. I prefer fully code my event system rather than using SO. Never used it for storing data, because there are A LOT of ways better than SO at storing data.

  • @andrewhamel1
    @andrewhamel12 жыл бұрын

    I've watched this video twice now and I'm still not sure how the SO is persisting values between scenes. I can't imagine "where" it exists in the project

  • @egoinstart8756
    @egoinstart87562 жыл бұрын

    Hi ! "Since I've discoverd SO's (with the Unite austin 2017 Talk) my entire life became better". As we don't have any Senior programmer in my company (small team, small projects), and the legacy projects are complet spaghetti, I've undertook to set up an SO Architecture based on the Austin Unite talk 2017 : That's solving a lot's of problems, and lot's of time. I've "discovered" you about 2 years ago with an old video talking about resolving scene merge conflicts (using unity YAML tool), and that makes me think, that one of my main problem in Unity, is still using it with Git. I can't find any efficient worklow for that. We do changes on prefab only, each member works on his own branch, with his own scene, etc.. etc... But, we can't avoid to make scene changes, and this is the point : I don't know how to merge scenes correctly. What I do is paper note these changes, and manually update scene after the merge. That's bad, I know. So, if someday you could do a video about setting up a worklow using Unity with git (and maybe what about Unity collab ?) i'll love it ;) I check from time to time, there isn't much about this topic on youtube other than "do prefabs, separate scene". By the way, keep up the good videos, I think they are one of the most "professional" in the youtube game. And 'Scuse my English !

  • @Xorgye

    @Xorgye

    2 жыл бұрын

    I am too not that experienced on architecture of games. But after SO's the wiring of objects became much more easy and stable. But for the scenes, I had to get a multi scene approach before everything worked as I hoped it would. And SO's help massively there because you can discover and wire up stuff properly between multiple scenes (while stil being able to work on a single scene and things don't break there)

  • @xanaramus

    @xanaramus

    2 жыл бұрын

    @@Xorgye The big downside however with scriptable object architecture IDE wont help you to write code more efficently, and god if you want to rename scriptable object class name or you get corrputed guids etc, then your whole project becomes a mess. In my opinion scriptable objects should be used mainly for holding static data. Logic should be in monobehavoiours or better in plain classes. This way debug process would`nt be so painfull or unpredictable.

  • @Xorgye

    @Xorgye

    2 жыл бұрын

    @@xanaramus I can understand your distrust of the Unity database system. That's what you end up with most of the time: creating your own object database system to store game state. However, that's the optimum solution. There are options I'm between that are easier to understand, build and maintain. And SO's are definitely part of that, even with code in them.

  • @miloverreijt6396
    @miloverreijt63962 жыл бұрын

    I use SO's for my multiplayer game by storing object data in SO's i can use a single prevab for every object in my scene.

  • @xalalakos
    @xalalakos Жыл бұрын

    how did you make your unity play and stop so fast?

  • @zeejenkins
    @zeejenkins2 жыл бұрын

    I use SOs as factories and a way to connect my domain logic to Unity.

  • @rwells242
    @rwells242 Жыл бұрын

    i thought in production builds scriptable objects doesnt persist data changes. That is the data is stored in the editor and play mode but changes arent saved in builds. Is that incorrect?

  • @SunSailor

    @SunSailor

    Жыл бұрын

    That is correct, you have to be aware about that. You can instance SOs before using them to prevent overwriting values.

  • @Malicos
    @Malicos2 жыл бұрын

    I tried this same method but my coins just turned into cubes and then I wasn't able to collect them any more :(

  • @Wanfanel
    @Wanfanel2 жыл бұрын

    between scenes SO can unload and lose not serialized/stored data

  • @SunSailor

    @SunSailor

    Жыл бұрын

    That happens, if there is no reference left on them. You need to be aware of that, but from there it is no deeper problem. Or simply don't work with scenes in the first place and use addressables instead.

  • @Braneloc
    @Braneloc2 жыл бұрын

    One view, zero comments, 3 thumbs up :) The internet is a weird place.

  • @Unity3dCollege

    @Unity3dCollege

    2 жыл бұрын

    Distributed databases and apis :) It's always interesting seeing the difference in the 'realtime' / 'day' / and 'public youtube page' views. I still have no idea which one is most accurate lol :)

  • @0Mindmachine0

    @0Mindmachine0

    2 жыл бұрын

    had the same view :D

  • @Stefan.05
    @Stefan.052 жыл бұрын

    Could you make a third person shooter with a weaponwheel and different weapons with unitys new input-system?

  • @habibyahya788

    @habibyahya788

    2 жыл бұрын

    I can say yes, whether using old or new input-system I think that won't interfere with your weaponwheel logic

  • @alexh.4644
    @alexh.46442 жыл бұрын

    Events, Data (Weapon stats, skills, scores, cash), Shared script values (e.g. bools)

  • @VEOdev
    @VEOdev2 жыл бұрын

    The only time I use scriptable objects is for Items & characters & abilities .. BUT I do it only for fixed variables, variables that I know they will not change in the game like item name , description and others fixed data .. I don't use it for things like player health

  • @zainuldin9095
    @zainuldin90952 жыл бұрын

    please show me how to make easy save system or can i store data in SO on run time

  • @lvx969
    @lvx9692 жыл бұрын

    Events, Items, reference data, character statistics,... to name a few.

  • @bobmcbob4399
    @bobmcbob43992 жыл бұрын

    Anyone know if it is possible in Unity to create a game specific stylized button that has for example different tint colours for the various states like hover, button click etc + has a nested Text element which has a specific colour and Font and say a Shadow component on the text object as well?... and then create instances of these buttons over different scenes and change the text for each one like "Start Game" or "Store" or "Quit"? This could be done almost with Prefabs, but the problem there is that changes made to instances of prefabs on your scene will differ (by text content) to the prefab definition in your Project window. Basically I want a button with a specific look and feel for my game. And I want each button I place down to have its own text content. Also I want to be able to update/change the look and feel of the button design and do this one time only and have my change instantly reflected across all instances of this button whilst also preserving the unique button text that each instance has. Any ideas?

  • @thalesdarini

    @thalesdarini

    2 жыл бұрын

    Well, the prefab actually does this if I understood what you want. Each instance of the prefab shares the same properties and values from the prefab definition but can also alter some of them (like the text content), that isn't a problem. If you update the colors on the prefab definition, it will automatically update on all of its instances whilst maintaining the altered properties of each one. So you can have different text contents in each instance and alter the color on the prefab and all of them will be updated.

  • @bobmcbob4399

    @bobmcbob4399

    2 жыл бұрын

    @@thalesdarini Ah I see. Thanks. I wasn't liking the "Overrides" having values in the inspector, but I guess this is perfectly normal and expected in Unity Prefabs. Would be nice for Unity to let the prefab designer to mark properties as Exclude State From Prefab or Don't Track Property State etc

  • @johnny2x2
    @johnny2x22 жыл бұрын

    Use scriptable objects for networked variables so my artist can use networked variables in a local code … I use RPCs on the variable change and a controller to hold and send that information for all networked variables in my scene

  • @MonkeyShark
    @MonkeyShark2 жыл бұрын

    I use them for things like weapons, items, skins, etc.

  • @cameronlile2931
    @cameronlile29312 жыл бұрын

    Maybe I'm wrong and I just didn't do it right but I was thinking that data in scriptable objects are NOT persistent in a build. Only in the editor. If you build it, change the data in the scriptable object, exit the game, and then restart the game, it won't retain the changed data like it does editor mode. What I've read on the forums seem to suggest the same thing.

  • @juice1884

    @juice1884

    2 жыл бұрын

    Isn't that obvious tho?

  • @cameronlile2931

    @cameronlile2931

    2 жыл бұрын

    @@juice1884 I think you misunderstood me. I don't mean change it in the editor and it doesn't change in the build you already made. I mean if you change the value at runtime in the build just like in the video it will not work. This only works in the editor. So its useless if you want to actually publish your game.

  • @juice1884

    @juice1884

    2 жыл бұрын

    @@cameronlile2931 No, I understand you correctly. I think this is obvious behaviour.

  • @Unity3dCollege

    @Unity3dCollege

    2 жыл бұрын

    This is something I addressed with a solution in a live stream here - kzread.info/dash/bejne/oXpqrqeTgdOams4.html I think I'll do a quick dedicated video on the topic though, didn't realize that one had been a stream, perhaps as a part 2 or followup to this one.

  • @cameronlile2931

    @cameronlile2931

    2 жыл бұрын

    @@juice1884 Perhaps. But if you are on here learning about it it's a good chance you don't know. I built an entire replay system based on saving info in scriptable objects only to realize once I built it it was useless. Good to point it out to people as an fyi before they waste their time as well 😂

  • @Stargate16789
    @Stargate167899 ай бұрын

    Hi there, I would not use ScriptableObject for dinamic data between scenes (It is not good practice in builds). You can loose this data if you have no reference to it. For example you are going from A to B scene but you have a loading screen. If you have no reference to your scriptable object in your loading screen UnloadUnusedAssets can clear your data (this can be called on mobile devices if you have not enough memory). Using them for Game Events and static data is perfect :)

  • @GaryParkin

    @GaryParkin

    8 ай бұрын

    I was curious about this too. I have read in a lot of places that SO is not to be used for cross Screen data keeping, but for static data like inventory items. What do you use instead? I don't like the Singleton much.

  • @Stargate16789

    @Stargate16789

    8 ай бұрын

    ​@@GaryParkin You have many options to keep data between scenes: - Singleton (DontDestroyonLoad object with your data), - static class with static variables (for few variables), - PlayerPrefs, - you can load Scenes Additively (or create a PersistentScene with Persistent objects),

  • @GaryParkin

    @GaryParkin

    8 ай бұрын

    @@Stargate16789 Thank you. I played with the static class, and the singleton. PlayerPrefs looked like a great option because it saves to the hard drive. As a new user I wanted to do it right up front and not develop any bad habits. :) I still like the idea of the scriptable objects, but I wanted to be sure I wasn't painting myself into the corner. I'll go look up added scenes.

  • @Rubidev
    @Rubidev2 жыл бұрын

    Are SOs much more prone to be hacked than classes? if so whhy bother even risking a game that will definitely let hackers lurk into?

  • @Rafaelcraftero
    @Rafaelcraftero2 жыл бұрын

    Not using integer and using list makes me nervous! optimization pls :C

  • @firebiscuitgaming7624

    @firebiscuitgaming7624

    2 жыл бұрын

    My game is using lists, loops of loops, dictionaries etc and runs at 500fps. Loops are not the issue, loops are an issue if you keep looping inside the update method. No point overly optimizing code that runs once per scene or once every minute or something.

  • @puretrack06
    @puretrack062 жыл бұрын

    Inventory system, input system, unlockables, quality and game settings

  • @justinwhite2725
    @justinwhite27252 жыл бұрын

    Sometimes I worry I'm over-using scriptable objects. Nested chains and other things that make me wonder if I'm over-engineering.

  • @dejamoogames612
    @dejamoogames6122 жыл бұрын

    Events, Runtime Sets(based off Ryan Hipples 2017 GDC talk), and I use them as states in my finite state machine for my AI.

  • @PhodexGames
    @PhodexGames2 жыл бұрын

    TLDR Don't use Scriptable Objects (Most of the time) I think the more complex you get with SOs the less suitable they are. As a result I am trying to reduce usage replacing it with a much better solution. I would like to say "Don't use SOs" but that would be too harsh. They have their uscases. But they are horrible and even dangerous for storing larger amounts of data. It happend too often that my entire item or skill data got purged because I renamed a variable and forgot to add a "FormerlySerializedAs". Also because unitys default inspectors are very unpleasant and badly readable I found myself spending more time writing custom inspectors than actually writting data. Also, unless you are using Addressables which can make it somewhat comfortable, you always need to reference your SOs with a inspector field or "Resource.Load" you cant just access their data. Which also is annoying. Especially if its just text and numbers. Whats the solution? Use a database. There are Database assets in the asset store, but I prefer to use CastleDB for maximum flexibility. It has some limitations but you can easily work around them. Use it together with Addressables and you will say goodbye to SOs in a minute. The benefits? - Never lose data again - Clean, organized and uniform interface to view and edit your data without spending hours on a custom inspector - Directly reference your data thanks to code generation (say goodbye to missing reference) - Easily rename all your fields and values with a single click. No need to spend half an hour to create a batch process tool yourself. As the database is plain json Just use a texteditor for it - very flexible and easy to share. Everyone can edit it without even having unity So just don't really use SOs for storing your data, apart from config stuff, or use them as proxies.

  • @pmoneyish6869

    @pmoneyish6869

    Жыл бұрын

    I'm actually surprised Unity doesn't have Sqlite built in for data storage. I'm coming from a business programming background so I'm used to and love databases but seems the game world avoids them as much as possible for some reason. SQL isn't that difficult so not sure why. I've been watching many videos on SO to understand what and why they exist, but yeah it really seems to be from a data perspective a DB would be a better place to store stuff than an SO.

  • @PhodexGames

    @PhodexGames

    Жыл бұрын

    @@pmoneyish6869 Well, I heard that Unreal has some sort of database. It is dumbfolding for me Unity doesn't. It is such an essential feature for making games.

  • @edward3190
    @edward31902 жыл бұрын

    Im using SO for EVERYTHING that is not required to be in a scene

  • @Goomero
    @Goomero2 жыл бұрын

    using them for literally everything

  • @odyss160
    @odyss1602 жыл бұрын

    we are negan!

  • @batuhankaraveliogullar7027
    @batuhankaraveliogullar70272 жыл бұрын

    Code Review!!!

  • @ignatiusreilly8280
    @ignatiusreilly8280 Жыл бұрын

    Yeah, but what if someone tries to sell me a game development course (for $1000 ) and keeps emphasizing that they will teach me how to make a game "WITH LEVELS!" - can scriptable objects help me in that situation?

  • @maxit0x
    @maxit0x Жыл бұрын

    Scriptable Objects ftw!