mirror of
https://github.com/Siccity/xNode.git
synced 2026-03-26 22:49:02 +08:00
Fix SceneGraphs in Prefabs
Allow SceneGraphs to save to prefab assets if contained in one.
This commit is contained in:
parent
a1cf78d3fb
commit
f58d2bb392
@ -2,6 +2,7 @@ using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using UnityEditor;
|
||||
using UnityEditor.Experimental.SceneManagement;
|
||||
using UnityEngine;
|
||||
using XNodeEditor.Internal;
|
||||
|
||||
@ -227,18 +228,18 @@ namespace XNodeEditor {
|
||||
draggedOutput = null;
|
||||
draggedOutputTarget = null;
|
||||
EditorUtility.SetDirty(graph);
|
||||
if (NodeEditorPreferences.GetSettings().autoSave) AssetDatabase.SaveAssets();
|
||||
if (NodeEditorPreferences.GetSettings().autoSave) SaveAssets();
|
||||
} else if (currentActivity == NodeActivity.DragNode) {
|
||||
IEnumerable<XNode.Node> nodes = Selection.objects.Where(x => x is XNode.Node).Select(x => x as XNode.Node);
|
||||
foreach (XNode.Node node in nodes) EditorUtility.SetDirty(node);
|
||||
if (NodeEditorPreferences.GetSettings().autoSave) AssetDatabase.SaveAssets();
|
||||
if (NodeEditorPreferences.GetSettings().autoSave) SaveAssets();
|
||||
} else if (!IsHoveringNode) {
|
||||
// If click outside node, release field focus
|
||||
if (!isPanning) {
|
||||
EditorGUI.FocusTextInControl(null);
|
||||
EditorGUIUtility.editingTextField = false;
|
||||
}
|
||||
if (NodeEditorPreferences.GetSettings().autoSave) AssetDatabase.SaveAssets();
|
||||
if (NodeEditorPreferences.GetSettings().autoSave) SaveAssets();
|
||||
}
|
||||
|
||||
// If click node header, select it.
|
||||
@ -543,5 +544,12 @@ namespace XNodeEditor {
|
||||
if (NodeEditorPreferences.GetSettings().autoSave) AssetDatabase.SaveAssets();
|
||||
autoConnectOutput = null;
|
||||
}
|
||||
|
||||
/// <summary> Save assets normally or to prefab is contained in one </summary>
|
||||
private void SaveAssets(){
|
||||
PrefabStage prefabStage = PrefabStageUtility.GetCurrentPrefabStage();
|
||||
if (prefabStage == null) AssetDatabase.SaveAssets();
|
||||
else AssetDatabase.AddObjectToAsset(graph,prefabStage.prefabAssetPath);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user