mirror of
https://github.com/Siccity/xNode.git
synced 2025-12-20 17:26:02 +08:00
Improved handling of null sub assets
Thanks to Lenny#3404 from the discord channel
This commit is contained in:
parent
369a3fd6ea
commit
c350c135ca
@ -6,7 +6,8 @@ namespace XNodeEditor {
|
|||||||
class NodeEditorAssetModProcessor : UnityEditor.AssetModificationProcessor {
|
class NodeEditorAssetModProcessor : UnityEditor.AssetModificationProcessor {
|
||||||
|
|
||||||
/// <summary> Automatically delete Node sub-assets before deleting their script.
|
/// <summary> Automatically delete Node sub-assets before deleting their script.
|
||||||
/// <para/> This is important to do, because you can't delete null sub assets. </summary>
|
/// This is important to do, because you can't delete null sub assets.
|
||||||
|
/// <para/> For another workaround, see: https://gitlab.com/RotaryHeart-UnityShare/subassetmissingscriptdelete </summary>
|
||||||
private static AssetDeleteResult OnWillDeleteAsset (string path, RemoveAssetOptions options) {
|
private static AssetDeleteResult OnWillDeleteAsset (string path, RemoveAssetOptions options) {
|
||||||
// Get the object that is requested for deletion
|
// Get the object that is requested for deletion
|
||||||
UnityEngine.Object obj = AssetDatabase.LoadAssetAtPath<UnityEngine.Object> (path);
|
UnityEngine.Object obj = AssetDatabase.LoadAssetAtPath<UnityEngine.Object> (path);
|
||||||
@ -51,6 +52,8 @@ namespace XNodeEditor {
|
|||||||
Object[] objs = AssetDatabase.LoadAllAssetRepresentationsAtPath (assetpath);
|
Object[] objs = AssetDatabase.LoadAllAssetRepresentationsAtPath (assetpath);
|
||||||
// Ensure that all sub node assets are present in the graph node list
|
// Ensure that all sub node assets are present in the graph node list
|
||||||
for (int u = 0; u < objs.Length; u++) {
|
for (int u = 0; u < objs.Length; u++) {
|
||||||
|
// Ignore null sub assets
|
||||||
|
if (objs[u] == null) continue;
|
||||||
if (!graph.nodes.Contains (objs[u] as XNode.Node)) graph.nodes.Add(objs[u] as XNode.Node);
|
if (!graph.nodes.Contains (objs[u] as XNode.Node)) graph.nodes.Add(objs[u] as XNode.Node);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user