mirror of
https://github.com/MirrorNetworking/Mirror.git
synced 2024-11-18 02:50:32 +00:00
feat: Adding default folder as argument for ScriptableObjectUtility (#2513)
This allows ScriptableObjectUtility to be used for other folders not just Asset/Mirror
This commit is contained in:
parent
220c98a25e
commit
1cf5930d51
@ -7,11 +7,12 @@ namespace Mirror.EditorScripts.Logging
|
||||
{
|
||||
public static class LogLevelsGUI
|
||||
{
|
||||
const string DefaultFolder = "Assets/Mirror/";
|
||||
public static LogSettings DrawCreateNewButton()
|
||||
{
|
||||
if (GUILayout.Button("Create New"))
|
||||
{
|
||||
return ScriptableObjectUtility.CreateAsset<LogSettings>(nameof(LogSettings));
|
||||
return ScriptableObjectUtility.CreateAsset<LogSettings>(nameof(LogSettings), DefaultFolder);
|
||||
}
|
||||
|
||||
return null;
|
||||
|
@ -5,12 +5,18 @@ namespace Mirror.EditorScripts
|
||||
{
|
||||
public static class ScriptableObjectUtility
|
||||
{
|
||||
/// <summary>
|
||||
// This makes it easy to create, name and place unique new ScriptableObject asset files.
|
||||
/// </summary>
|
||||
const string DefaultMirrorFolder = "Assets/Mirror/";
|
||||
|
||||
[System.Obsolete("Use CreateAsset<T>(string defaultName, string defaultFolder) instead")]
|
||||
public static T CreateAsset<T>(string defaultName) where T : ScriptableObject
|
||||
=> CreateAsset<T>(defaultName, DefaultMirrorFolder);
|
||||
|
||||
/// <summary>
|
||||
/// This makes it easy to create, name and place unique new ScriptableObject asset files.
|
||||
/// </summary>
|
||||
public static T CreateAsset<T>(string defaultName, string defaultFolder) where T : ScriptableObject
|
||||
{
|
||||
string path = SavePanel(defaultName);
|
||||
string path = SavePanel(defaultName, defaultFolder);
|
||||
// user click cancel
|
||||
if (string.IsNullOrEmpty(path)) { return null; }
|
||||
|
||||
@ -21,11 +27,11 @@ public static T CreateAsset<T>(string defaultName) where T : ScriptableObject
|
||||
return asset;
|
||||
}
|
||||
|
||||
static string SavePanel(string name)
|
||||
static string SavePanel(string name, string defaultFolder)
|
||||
{
|
||||
string path = EditorUtility.SaveFilePanel(
|
||||
"Save ScriptableObject",
|
||||
"Assets/Mirror/",
|
||||
defaultFolder,
|
||||
name + ".asset",
|
||||
"asset");
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user