// Copyright (c) 2012-2021 Wojciech Figat. All rights reserved. using System; using FlaxEngine; namespace FlaxEditor.Content.Create { /// /// Visual Script asset creating handler. Allows to specify base class to inherit from. /// /// public class VisualScriptCreateEntry : CreateFileEntry { /// /// The create options. /// public class Options { /// /// The template. /// [TypeReference(typeof(FlaxEngine.Object), nameof(IsValid))] [Tooltip("The base class of the new Visual Script to inherit from.")] public Type BaseClass = typeof(Script); private static bool IsValid(Type type) { return (type.IsPublic || type.IsNestedPublic) && !type.IsSealed && !type.IsGenericType; } } private readonly Options _options = new Options(); /// public override object Settings => _options; /// /// Initializes a new instance of the class. /// /// The result file url. public VisualScriptCreateEntry(string resultUrl) : base("Settings", resultUrl) { } /// public override bool Create() { return Editor.CreateVisualScript(ResultUrl, _options.BaseClass?.FullName); } } }