Version: 2020.2
言語: 日本語
プラグイン
マネージプラグイン

プラグインインスペクター

Use the Plugin Inspector to specify the conditions under which Unity loads and references a plug-in file. You can also specify various other platform-specific settings for a plug-in.

Select a plug-in file in the Project window to view the Plugin Inspector:

MyPlugin.dll のプラグインインスペクター
MyPlugin.dll のプラグインインスペクター

General

The Auto Reference setting controls how a plug-in file is referenced by other assemblies and assembly definitions in the project.

If Auto Reference is enabled, which is the default, then all predefined assemblies and assembly definitions automatically reference the plug-in file. Disable Auto Reference if you want to explicitly declare references to the plug-in instead.

You can declare references to a plug-in file for an assembly definition using the Assembly Definition Inspector window. See Script Compilation and Assembly Definition Files for more information.

When you disable Auto Reference you cannot reference a plug-in from the predefined assemblies created for your project by Unity. These predefined assemblies contain all the scripts in your project that you have not assigned to another assembly using an assembly definition file. Only code included in an assembly created with an assembly definition file can reference classes, functions, or other resources in a plug-in that has the Auto Reference property disabled.

The Auto Reference option has no effect on whether a file is included in the build. When you disable the Auto Reference option, Unity will not automatically reference the file during compilation. To control Build Settings for plug-ins use Platform settings.

Disable Auto Reference in order to limit the scope in which a plug-in can be referenced by explicitly declaring all references to that plug-in. For example, if only one set of scripts in your project use a plug-in, you could create an assembly definition file for those scripts and create an explicit reference to the plug-in. Because the plug-in is no longer automatically referenced throughout your project, other scripts in your project cannot mistakenly use the plug-in. (More than one assembly can use the plug-in, but all assemblies must explicitly declare the dependency.) Also, if you change the plug-in, only the dependent assemblies must be recompiled, not your entire project.

You can also use explicit references to plug-ins to prevent plug-ins used in an Asset package from conflicting with other code in a project into which the package is imported.

Select platforms for plugin

Use the Select platforms for plugin setting to define the platforms with which a plug-in file is compatible and should be used on. The list of platforms includes the Editor itself (for Play mode and for any scripts that run at edit time), Standalone, and platforms for which you have installed Unity build support, such as Android, iOS, and WebGL.

Any Platform をチェックし、任意で個々のプラットフォームを除外できます。または、Any Platform のチェックを外し、任意で、個々のプラットフォームを加えることもできます。

Platform settings

プラットフォームを選択したら、CPU タイプや特定の OS などの追加オプションを Platform settings (プラットフォーム設定) セクションで指定できます。Inspector ウィンドウのこのセクションには、選択した各プラットフォームのタブがあります。プラットフォームには設定がまったくないものもあれば、CPU や OS の選択など、少数のものもあります。

When possible, the Inspector only shows settings that apply to the plug-in type on a specific platform. For example, for a native plug-in file with a .dll extension, the Inspector only shows the options that apply to Windows since such a plug-in can only be used on Windows.

Note: Native plug-ins cannot be unloaded. If a plug-in has already been loaded by the Editor, it remains loaded even after you change the settings for that plug-in in the same Editor session. To unload the plug-in, you must restart Unity.

エディター設定

Use the Editor platform settings to specify the CPU architectures and operating systems with which the plug-in is compatible.

エディタータブのオプション
エディタータブのオプション

Most managed plug-ins are compatible with any CPU and OS, but native plug-ins are typically only compatible with a single OS and, depending on how they were compiled, might be compatible with only a single CPU architecture.

For instance, if you select CPU X86, Unity loads the plug-in when you run an older, 32-bit version of the Editor, but not when you run a 64-bit version.

Similarly, if you select OS Windows, Unity loads the plug-in when running the Editor on Windows systems, but not on OS X or Linux systems.

スタンドアロン設定

スタンドアロンプラットフォーム、Windows、OS X、Linux では、ライブラリに互換性のある CPU アーキテクチャを選択できます。マネージライブラリは通常、特定のシステム API にアクセスしない限り、どの OS やアーキテクチャとも互換性があります。ネイティブライブラリは、1 つの OS にのみ互換性がありますが、32 ビット、64 ビット、または両方の CPU アーキテクチャと互換性があります。

スタンドアロンプラットフォームの Player 設定 も参照してください。

ユニバーサル Windows プラットフォーム (UWP)

Universal Windows Platform plug-in settings are covered in their own section. For more information, see Universal Windows Platform: Plugins on IL2CPP Scripting Backend.

Android

For plug-in files that are potentially compatible with Android, you can choose the CPU architecture. The chosen architecture must match the architecture for which the library was compiled. Unity does not validate whether you choose the correct setting.

iOS と tvOS

The iOS and tvOS settings allow you to specify which iOS frameworks a plug-in depends upon, if any.

iOS プラグイン設定。フレームワークの依存関係を表示
iOS プラグイン設定。フレームワークの依存関係を表示

For dynamically loaded libraries, as well as for bundles and frameworks containing dynamically loaded libraries or any assets and resources that need to be loaded at run time, check the Add to Embedded Binaries option. When you check this option, Unity sets the Xcode project options to copy the plug-in file into the final application package.

For plug-in source code files, which must be compiled as part of the build, you can specify any flags needed when compiling in the Compile Flags field.

Define Constraints

Use the Define Constraints setting to specify symbols that must be defined (or undefined) in order for the plug-in file to be used.

Unity only loads and references a plug-in if all the Define Constraints are satisfied. Constraints work like the #if preprocessor directive in C#, but on the assembly level instead of the script level. All the symbols in the Define Constraints setting must be defined for the constraints to be satisfied. You can also specify that a symbol must be undefined by prefixing it with a negating ! (bang) symbol. For example, if you specify the following symbols as your Define Constraints:

制約の定義
制約の定義

制約は、シンボル ENABLE_IL2CPP否定する定義 がされ、シンボル UNITY_2018_3_OR_NEWER定義 するときに満たされます。言い換えると、このアセンブリは、Unity 2018.3 以降の IL2CPP 以外のスクリプティングランタイムでのみロードされ、参照されます。

You can use any of Unity’s built-in define symbols or any symbols defined in the project’s Scripting Define Symbols Player setting. See Platform dependent compilation for more information, including a list of the built-in symbols. Note that the Scripting Define Symbols settings are platform-specific. Make sure that you define the necessary symbols on all the relevant platforms.

プラグインの検出

Unity detects whether a file in your Assets folder is a plug-in by its file extension. It treats files with the following extensions as plug-ins:

  • .dll
  • .winmd
  • .so
  • .jar
  • .aar
  • .xex
  • .def
  • .suprx
  • .prx
  • .sprx
  • .rpl
  • .cpp
  • .cc
  • .c
  • .h
  • .jslib
  • .jspre
  • .bc
  • .a
  • .m
  • .mm
  • .swift
  • .xib
  • .dylib

Unity also treats certain folders as bundle plug-ins. Unity does not look for additional plug-in files within such folders, so everything within the folder is considered a single plug-in. Unity detects whether a folder is a bundle plug-in when it has one of the following extensions:

  • .framework
  • .bundle
  • .plugin

Finally, Unity treats folders found with a parent path matching exactly Assets/Plugins/Android/ as an Android Library plug-in folder. Unity handles such folders in the same way as folders with the special extensions: .plugin, .bundle and .framework.

デフォルト設定

Unity sets defaults for the import settings of a plug-in file according to the folder where the plug-in is located:

フォルダー デフォルト設定
Assets/../Editor Plug-in will be set only compatible with Editor, and won’t be used when building to platform.
Assets/../Editor/(x86x86_64x64) Plug-in will be set only compatible with Editor, CPU value will be assigned depending on the subfolder.
Assets/../Plugins/(x86_64x64) x64 Standalone plug-ins will be set as compatible.
Assets/../Plugins/x86 x86 Standalone plug-ins will be set as compatible.
Assets/Plugins/iOS Plug-in will be set only compatible with iOS.
Assets/Plugins/WSA/(x86ARM) Plug-in will be set only compatible with Universal Windows Platform, if subfolder is CPU present, CPU value will be set as well. Metro keyword can be used instead of WSA.
Assets/Plugins/WSA/(SDK80SDK81PhoneSDK81) 上記と同じで SDK に応じて使用するプラグインを割り当てることができます。また CPU のサブフォルダーを追加することも可能です。互換性を持たせるために、SDK81 は Win81 と同じで、PhoneSDK81 は WindowsPhone81 と同じ意味になります。
Assets/Plugins/Tizen Plug-in will be set only compatible with Tizen.
Assets/Plugins/PS4 Plug-in will be set only compatible with Playstation 4.
プラグイン
マネージプラグイン
Copyright © 2023 Unity Technologies
优美缔软件(上海)有限公司 版权所有
"Unity"、Unity 徽标及其他 Unity 商标是 Unity Technologies 或其附属机构在美国及其他地区的商标或注册商标。其他名称或品牌是其各自所有者的商标。
公安部备案号:
31010902002961