res-avatar-unity/Packages/com.vrchat.core.vpm-resolver/Editor/PackageMaker/PackageMakerWindowData.cs

45 lines
1.3 KiB
C#
Raw Normal View History

2023-07-16 02:51:23 +00:00
using System.IO;
using UnityEditor;
using UnityEngine;
using VRC.PackageManagement.PackageMaker;
public class PackageMakerWindowData : ScriptableObject
{
public static string defaultAssetPath = Path.Combine("Assets", "PackageMakerWindowData.asset");
public string targetAssetFolder;
public string packageID;
public PackageMakerWindow.VRCPackageEnum relatedPackage;
public static PackageMakerWindowData GetOrCreate()
{
var existingData = AssetDatabase.AssetPathToGUID(defaultAssetPath);
if (string.IsNullOrWhiteSpace(existingData))
{
return Create();
}
else
{
var saveData = AssetDatabase.LoadAssetAtPath<PackageMakerWindowData>(defaultAssetPath);
if (saveData == null)
{
Debug.LogError($"Could not load saved data but the save file exists. Resetting.");
return Create();
}
return saveData;
}
}
public static PackageMakerWindowData Create()
{
var saveData = CreateInstance<PackageMakerWindowData>();
AssetDatabase.CreateAsset(saveData, defaultAssetPath);
AssetDatabase.SaveAssets();
return saveData;
}
public void Save()
{
AssetDatabase.SaveAssets();
}
}