class in UnityEditor.Experimental.U2D
切换到手册Sprite Editor 窗口自定义模块继承内容的基类。
Sprite Editor 窗口功能可通过提供自定义模块进行扩展。通过继承 SpriteEditorModuleBase,用户将能从 Sprite Editor 窗口激活模块的功能。
using UnityEditor.Experimental.U2D; using UnityEngine;
public class MySpriteEditorCustomModule : SpriteEditorModuleBase { // The name of the module that will be shown in Sprite Editor Window drop down menu public override string moduleName { get { return "MySpriteEditorCustomModule"; } }
// This is called when user clicks on the Apply or Revert button in Sprite Editor Window public override bool ApplyRevert(bool apply) { return true; }
// Indicates if the module can be activated with the current ISpriteEditor state public override bool CanBeActivated() { return true; }
// Called after SpriteEditorWindow drawn the sprite. // UnityEditor.Handles draw calls will operate in Texture space public override void DoMainGUI() {}
// Draw user tool bar public override void DoToolbarGUI(Rect drawArea) {}
// Called when the module is activated by user public override void OnModuleActivate() {}
// Called when user switches to another module public override void OnModuleDeactivate() {}
// Any last GUI draw. This is in the SpriteEditorWindow's space. // Any GUI draw will appear on top public override void DoPostGUI() {} }
moduleName | 将显示在 Sprite Editor 窗口中的模块名称。 |
spriteEditor | 将模块实例化的 ISpriteEditor 实例。 |
ApplyRevert | 这将在用户单击 Sprite Editor 窗口中的 Apply 或 Revert 按钮时调用。 |
CanBeActivated | 表明模块能否通过当前的 ISpriteEditor 状态激活。 |
DoMainGUI | 实现此方法以在 Sprite Editor 窗口中绘制。 |
DoPostGUI | 实现此方法以在 Sprite Editor 窗口中绘制小部件。 |
DoToolbarGUI | 实现此方法以创建自定义工具栏。 |
OnModuleActivate | 当用户激活模块时调用此方法。 |
OnModuleDeactivate | 当用户切换至其他模块时调用此方法。 |
Did you find this page useful? Please give it a rating:
Thanks for rating this page!
What kind of problem would you like to report?
Thanks for letting us know! This page has been marked for review based on your feedback.
If you have time, you can provide more information to help us fix the problem faster.
Provide more information
You've told us this page needs code samples. If you'd like to help us further, you could provide a code sample, or tell us about what kind of code sample you'd like to see:
You've told us there are code samples on this page which don't work. If you know how to fix it, or have something better we could use instead, please let us know:
You've told us there is information missing from this page. Please tell us more about what's missing:
You've told us there is incorrect information on this page. If you know what we should change to make it correct, please tell us:
You've told us this page has unclear or confusing information. Please tell us more about what you found unclear or confusing, or let us know how we could make it clearer:
You've told us there is a spelling or grammar error on this page. Please tell us what's wrong:
You've told us this page has a problem. Please tell us more about what's wrong:
Thank you for helping to make the Unity documentation better!
Your feedback has been submitted as a ticket for our documentation team to review.
We are not able to reply to every ticket submitted.