Creating new atom in current directory improvement (#184)

* small improvement for creating new atoms in inspector window

* fixed getting directory path instead of full file path
This commit is contained in:
IceTrooper 2020-08-04 01:09:52 +02:00 committed by GitHub
parent 0c1aaf7d3c
commit 47286f40a9
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -1,5 +1,6 @@
#if UNITY_2018_3_OR_NEWER
using System.Collections.Generic;
using System.IO;
using UnityEditor;
using UnityEngine;
@ -108,9 +109,11 @@ namespace UnityAtoms.Editor
{
try
{
string path = AssetDatabase.GetAssetPath(property.serializedObject.targetObject);
path = path == "" ? "Assets/" : Path.GetDirectoryName(path) + "/";
// Create asset
T so = ScriptableObject.CreateInstance<T>();
AssetDatabase.CreateAsset(so, "Assets/" + drawerData.NameOfNewAtom + ".asset");
AssetDatabase.CreateAsset(so, path + drawerData.NameOfNewAtom + ".asset");
AssetDatabase.SaveAssets();
// Assign the newly created SO
property.objectReferenceValue = so;