ScriptableWizard.OnWizardOtherButton()

Unity · Версия 2020.3 LTS · Scripting · ScriptableWizard

ScriptableWizard.OnWizardOtherButton()

Описание

Позволяет указать действие, когда пользователь нажимает другую кнопку.

Здесь вы можете реализовать все, что будет сделано, если пользователь выберет дополнительный параметр при вызове DisplayWizard.

Смотрите так же: ScriptableWizard.DisplayWizard

ScriptableWizard с кнопкой «Другое», в данном случае с именем «Информация».
// Отобразить окно, показывающее расстояние между двумя объектами при нажатии кнопки "Информация".

using UnityEngine;
using UnityEditor;

public class ScriptableWizardOnWizardOtherButton : ScriptableWizard
{
    public Transform firstObject = null;
    public Transform secondObject = null;

    [MenuItem("Example/Show OnWizardOtherButton Usage")]
    static void CreateWindow()
    {
        ScriptableWizard.DisplayWizard("Click info to know the distance between the objects",
            typeof(ScriptableWizardOnWizardOtherButton), "Finish!", "Info");
    }

    void OnWizardUpdate()
    {
        if (firstObject == null || firstObject == null)
        {
            isValid = false;
            errorString = "Select the objects you want to measure";
        }
        else
        {
            isValid = true;
            errorString = "";
        }
    }

    // Called when you press the "Info" button.
    void OnWizardOtherButton()
    {
        float distanceObjs = Vector3.Distance(firstObject.position, secondObject.position);
        EditorUtility.DisplayDialog(
            "The distance between the objects is: " + distanceObjs + " Units",
            "",
            "Ok");
    }

    // Called when you press the "Finish!" button.
    void OnWizardCreate()
    {
    }
}

Обновлено 17 ноября 2026 г.