Notifications
bg
Lucas
Self taught hobbyist - Programmer
Porto Alegre, Brazil
6
Likes
24
Followers
13
Connections
All
Articles3
Games0
Showcases0
Column3
Jobs0
Lucas
published the article
Aug 2, 2018
Bitmasks and enum flags
Bitmasks and enum flags
Very useful (and simple) binary tricks
Lucas
published the article
Jul 30, 2018
Singleton ScriptableObjects
Singleton ScriptableObjects
How to set them up
Funbites
Game Studio
15 days ago
I didn't know about the "[RuntimeInitializeOnLoadMethod]" attribute and I will start using it. Thanks! What I did before was to have a MonoBehaviour that initializes the Scriptable Objects in the Awake, but if you forget to add the references, you will get a lot of null exceptions. I suggest you to not use the singleton pattern at all. I have a Scriptable Object that shares memory for all AI agents (AISharedMemory). It's similar to your ItemDB singleton. I could have used a singleton because only the enemies had references to it, but I decided to use a reference to AISharedMemory in all AI related Components. When I needed to create a AI companion to help players, it was super simple. I made another instance of the AISharedMemory and add that instance to the AI companion Components in their prefabs. And it was simple as that. If I had used the singleton pattern, I would have to fix a lot of stuff in the code. If you think that setting up references for the most common case can be tedious, there's a simple way that Unity can help you with that. You need just to select the script that makes references and set the instance of the Scriptable Object in the inspector. Every time you create a new instance of the Component, it will make reference to that specific Scriptable Object.
Lucas
updated the article
Jul 16, 2018
Making a 2D movement script
How to write a simple 2D player controller
Lucas
published the article
Jul 16, 2018
Making a 2D movement script
How to write a simple 2D player controller
About Me
Coding is my hobby and I do it for fun. I have 1 year of experience in Unity and 1 year in UE4 ...
See more
Skills
Certifications (0)
Import
See all
Lucas's liked projects (3)
Following (17)
Followers (24)
Following Companies (0)
Not following anyone yet
Groups (0)
No groups