You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 

56 lines
1.6 KiB

using System.IO;
using UnityEditor.Experimental;
using UnityEngine;
using UnityEngine.UIElements;
namespace UnityEditor.VFX.UI
{
class VFXSaveDropdownButton : DropDownButtonBase
{
public VFXSaveDropdownButton(VFXView vfxView)
: base(
nameof(VFXSaveDropdownButton),
vfxView,
"VFXSaveDropDownPanel",
"Save",
"save-button",
EditorResources.iconsPath + "SaveActive.png",
false,
true)
{
var saveAsButton = m_PopupContent.Q<Button>("saveAs");
saveAsButton.clicked += OnSaveAs;
var selectButton = m_PopupContent.Q<Button>("showInInspector");
selectButton.clicked += OnSelectAsset;
}
protected override Vector2 GetPopupSize() => new(150, 56);
protected override void OnMainButton()
{
m_VFXView.OnSave();
}
void OnSaveAs()
{
var originalPath = AssetDatabase.GetAssetPath(m_VFXView.controller.model);
var extension = Path.GetExtension(originalPath).Trim('.');
var newFilePath = EditorUtility.SaveFilePanelInProject("Save VFX Graph As...", Path.GetFileNameWithoutExtension(originalPath), extension, "", Path.GetDirectoryName(originalPath));
if (!string.IsNullOrEmpty(newFilePath))
{
m_VFXView.SaveAs(newFilePath);
}
ClosePopup();
}
void OnSelectAsset()
{
m_VFXView.SelectAsset();
}
}
}