Files
XCEngine/docs/api/XCEngine/Scripting/Mono/MonoScriptRuntime/TryGetFieldValue.md

31 lines
764 B
Markdown
Raw Normal View History

# MonoScriptRuntime::TryGetFieldValue
**命名空间**: `XCEngine::Scripting`
**类型**: `method`
**头文件**: `XCEngine/Scripting/Mono/MonoScriptRuntime.h`
## 签名
```cpp
bool TryGetFieldValue(
const ScriptComponent* component,
const std::string& fieldName,
ScriptFieldValue& outValue) const;
```
## 当前实现行为
- 先通过组件找到实例缓存。
- 再检查类元数据中是否存在该字段。
- 成功时直接从托管对象读出字段值。
## 与 `TryGetManagedFieldValue` 的区别
这个接口用 `ScriptComponent*` 作为入口,更适合测试和诊断;`TryGetManagedFieldValue()` 则是实现 `IScriptRuntime` 接口的标准路径。
## 相关文档
- [TryGetManagedFieldValue](TryGetManagedFieldValue.md)