mirror of
https://github.com/unity-atoms/unity-atoms.git
synced 2025-01-22 08:08:51 -05:00
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:
parent
0c1aaf7d3c
commit
47286f40a9
@ -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;
|
||||
|
Loading…
Reference in New Issue
Block a user