godotengine / godotengine/godot-cpp

c++ GDExtension how to get Autoload Global Data

Open
#1,623 2 comments 0 reactions 0 assignees View on GitHub
Dominant language
C++
Stars
2.7k
Forks
809
Avg merge
1d 3h
Merged PRs (30d)
8

Description

### Godot version

4.3

### godot-cpp version

4.3

### System information

Window10 godot-cpp4.3

### Issue description

ERROR: Failed to retrieve non-existent singleton 'GlobalEcgResObj'.
at: (core/config/engine.cpp:294)

![image](https://github.com/user-attachments/assets/7baad865-a088-4e5b-bb4e-e770630b284b)
![image](https://github.com/user-attachments/assets/f738fcee-e8f0-429c-9548-e7b610a6005f)
![image](https://github.com/user-attachments/assets/f4bc3481-bbdb-48d5-addf-262f7c85023f)

### Steps to reproduce

// 获取 GlobalEcgResObj 单例
Object *global_ecg_res_obj = Engine::get_singleton()->get_singleton("GlobalEcgResObj");

// 检查是否成功获取单例
if (global_ecg_res_obj) {
// 获取 check_uid 变量的值
Variant check_uid_variant = global_ecg_res_obj->get("check_uid");

// 转换为字符串类型
String check_uid_str = check_uid_variant.operator String();

// 打印输出
UtilityFunctions::print("check_uid: " + check_uid_str);
} else {
UtilityFunctions::print("Failed to GlobalEcgResObj singleton.");
}

### Minimal reproduction project

Failed to GlobalEcgResObj singleton.

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.