Experimental: this API is experimental and might be changed or removed in the future.

RequireSpriteDataProviderAttribute

class in UnityEditor.Experimental.U2D

매뉴얼로 전환

설명

Use this attribute on a class that inherits from SpriteEditorModuleBase to indicate what data provider it needs.

When you use this attribute, Sprite Editor Window will only make the module available for selection if ISpriteEditorDataProvider.HasDataProvider returns true for all the data providers the module needs.

using UnityEditor.Experimental.U2D;
using UnityEngine;

[RequireSpriteDataProvider(typeof(ISpriteOutlineDataProvider), typeof(ITextureDataProvider))] public class MySpriteEditorCustomModule : SpriteEditorModuleBase { public override string moduleName { get { return "MySpriteEditorCustomModule"; } }

public override bool ApplyRevert(bool apply) { return true; }

public override bool CanBeActivated() { return true; }

public override void DoMainGUI() {}

public override void DoToolbarGUI(Rect drawArea) {}

public override void OnModuleActivate() { var outlineProvider = spriteEditor.GetDataProvider<ISpriteOutlineDataProvider>(); var spriteRects = spriteEditor.GetDataProvider<ISpriteEditorDataProvider>().GetSpriteRects(); foreach (var spriteRect in spriteRects) { // Access outline data Debug.Log(outlineProvider.GetOutlines(spriteRect.spriteID)); } }

public override void OnModuleDeactivate() {}

public override void DoPostGUI() {} }

생성자

RequireSpriteDataProviderAttributeUse the attribute to indicate the custom data provider that SpriteEditorBaseModule needs.
Copyright © 2023 Unity Technologies
优美缔软件(上海)有限公司 版权所有
"Unity"、Unity 徽标及其他 Unity 商标是 Unity Technologies 或其附属机构在美国及其他地区的商标或注册商标。其他名称或品牌是其各自所有者的商标。
公安部备案号:
31010902002961