浏览代码

[CDB] Fix ctrl-Z on cdb that shows an error when there is prefab without name in datafiles

lviguier 11 月之前
父节点
当前提交
2f08558258
共有 2 个文件被更改,包括 5 次插入0 次删除
  1. 2 0
      hide/comp/cdb/DataFiles.hx
  2. 3 0
      hrt/prefab/Prefab.hx

+ 2 - 0
hide/comp/cdb/DataFiles.hx

@@ -679,6 +679,8 @@ class DataFiles {
 	public static function getPrefabsByPath(prefab: hrt.prefab.Prefab, path : String ) : Array<hrt.prefab.Prefab> {
 		function rec(prefab: hrt.prefab.Prefab, parts : Array<String>, index : Int, out : Array<hrt.prefab.Prefab> ) {
 			var name = parts[index++];
+			if (name == hrt.prefab.Prefab.emptyNameReplacement)
+				name = "";
 			if( name == null ) {
 				out.push(prefab);
 				return;

+ 3 - 0
hrt/prefab/Prefab.hx

@@ -58,6 +58,7 @@ class Prefab {
 		The name of the prefab in the tree view
 	**/
 	@:s public var name : String = "";
+	public static var emptyNameReplacement = "$no_name";
 
 	/**
 		The associated source file (an image, a 3D model, etc.) if the prefab type needs it.
@@ -492,6 +493,8 @@ class Prefab {
 		if(parent == null)
 			return "";
 		var path = name ?? "";
+		if (path == "")
+			path = hrt.prefab.Prefab.emptyNameReplacement;
 		if(unique) {
 			var suffix = 0;
 			for(i in 0...parent.children.length) {