Skip to content

Commit b3f01d6

Browse files
authored
Update README.md
1 parent a5dd418 commit b3f01d6

File tree

1 file changed

+54
-60
lines changed

1 file changed

+54
-60
lines changed

README.md

Lines changed: 54 additions & 60 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ Unlike traditional ECS solutions, EasyCS offers a **gradual adoption path**. You
1818
- [🚀 Why EasyCS?](#-why-easycs-solving-common-unity-development-challenges)
1919
- [🌟 Features at a Glance](#-features-at-a-glance)
2020
- [🔍 Comparison Table](#-framework-comparison-table)
21+
- [📦 Dependencies](#-dependencies)
2122
- [❔ FAQ](#frequently-asked-questions-faq)
2223
- [Is EasyCS just another ECS framework?](#is-easycs-just-another-ecs-framework)
2324
- [Is EasyCS as complex and slow to develop with as other ECS frameworks?](#is-easycs-as-complex-and-slow-to-develop-with-as-other-ecs-frameworks)
@@ -28,7 +29,6 @@ Unlike traditional ECS solutions, EasyCS offers a **gradual adoption path**. You
2829
- [What kind of games are *not* ideal for EasyCS?](#what-kind-of-games-are-not-ideal-for-easycs)
2930
- [Do I need to update all MonoBehaviours to EasyCS?](#do-i-need-to-update-all-monobehaviours-to-easycs)
3031
- [How to migrate my MonoBehaviours to EasyCS?](#how-to-migrate-my-monobehaviours-to-easycs)
31-
- [📦 Dependencies](#-dependencies)
3232
- [⚙️ Setup](#️-setup)
3333
- [🔧 Setup with VContainer (Optional)](#optional-️-setup-with-vcontainer)
3434
- [🧪 Setup with Zenject (Optional)](#optional-️-setup-with-zenject)
@@ -112,6 +112,21 @@ EasyCS is an **evolving framework** designed to be intuitive and easy to integra
112112

113113
---
114114

115+
116+
## 📦 Dependencies
117+
118+
| Package | Purpose | Optional |
119+
|--------------------|----------------------------|----------|
120+
| Unity 2021+ | Minimum version supported ||
121+
| com.unity.2d.animation | Required for editor-hooks ||
122+
| Tri Inspector Plus | Required for editor ||
123+
| Zenject | DI Framework support ||
124+
| VContainer | DI Framework support ||
125+
| Odin Inspector | Enhanced inspector UI ||
126+
| Odin Validator | Editor-Validation System ||
127+
128+
---
129+
115130
## **Frequently Asked Questions (FAQ)**
116131

117132
### **Is EasyCS just another ECS framework?**
@@ -167,39 +182,22 @@ Let's compare how a simple player movement system might be implemented in a trad
167182
In a typical Unity setup, movement logic and the Rigidbody component are often tightly coupled within a single MonoBehaviour.
168183

169184
```csharp
170-
using UnityEngine;
171-
172-
public class PlayerMovementTraditional : MonoBehaviour
173-
{
174-
private float moveSpeed = 5f;
175-
private Rigidbody rb;
176-
177-
void Awake()
178-
{
179-
rb = GetComponent<Rigidbody>();
180-
if (rb == null)
181-
{
182-
Debug.LogError("PlayerMovementTraditional requires a Rigidbody component!");
183-
enabled = false;
184-
}
185-
}
186-
185+
public class PlayerMovement : MonoBehaviour
186+
{
187+
[SerializeField]
188+
private float _moveSpeed = 5f;
189+
[SerializeField]
190+
private Rigidbody _rb;
191+
187192
void FixedUpdate()
188193
{
189194
float horizontalInput = Input.GetAxis("Horizontal");
190195
float verticalInput = Input.GetAxis("Vertical");
191196

192197
Vector3 moveDirection = new Vector3(horizontalInput, 0f, verticalInput).normalized;
198+
Vector3 nextPosition = _rb.position + moveDirection * _moveSpeed * Time.fixedDeltaTime;
193199

194-
if (moveDirection.magnitude > 0.01f)
195-
{
196-
Vector3 nextPosition = rb.position + moveDirection * moveSpeed * Time.fixedDeltaTime;
197-
198-
Quaternion rotation = Quaternion.LookRotation(moveDirection, Vector3.up);
199-
rb.MoveRotation(rotation);
200-
201-
rb.MovePosition(nextPosition);
202-
}
200+
_rb.MovePosition(nextPosition);
203201
}
204202
}
205203
```
@@ -216,37 +214,44 @@ EasyCS allows you to define movement data (EntityDataMove) separately from the R
216214

217215
```csharp
218216

219-
[Serializable, RuntimeOnly]
220-
public class EntityDataMove : EntityDataBase<Vector3> { }
217+
// Use EntityData for configuration and runtime data. Do not user for storing UnityEngine.Objects
218+
[Serializable] // (Optional) Apply [RuntimeOnly] attribute for data that does not require setup from inspector(runtime data)
219+
public class EntityDataMoveSpeed : EntityDataBase<float> { }
221220

222-
public partial class ActorDataRigidbody : ActorData
221+
// Use ActorData for linking GameObjects/Transform/Components within the GameObject hierarchy
222+
// For linking assets(prefabs, sprites, textures etc.) use ActorDataSharedBase
223+
// Ensure class is partial for compatibility with code generation
224+
public partial class ActorDataRigidbody : ActorData
223225
{
224226
[field: SerializeField, Required]
225227
public Rigidbody Rigidbody { get; private set; }
226228
}
227229

228-
public partial class ActorBehaviorMove : ActorBehavior, IFixedUpdate
230+
// Ensure class is partial for compatibility with code generation
231+
// Replace the Monobehavior with ActorBehavior
232+
public partial class ActorBehaviorMove : ActorBehavior, IFixedUpdate // Implement required callbacks for your logic(IFixedUpdate)
229233
{
230234
[Bind]
231-
private EntityDataMove _dataMove;
235+
private EntityDataMoveSpeed _dataMoveSpeed;
232236
[Bind]
233237
private ActorDataRigidbody _dataRigidbody;
234238

235239
public void OnFixedUpdate(float deltaTime)
236-
{
237-
Vector3 nextPosition = Actor.transform.position + _dataMove.Value * deltaTime;
240+
{
241+
float horizontalInput = Input.GetAxis("Horizontal");
242+
float verticalInput = Input.GetAxis("Vertical");
243+
244+
Vector3 moveDirection = new Vector3(horizontalInput, 0f, verticalInput).normalized;
245+
Vector3 nextPosition = _dataRigidbody.Rigidbody.position + moveDirection * _dataMoveSpeed.Value * deltaTime;
238246

239-
if (_dataMove.Value.magnitude > 0f)
240-
{
241-
Quaternion rotation = Quaternion.LookRotation(_dataMove.Value.normalized, Vector3.up);
242-
_dataRigidbody.Rigidbody.MoveRotation(rotation);
243-
_dataRigidbody.Rigidbody.MovePosition(nextPosition);
244-
}
247+
_dataRigidbody.Rigidbody.MovePosition(nextPosition);
245248
}
246249
}
247250

248251
```
249252

253+
**Note:** Don't forget to attach `Actor` component to your GameObject
254+
250255
**Key Steps and Benefits of Migration:**
251256

252257
1. **Identify and Separate Data:** The moveSpeed and Rigidbody references are extracted into dedicated data components: EntityDataMove (for the conceptual movement input/direction) and ActorDataRigidbody (for the Rigidbody component itself). These are now separate, reusable pieces of data.
@@ -257,18 +262,6 @@ public partial class ActorBehaviorMove : ActorBehavior, IFixedUpdate
257262

258263
This approach allows you to refactor your codebase piece by piece, gradually benefiting from EasyCS's architectural improvements without stopping ongoing development.
259264

260-
## 📦 Dependencies
261-
262-
| Package | Purpose | Optional |
263-
|--------------------|----------------------------|----------|
264-
| Unity 2021+ | Minimum version supported ||
265-
| com.unity.2d.animation | Required for editor-hooks ||
266-
| Tri Inspector Plus | Required for editor ||
267-
| Zenject | DI Framework support ||
268-
| VContainer | DI Framework support ||
269-
| Odin Inspector | Enhanced inspector UI ||
270-
| Odin Validator | Editor-Validation System ||
271-
272265
---
273266

274267
## ⚙️ Setup
@@ -285,25 +278,25 @@ https://github.com/Watcher3056/EasyCS-Submodule/releases
285278

286279
### (Optional) ⚙️ Setup with VContainer
287280

288-
5. Add `VCONTAINER_ENABLED` keyword in `Edit > Project Settings > Player > Scripting Define Symbols` then press "Apply"
289-
6. Attach `LifeTimeScopeWithInstallers` component on the same GameObject as before
290-
7. Drag-n-Drop `EasyCSInstaller` into `Installers` list on `LifeTimeScopeWithInstallers`
281+
4. Add `VCONTAINER_ENABLED` keyword in `Edit > Project Settings > Player > Scripting Define Symbols` then press "Apply"
282+
5. Attach `LifeTimeScopeWithInstallers` component on the same GameObject as before
283+
6. Drag-n-Drop `EasyCSInstaller` into `Installers` list on `LifeTimeScopeWithInstallers`
291284

292285
---
293286

294287
### (Optional) ⚙️ Setup with Zenject
295288

296-
5. Add `ZENJECT_ENABLED` keyword in `Edit > Project Settings > Player > Scripting Define Symbols` then press "Apply"
297-
6. Make sure to attach `EasyCSInstaller` component on the GameObject with `SceneContext`
298-
7. Drag-n-Drop `EasyCSInstaller` into `Mono Installers` list on `SceneContext`
289+
4. Add `ZENJECT_ENABLED` keyword in `Edit > Project Settings > Player > Scripting Define Symbols` then press "Apply"
290+
5. Make sure to attach `EasyCSInstaller` component on the GameObject with `SceneContext`
291+
6. Drag-n-Drop `EasyCSInstaller` into `Mono Installers` list on `SceneContext`
299292

300293
---
301294

302295

303296
## 📚 Examples
304297

305-
Check:
306-
`Assets/EasyCS/EasyCS-Samples/`
298+
1. Download this repository
299+
2. Check: `Assets/EasyCS-Samples/`
307300

308301
---
309302

@@ -371,6 +364,7 @@ public class ActorBehaviorHealth : ActorBehavior
371364
- HandleEntityDetached
372365
- HandleEnable
373366
- HandleDisable
367+
374368
**Note:** For other callbacks implement IStart, IUpdate, IFixedUpdate, ILateUpdate interfaces
375369

376370
Generate providers:

0 commit comments

Comments
 (0)