Loxodon Framework Documentation

repository·master·Indexed 24 days ago

https://github.com/vovgou/loxodon-framework

A high-performance, lightweight MVVM and data-binding framework tailored for Unity3D development. It supports databinding, localization, and is compatible with MacOSX, Windows, Linux, UWP, IOS, and Android. The framework provides robust support for C#, XLua, and ILRuntime, and includes specialized plugins such as Loxodon.Framework.Addressable for Unity's Addressable Assets System and Loxodon.Framework.Connection for TCP-based communication with TLS encryption.

Tokens
97.5K
Snippets
165
Records
338
Agent score
80%

What's inside Loxodon Framework

  1. Overview of Loxodon Framework TextMeshPro

    master

    Loxodon Framework TextMeshPro provides TextMeshPro support for AlertDialog and Toast views, replacing the standard UnityEngine.UI.Text with TextMeshProUGUI to optimize UI performance.

    Key features include:

    • 0GC UI Updates: By depending on the Loxodon.Framework.TextFormatting plugin, this package uses FormattableTextMeshProUGUI and TemplateTextMeshProUGUI controls to update UI views with zero Garbage Collection (GC) overhead.
    • Requirements: Requires Unity 2021.3 or higher.
  2. Overview of Loxodon Framework Official Plugins

    master

    Loxodon Framework provides several specialized plugins to extend its functionality:

    • XLua: Lua MVVM framework for mixed C#/Lua programming and hot updates.
    • Localization For CSV: Supports localization using CSV files (requires Unity 2018.4+).
    • Bundle: A tool for loading/managing AssetBundles with automatic dependency management via reference counting. Supports asynchronous loading, weak caching, and encrypted bundles.
    • FairyGUI: Provides data binding support for FairyGUI controls.
    • Log4Net: Plugin for Unity logging using Log4Net, supporting remote debugging over LAN.
    • Obfuscation: Protects game data using obfuscated numeric types (requires "Allow unsafe code").
    • Addressable: Extends and supports the Unity Addressable Asset System.
  3. Overview of Loxodon Framework Fody plugins

    master

    Loxodon Framework Fody is a tool for static code weaving in Unity, integrating Fody to simplify code and improve development efficiency. It provides several specialized plugins:

    • PropertyChanged.Fody: Automatically injects INotifyPropertyChanged implementation into Model or ViewModel classes by adding specific annotations. Refer to the official PropertyChanged.Fody documentation for annotation details.
    • ToString.Fody: Automatically generates a ToString() function for a class when the [ToString] annotation is added.
    • BindingProxy.Fody: Performs static weaving on fields, properties, and methods of a ViewModel to create proxy classes. This optimizes performance during data binding by allowing proxy classes to access object properties and methods.
  4. Overview of Loxodon Framework Obfuscation

    master

    Loxodon Framework Obfuscation is a memory obfuscation plugin for Unity designed to prevent memory editors (like Cheat Engine) from modifying game values. It provides obfuscated versions of standard numeric data types.

    Supported types include:

    • ObfuscatedByte
    • ObfuscatedShort
    • ObfuscatedInt
    • ObfuscatedLong
    • ObfuscatedFloat
    • ObfuscatedDouble

    Key Features:

    • Supports all standard arithmetic operators for these types.
    • Provides automatic conversion between obfuscated types and standard types (byte, short, int, long, float, double).
    • For Float and Double, obfuscation uses bitwise operations on int and long representations to ensure no precision loss.
    • Uses unsafe code for high-performance type conversions.

    Requirements:

    • Unity 2018.4 or higher.
    • Important: You must enable "Allow unsafe Code" in your Unity Project Settings.
  5. Overview of Loxodon Framework

    master

    Loxodon Framework is a lightweight Model-View-ViewModel (MVVM) framework designed specifically for Unity3D game development. It draws inspiration from WPF and Android's MVVM patterns and is built using an object-oriented and interface-oriented approach.

    Core Capabilities:

    • Data Binding: Supports field, property (Two-Way), dictionary, list, event, and command binding. It also supports expression binding and observable attributes.
    • Asynchronous Programming: Provides async & await support for both C# and Lua, along with asynchronous results/tasks for threads and coroutines using a Future/Promise design model.
    • Service Container: A lightweight container for registering and locating services.
    • Localization: Android-style localization supporting basic data types, arrays, and Unity value types.
    • UI Framework: Provides universal controls (AlertDialog, Loading, Toast) and advanced UI view management.
    • Multi-platform Support: Compatible with PC/Mac/Linux, iOS, Android, UWP, and WebGL across .Net 4.x, .Net Standard 2.0, and IL2CPP.
  6. Overview of Loxodon Framework TextFormatting features

    master

    Loxodon Framework TextFormatting is a high-performance text formatting plugin for Unity (requires Unity 2021.3 or higher). It focuses on minimizing Garbage Collection (GC) during string operations.

    Key capabilities include:

    • Optimized StringBuilder: Extends AppendFormat to prevent boxing/unboxing of value types (numbers, DateTime, TimeSpan).
    • UGUI Integration: Provides TemplateText and FormattableText controls that support MVVM data binding and avoid boxing/unboxing.
    • TextMeshPro Integration: Provides TemplateTextMeshPro and FormattableTextMeshProUGUI controls for 0-GC game view updates.
  7. Overview of Loxodon Framework TextUGUI

    master

    Loxodon Framework TextUGUI is a text formatting plugin for Unity (requires Unity 2021.3 or higher) designed to minimize Garbage Collection (GC) overhead.

    Key features include:

    • Optimized String Formatting: Extends StringBuilder.AppendFormat to avoid GC when concatenating strings or converting numbers to strings.
    • UGUI Extensions: Introduces FormattableText and TemplateText controls that support MVVM data binding. These controls are optimized to avoid boxing/unboxing of value types during binding.
    • TextMeshPro Support: For even better performance, use TemplateTextMeshPro or FormattableTextMeshProUGUI from the Loxodon.Framework.TextMeshPro package to achieve near-zero GC updates in the game view.
  8. Overview of Loxodon Framework (Unity-MVVM)

    master

    Loxodon Framework is a lightweight MVVM (Model-View-ViewModel) framework specifically designed for Unity3D game development. It provides data binding between Views and ViewModels, localization, object containers, configuration components, thread tools, application/player contexts, and asynchronous task components (async/await, Task, Coroutines).

    Key characteristics include:

    • High Performance: Optimized data binding using dynamic delegates/static weaving to avoid reflection and boxing/unboxing, aiming for 0GC UI updates.
    • UI Support: Supports UGUI, UIToolkit, and FairyGUI, with easy extensibility for other UI systems.
    • Scripting Support: Compatible with C#, XLua, and ILRuntime. For hot-updates, it is recommended to use HybridCLR.
    • Architecture: Interface-oriented design allowing for high customizability.
    • Cross-Platform: Supports PC/Mac/Linux, iOS, Android, UWP (Windows 10), and WebGL.
  9. What is Loxodon Framework Obfuscation

    master

    Loxodon Framework Obfuscation is a memory obfuscation plugin for Unity designed to prevent memory editors (like Cheat Engine) from modifying game values. It provides obfuscated versions of standard numeric data types.

    Supported Types:

    • ObfuscatedByte
    • ObfuscatedShort
    • ObfuscatedInt
    • ObfuscatedLong
    • ObfuscatedFloat
    • ObfuscatedDouble

    Key Features:

    • Operator Support: Supports all standard numeric operators.
    • Automatic Conversion: Supports automatic conversion between obfuscated types and standard types (byte, short, int, long, float, double).
    • Precision Preservation: For Float and Double types, obfuscation is performed using int and long via bitwise OR/AND operations to ensure no precision loss.
    • Performance: Uses unsafe code for type conversions to maintain high performance.

    Requirements:

    • Unity 2018.4 or higher.
    • Crucial: You must enable "Allow unsafe Code" in your Unity Project Settings.
    ObfuscatedInt length = 200;
    ObfuscatedFloat scale = 20.5f;
    int offset = 30;
    
    float value = (length * scale) + offset;
  10. What is Loxodon Framework Fody?

    master

    Loxodon Framework Fody is a static code weaving tool that integrates Fody into Unity projects. It uses Fody plugins to simplify code and improve development efficiency by injecting boilerplate code at compile time.

    It currently provides Unity-compatible packages for:

    • PropertyChanged.Fody: Automatically generates INotifyPropertyChanged implementation and related code for Model or ViewModel classes using annotations.
    • ToString.Fody: Automatically generates/overloads the ToString function for classes using the [ToString] annotation.
    • BindingProxy.Fody: Performs static weaving of proxy classes for fields, properties, and methods in ViewModels. This optimizes performance during data binding by allowing the binding system to access object members through these injected proxies.
  11. What is Loxodon Framework TextFormatting and why use it?

    master

    Loxodon Framework TextFormatting is a C# library extension designed for Unity (requires Unity 2021.3 or higher) to optimize text operations.

    Its primary goal is to eliminate Garbage Collection (GC) allocations during string concatenation and number-to-string conversions. It achieves this by:

    1. Extending StringBuilder.AppendFormat<T> to handle value types without boxing.
    2. Providing specialized UI controls (in related packages like TextUGUI and TextMeshPro) that support MVVM data binding without boxing/unboxing value types.

    Use this framework when you need to update text frequently (e.g., every frame) and want to maintain high performance by minimizing memory pressure.

  12. Track progress with ProgressResult

    master

    For tasks that provide incremental updates (like file downloads), use ProgressResult<TProgress, TResult>. This allows you to listen to progress updates and the final result separately.

    • OnProgressCallback: Triggered whenever promise.UpdateProgress(progress) is called inside the task.
    • OnCallback: Triggered when the task is finished (IsDone).
    // Start a progressive task
    IProgressResult<Progress, string> result = StartTask();
    
    // Listen to progress updates
    result.Callbackable().OnProgressCallback(progress => {
        Debug.LogFormat("Percentage: {0}% ", progress.Percentage);
    });
    
    // Listen to the final result
    result.Callbackable().OnCallback(r => {
        Debug.LogFormat("IsDone:{0} Result:{1}", r.IsDone, r.Result);
    });