An advanced link.xml file generator for Unity projects with support for multiple resource types and automated section management.
LinkXmlGenerator is a Unity Editor utility that automatically generates and updates the link.xml file required for proper IL2CPP builds. The generator supports various resource types and preserves existing manual rules in the file. It also includes LinkXmlGeneratorAsset - a ScriptableObject-based solution for easy configuration through Unity Inspector.
- ✅ Multiple Resource Types: Support for namespaces, types, assemblies, regex patterns, and base types
- ✅ ScriptableObject Asset: Easy configuration through Unity Inspector with LinkXmlGeneratorAsset
add into your manifest.json dependencies section:
"com.unigame.linkxml.generator": "https://github.com/UnioGame/linkxml.generator"
- Create Asset:
- Right-click in Project window → Create → UniGame/Tools/Link Xml Generator Asset
 
- Configure Resources: The modern UI Toolkit editor provides an enhanced interface:
- Search & Filter: Real-time search by value to quickly find resources
- Add Buttons: Convenient "Add [Type]" buttons for all resource types
 
- Generate: Click the prominent "Generate Link XML" button or use context menu
- Namespace Resources: Enter namespace name (e.g., "MyProject.Core")
- Base Type Resources: Enter full type name (e.g., "UnityEngine.MonoBehaviour") to include the type + all inheritors
- Concrete Type Resources: Enter exact type name (e.g., "MySpecificClass")
- Regex Pattern Resources: Enter regex pattern (e.g., ".*Controller$")
- Assembly Resources: Enter assembly name (e.g., "MyProject.Runtime")
using System;
using UnityEngine;
            LinkXmlResource.FromRegex(@".*Controller$"), // all classes ending with "Controller"
            LinkXmlResource.FromRegex(@"^MyProject\.Data\..*"), // all types in MyProject.Data
            
            // Include entire assembly
            LinkXmlResource.FromAssembly("MyProject.Runtime"),
        };
        LinkXmlGenerator.GenerateFromResources(resources);
    }
}Includes all types in the specified namespace and its sub-namespaces:
LinkXmlResource.FromNamespace("MyProject.Core")
// Will include: MyProject.Core.*, MyProject.Core.Utils.*, etc.Includes the base type itself and all its inheritors:
LinkXmlResource.FromBaseType(typeof(UIWindow))
LinkXmlResource.FromBaseType("MyProject.UI.UIWindow") // Using string type name
// Will include: UIWindow + all classes inheriting from UIWindowIncludes only the specified type:
LinkXmlResource.FromConcreteType("MySpecificClass")
LinkXmlResource.FromConcreteType(typeof(MyClass))Includes types whose names match the regex pattern:
LinkXmlResource.FromRegex(@".*Manager$")     // all classes ending with "Manager"
LinkXmlResource.FromRegex(@"^UI\..*")        // all types starting with "UI."
LinkXmlResource.FromRegex(@"Controller|Service|Handler") // multiple patternsIncludes all types in the specified assembly:
LinkXmlResource.FromAssembly("MyProject.Runtime")
// Creates: <assembly fullname="MyProject.Runtime" preserve="all"/><linker>
  <!-- You can keep your manual rules here -->
  
  <!-- BEGIN-AUTO-GENERATED-BY-LinkXmlNamespaceGenerator -->
  <!-- DO NOT EDIT MANUALLY: this section is regenerated by LinkXmlGenerator -->
  
  <!-- Entire assemblies -->
  <assembly fullname="MyProject.Runtime" preserve="all"/>
  
  <!-- Partial assemblies -->
  <assembly fullname="Assembly-CSharp">
    <namespace fullname="MyProject.Core" preserve="all"/>
    <namespace fullname="MyProject.Gameplay" preserve="all"/>
    <type fullname="MySpecificClass" preserve="all"/>
    <type fullname="SomeController" preserve="all"/>
  </assembly>
  
  <!-- END-AUTO-GENERATED-BY-LinkXmlNamespaceGenerator -->
  
  <!-- Your manual rules continue to work here -->
</linker>- Create: Right-click in Project window → Create → UniGame/Tools/Link Xml Generator Asset
- Configure:
- Add resources to the "Resources" list
- Set resource type and values
- Enable/disable individual resources
- Use legacy "Namespaces" and "Types" arrays for backward compatibility
 
- Generate: Click "Generate Link Xml" button or use context menu
The custom UI Toolkit editor provides convenient buttons:
- Add Namespace Resource: Quickly add a namespace resource
- Add Base Type Resource: Add a base type resource with MonoBehaviour as default
- Add Regex Resource: Add a regex pattern resource
- Add Assembly Resource: Add an entire assembly resource
- Add Concrete Type Resource: Add a specific type resource
The LinkXmlGeneratorAsset also maintains backward compatibility with legacy Namespaces and Types arrays.
The generator automatically excludes:
- Editor assemblies: *.Editor,*.EditorTests,UnityEditor
- Editor types: Types from UnityEditor.*namespace
- Generic definitions: Open generic types (only concrete types are included)
- Dynamic assemblies: Assemblies created at runtime
Use freely in your Unity projects.
