Version: Unity 6.3 Beta (6000.3)
LanguageEnglish
  • C#
Method group is Obsolete

IShouldIncludeInBuildCallback

interface in UnityEditor.PackageManager

Suggest a change

Success!

Thank you for helping us improve the quality of Unity Documentation. Although we cannot accept all submissions, we do read each suggested change from our users and will make updates where applicable.

Close

Submission failed

For some reason your suggested change could not be submitted. Please <a>try again</a> in a few minutes. And thank you for taking the time to help us improve the quality of Unity Documentation.

Close

Cancel

Switch to Manual
Obsolete IShouldIncludeInBuildCallback interface is deprecated and will be removed in a later version, use PluginImporter.SetIncludeInBuildDelegate instead.

Description

Interface used by the Package Manager to request build information about packages.

During a build, the ShouldIncludeInBuild method is invoked on each managed plugin (DLL) inside the package whose name is PackageName.

Register your implementation with the Package Manager using BuildUtilities.RegisterShouldIncludeInBuildCallback. You can register only one implementation of this interface per package.

Consider using PluginImporter.SetIncludeInBuildDelegate for a simpler alternative.

using UnityEngine;
using UnityEditor;
using UnityEditor.PackageManager;

[ExecuteInEditMode] public class BuildCallbackExample : MonoBehaviour { void Start() { Debug.Log("IShouldIncludeInBuildCallback example..."); TestPluginInclusion(); }

void TestPluginInclusion() { var callback = new CustomPackageBuildCallback(); Debug.Log($"Checking plugins for package: {callback.PackageName}");

// Test with different plugin paths CheckPlugin(callback, "/Packages/com.mycompany.mypackage/Runtime/MyPlugin.dll"); CheckPlugin(callback, "/Packages/com.mycompany.mypackage/Editor/MyEditorPlugin.dll"); }

void CheckPlugin(IShouldIncludeInBuildCallback callback, string pluginPath) { bool include = callback.ShouldIncludeInBuild(pluginPath); Debug.Log($"Include plugin {pluginPath}: {include}"); } }

public class CustomPackageBuildCallback : IShouldIncludeInBuildCallback { public string PackageName => "com.mycompany.mypackage";

public bool ShouldIncludeInBuild(string path) { // Example: Include only plugins with "Runtime" in their path return path.Contains("Runtime"); } }