ECS-Like Game Architecture wScriptableObjects

This package is a simple game architecture system promotes data driven programming & C# jobs system, using scriptable objects.

System has three core classes.

note: Remember that systems can also contain logic that will run outside of callbacks. Since they are scriptableobjects, you can call any public method outside of the callback, anywhere you want by binding its references via the inspector. This idea is inspired by Ryan Hipple's ScriptableObject Runtime Sets idea.

Instructions & Demo Explanation

1. Create a monobehaviour class which derives from "SystemComponent" class. \ 2. Put every data exclusive to that gameobject which will be used in your logic.

3. Depending on when you want the game object to move, register in the system where the action starts.

Final version of movement component

4. Create a system class which derives from GameSystem that will contain your logic.

5. Add a field declaring maximum entity (gameobject) count.

6. Lets create an array of transforms & components, to maintain objects that registered to the system.

7. Lets populate these arrays on component register operation by overriding RegisterComponent method Base method will assign unique id's to each component & the id will be used as it's index.

7. You need to clear/redefine these array references at awake, because of how scriptableobjects work.

8. Lets create a struct to define our movement logic via C# jobs system

9. Define our Movement logic inside MovementSystem.cs and call the function on Update

10. Add Asset Menu Attribute to the movement system

11. Create an empty gameobject in scene, and add Engine.cs component.\ 12. Create an instance of MovementComponent via Create asset menu via right click => create in projects window.\ 13. Add MovementComponent.cs to the gameobjects that needs to move, adjust speed field & populate the system reference via inspector."\ 14. Populate the system reference via Engine.cs inspector.

Developer Notes

How To Install

This package uses the [scoped registry] feature to resolve package dependencies. Open the Package Manager page in the Project Settings window and add the following entry to the Scoped Registries list:

1. Open Edit / Project Settings in Unity

Project Settings

2. Go to Package Manager

Package Manager

3. On Scoped Registries Window add the keys below

Scoped Registry

4. Open Window / Package Manager in Unity

Open Package Manager

5. Select My Registries Option

My Registries

Now you can install the package from My Registries page in the Package Manager window.

My Registries