We consider to deep copy FSM and BT file including nested FSM and BT. Any idea?
Because of we actually want to deep copy of FSM file including Nested FSM files. so I though that there are 2 option I do,
1. Copy FSM and BT files and attach proper Nested xxx.asset (FSM file).
2. Deep copy of FSM file including nested FSM or BT files.
Do you mean creating a duplicate of a root asset graph along with duplicates of all sub-graphs instead of references to them?
If so, here is a NON tested way to do so recursively that should work. Commented code following:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
publicGraph DeepCopy(Graph original){
//create a duplicate asset of provided original. Maybe show file selection dialog?
varcopy=//your editor method to do so, like AssetDatabase.CreateAsset.
//make use of IGraphAssignable interface to find nodes that represent a sub-graph.
Hello,
This has now been added in the “gear” context menu of a graph asset. If you want, you can add this now manually as well, by opening Editor_Graph.cs file and adding this code at the end:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
[ContextMenu("Deep Duplicate")]
publicvoidDeepDuplicate(){
if(EditorUtility.DisplayDialog("Deep Duplicate","This will create a deep duplicate of this graph asset along with it's subgraphs. Continue?","Yes","No")){
DeepCopy(this);
}
}
///Make a deep copy of provided graph asset along with it's sub-graphs.
staticGraph DeepCopy(Graph root){
if(root==null){
returnnull;
}
varpath=EditorUtility.SaveFilePanelInProject("Duplicate of "+root.name,root.name+"_duplicate.asset","asset","");