|
| 1 | +# JEngine Framework |
| 2 | + |
| 3 | +Unity framework for runtime hot updates. Unity 2022.3+, C#. |
| 4 | + |
| 5 | +## Available Packages |
| 6 | + |
| 7 | +### JEngine.Util (com.jasonxudeveloper.jengine.util) |
| 8 | +- **JAction**: Fluent API for chainable action sequences with zero-allocation async |
| 9 | +- **JObjectPool<T>**: Thread-safe generic object pool using lock-free CAS |
| 10 | + |
| 11 | +### JEngine.UI (com.jasonxudeveloper.jengine.ui) |
| 12 | +- **MessageBox**: Async modal dialogs with UniTask (runtime) |
| 13 | +- **Editor Components**: JButton, JTextField, JStack, JCard, etc. (editor) |
| 14 | +- **Design Tokens**: Theme-aware colors, spacing, typography |
| 15 | + |
| 16 | +## Key Patterns |
| 17 | + |
| 18 | +### Always Use UniTask (not System.Threading.Tasks.Task) |
| 19 | +```csharp |
| 20 | +using Cysharp.Threading.Tasks; |
| 21 | +public async UniTask<bool> LoadAsync() { } |
| 22 | +``` |
| 23 | + |
| 24 | +### JAction - Always Dispose After Async |
| 25 | +```csharp |
| 26 | +using var action = await JAction.Create() |
| 27 | + .Do(static () => Debug.Log("Start")) |
| 28 | + .Delay(1f) |
| 29 | + .Do(static () => Debug.Log("After 1s")) |
| 30 | + .ExecuteAsync(); |
| 31 | +``` |
| 32 | + |
| 33 | +### JObjectPool - Reset State on Return |
| 34 | +```csharp |
| 35 | +var pool = new JObjectPool<List<int>>( |
| 36 | + onReturn: static list => list.Clear() |
| 37 | +); |
| 38 | +var list = pool.Rent(); |
| 39 | +pool.Return(list); |
| 40 | +``` |
| 41 | + |
| 42 | +### MessageBox - Await the Result |
| 43 | +```csharp |
| 44 | +bool ok = await MessageBox.Show("Title", "Message?", "Yes", "No"); |
| 45 | +if (ok) { /* confirmed */ } |
| 46 | +``` |
| 47 | + |
| 48 | +### Editor UI - Use Design Tokens |
| 49 | +```csharp |
| 50 | +using JEngine.UI.Editor.Theming; |
| 51 | +using JEngine.UI.Editor.Components.Button; |
| 52 | +using JEngine.UI.Editor.Components.Layout; |
| 53 | + |
| 54 | +var stack = new JStack(GapSize.MD) |
| 55 | + .Add(new JButton("Action", () => DoIt(), ButtonVariant.Primary)); |
| 56 | +``` |
0 commit comments