/
TON618OFF
/
Unity-Project-RTU
Обзор
Документация
Войти
/
TON618OFF
/
Unity-Project-RTU
Код
Запросы
0
Задачи
Вики
Пакеты
0
Релизы
0
Аналитика
Безопасность
master
Library/PackageCache/com.unity.visualscripting@1.9.4/Runtime/VisualScripting.Flow/Framework/Control/Throw.cs
65 строк
2 KB
TON618OFF
release
03 окт 2024, 22:20
03 окт 2024, 22:20
7c70e9f
Код
Авторство
О чём код?
using System; namespace Unity.VisualScripting { /// <summary> /// Throws an exception. /// </summary> [UnitCategory("Control")] [UnitOrder(16)] public sealed class Throw : Unit { /// <summary> /// Whether a custom exception object should be specified manually. /// </summary> [Serialize] [Inspectable, UnitHeaderInspectable("Custom")] [InspectorToggleLeft] public bool custom { get; set; } /// <summary> /// The entry point to throw the exception. /// </summary> [DoNotSerialize] [PortLabelHidden] public ControlInput enter { get; private set; } /// <summary> /// The message of the exception. /// </summary> [DoNotSerialize] public ValueInput message { get; private set; } /// <summary> /// The exception to throw. /// </summary> [DoNotSerialize] public ValueInput exception { get; private set; } protected override void Definition() { if (custom) { enter = ControlInput(nameof(enter), ThrowCustom); exception = ValueInput<Exception>(nameof(exception)); Requirement(exception, enter); } else { enter = ControlInput(nameof(enter), ThrowMessage); message = ValueInput(nameof(message), string.Empty); Requirement(message, enter); } } private ControlOutput ThrowCustom(Flow flow) { throw flow.GetValue<Exception>(exception); } private ControlOutput ThrowMessage(Flow flow) { throw new Exception(flow.GetValue<string>(message)); } } }