Browse Source

Avoid [] for external_animation_library import option

Some uses of operator[] were causing "rest_pose/external_animation_library": null to be added to the .import file.
Lyuma 1 year ago
parent
commit
e7de6f8725
1 changed files with 7 additions and 2 deletions
  1. 7 2
      editor/import/3d/scene_import_settings.cpp

+ 7 - 2
editor/import/3d/scene_import_settings.cpp

@@ -117,7 +117,9 @@ class SceneImportSettingsData : public Object {
 		ERR_FAIL_NULL(settings);
 		ERR_FAIL_NULL(settings);
 		if (r_option.name == "rest_pose/load_pose") {
 		if (r_option.name == "rest_pose/load_pose") {
 			if (!settings->has("rest_pose/load_pose") || int((*settings)["rest_pose/load_pose"]) != 2) {
 			if (!settings->has("rest_pose/load_pose") || int((*settings)["rest_pose/load_pose"]) != 2) {
-				(*settings)["rest_pose/external_animation_library"] = Variant();
+				if (settings->has("rest_pose/external_animation_library")) {
+					(*settings)["rest_pose/external_animation_library"] = Variant();
+				}
 			}
 			}
 		}
 		}
 		if (r_option.name == "rest_pose/selected_animation") {
 		if (r_option.name == "rest_pose/selected_animation") {
@@ -134,7 +136,10 @@ class SceneImportSettingsData : public Object {
 					}
 					}
 				} break;
 				} break;
 				case 2: {
 				case 2: {
-					Object *res = (*settings)["rest_pose/external_animation_library"];
+					Object *res = nullptr;
+					if (settings->has("rest_pose/external_animation_library")) {
+						res = (*settings)["rest_pose/external_animation_library"];
+					}
 					Ref<Animation> anim(res);
 					Ref<Animation> anim(res);
 					Ref<AnimationLibrary> library(res);
 					Ref<AnimationLibrary> library(res);
 					if (anim.is_valid()) {
 					if (anim.is_valid()) {