[Unity] 编辑器扩展学习(八)

[ScriptableWizard]

向导式的编辑窗口.

使用方式:

using UnityEditor;

public class EnemyChange : ScriptableWizard {
    public int EnemyHealth = 10;

    [MenuItem("Tools/DisPlay")]
    static void Dispalywizard()
    {
        ScriptableWizard.DisplayWizard<EnemyChange>("统一修改敌人");
    }
}

createButtonName : 确定按钮的名字.
errorString : 错误提示.
helpString : 帮助提示.
isValid : 底下按钮是否可点.

效果:

1

例如:

using System.Collections;
using System.Collections.Generic;
using UnityEditor;
using UnityEngine;
 
public class TestScriptableWizard : ScriptableWizard
{
    public string s = "aaa";
    public int i = 500;
    public Color color = Color.red;
 
    [MenuItem("TestMenu/MyScriptableWizard")]  
    //弹出窗口调用
    static void CreateWizard()
    {
        ScriptableWizard.DisplayWizard<TestScriptableWizard>("MyTestMenu", "确定", "应用");
        Debug.Log("CreateWizard");
    }
    //开启窗口或数据更新时调用
    void OnWizardUpdate()
    {
        helpString = "帮助或说明……";
        Debug.Log("OnWizardUpdate");
    }
    //当用户按下"应用"时被调用,保存设置但不关闭窗口
    void OnWizardOtherButton()
    {
        Debug.Log("OnWizardOtherButton");
    }
    //点击"确定"时调用,关闭窗口并保存设置
    void OnWizardCreate()
    {
        Debug.Log("OnWizardCreate");
    }
}

效果:

2

本文链接:

https://eggmo.net/archives/210/

转载请注明文章链接地址!Thanks♪(・ω・)ノ

1 + 2 =
快来做第一个评论的人吧~