1
0
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:
Samuel 2020-04-30 11:59:23 -03:00 committed by GitHub
parent a1cf78d3fb
commit f58d2bb392
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -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);
}
}
}