agentsclimarketplace

Unity csharp memory stripping

Skill meyverick/agy-skills/skills/unity-csharp-memory-stripping

A collection of elite, modular, and validated AI agent skills and system rules for Google Antigravity.

Install
npx -y skills add meyverick/agy-skills --skill unity-csharp-memory-stripping

Assembled from the repository path, not quoted from the project. Check it against their README if it does not work.

One thing to look at

  • 0 stars0 stars. Stars are a popularity signal and not a quality one, but at this level it is likely that nobody has read this closely except its author, and you would be relying on your own review.

What its author says it does

Copied from the file, not written here

Optimizes C# script compilation for WebGL, reducing the size of the final compiled WebAssembly binary by minimizing heavy dependencies and GC allocations.

SKILL.md

1.9 KB, 383 tokens by cl100k_base, as published. Nobody here has run it

Unity C# Memory Stripping

This skill teaches how to write lightweight C# code that avoids compiling down to heavy WebAssembly instructions, strictly targeting WebGL playable ads.

Core Rules

  1. YAGNI (You Aren't Gonna Need It): Do not use System.Reflection, dynamic generics, or LINQ. These force IL2CPP to generate thousands of lines of WebAssembly boilerplate.
  2. Defensive Programming & GC Optimization: Avoid Garbage Collection (GC) spikes in Update(). Pre-allocate arrays and use struct-based Math (e.g., Unity's native Vector3 instead of complex custom classes).
  3. Assembly Linker Configuration: Use a strict link.xml file to explicitly preserve only the necessary components while allowing aggressive stripping of the rest of the Unity engine assemblies.
  4. Green Software Engineering: Reduced WASM payload sizes directly translate to faster loading times and lower energy consumption.

Reference Example

// Anti-Pattern (Heavy WebAssembly generated due to LINQ and dynamic allocation)
using System.Linq;

void Update() {
    var activeEnemies = allEnemies.Where(e => e.isActive).ToList();
    // Heavy GC allocation every frame
}

// Optimized Pattern (Lightweight WASM, zero GC allocation)
void Update() {
    for (int i = 0; i < allEnemies.Length; i++) {
        if (allEnemies[i].isActive) {
            // Process directly
        }
    }
}

Example link.xml to protect essential scripts while stripping others:

<linker>
  <assembly fullname="UnityEngine">
    <type fullname="UnityEngine.MonoBehaviour" preserve="all"/>
  </assembly>
  <assembly fullname="Assembly-CSharp">
    <type fullname="GameController" preserve="all"/>
  </assembly>
</linker>

Keep looking

Skills are one crate of 328,083. Ordering is by how many stacks a row turns up in, so the top of any crate is what has actually been picked rather than what has the most stars.