// Copyright (c) 2012-2022 Wojciech Figat. All rights reserved. using System; using FlaxEditor.Content.Create; using FlaxEditor.Content.Settings; using FlaxEngine; namespace FlaxEditor.Content { /// /// Content proxy for json settings assets (e.g or ). /// /// public sealed class SettingsProxy : JsonAssetProxy { private readonly Type _type; private readonly SpriteHandle _thumbnail; /// /// Initializes a new instance of the class. /// /// The settings asset type (must be subclass of SettingsBase type). /// Asset icon. public SettingsProxy(Type type, SpriteHandle thumbnail) { _type = type; TypeName = type.FullName; _thumbnail = thumbnail; } /// public override string Name => "Settings"; //public override string Name { get; } = CustomEditors.CustomEditorsUtil.GetPropertyNameUI(_type.Name); /// public override bool CanCreate(ContentFolder targetLocation) { // Use proxy only for GameSettings for creating if (_type != typeof(GameSettings)) return false; return targetLocation.CanHaveAssets; } /// public override void Create(string outputPath, object arg) { Editor.Instance.ContentImporting.Create(new SettingsCreateEntry(outputPath)); } /// public override AssetItem ConstructItem(string path, string typeName, ref Guid id) { return new JsonAssetItem(path, id, typeName, _thumbnail); } /// public override bool IsProxyFor() { return typeof(T) == _type; } /// public override string TypeName { get; } } }