Godot 4 源码分析 - 获取属性信息

这篇具有很好参考价值的文章主要介绍了Godot 4 源码分析 - 获取属性信息。希望对大家有所帮助。如果存在错误或未考虑完全的地方,请大家不吝赐教,您也可以点击"举报违法"按钮提交疑问。

在管道通信基础上,可进行宿主程序与Godot的双向通信。

先拿属性信息试试手。

DrGraph端

static UnicodeString command = "Book.position";
if (InputQuery("输入窗口", "请输入待获取的属性信息", command)) {
	TDrStream_Get drGet(THelper::String::GetStringAt(command, L".", 0).Trim(),
						THelper::String::GetStringAt(command, L".", 1).Trim());
	TDllStream ds;
	ds << drGet;
	PipeStreamServer->WritePipe(ds, 1000);
}

Godot端(源码完善)

List<PropertyInfo> *p_list = new List<PropertyInfo>;
bool p_reversed = true;
destObject->get_property_list(p_list, p_reversed);
cofs << "OK";
for (List<PropertyInfo>::Iterator it = p_list->begin(); it != p_list->end(); ++it) {
	String content = it->name.ptr();
	if (it->class_name.operator String().is_empty() == false)
		content += str_format(U"[%s]", it->class_name.operator String().utf8().get_data());
	Variant value = destObject->get(it->name);
	content += str_format(U" = %s", value.operator String().utf8().get_data());
	cofs << content;
}
delete p_list;

运行结果

132. 13:20:29:829 > 【主线程】 > [Pipe.发送] > 发送数据中内容[DrGraph.28: Request - wait 1000 ms]: 
	[int]类型 > 值 = 2
	[UnicodeString]类型 > 值 = root
	[UnicodeString]类型 > 值 = propertyNames
133. 13:20:30:015 > 【主线程】 > [Pipe.Read] > 发送数据[DrGraph.28: Request - wait 1000 ms]成功返回 1837 字节... > PIPE响应中内容[godot -> DrGraph.28: Response - no return]: 
	[int]类型 > 值 = 3
	[UnicodeString]类型 > 值 = OK
	[UnicodeString]类型 > 值 = book.gd = <null>
	[UnicodeString]类型 > 值 = singlePage = false
	[UnicodeString]类型 > 值 = middleBarWidth = 0
	[UnicodeString]类型 > 值 = shader_rect[ColorRect] = ShaderRect:<ColorRect#26944209673>
	[UnicodeString]类型 > 值 = currentPageMode = false
	[UnicodeString]类型 > 值 = currentAreaType = -2
	[UnicodeString]类型 > 值 = triggleAreaMoment = 484887
	[UnicodeString]类型 > 值 = currentPageIndex = 30
	[UnicodeString]类型 > 值 = pageCount = 100
	[UnicodeString]类型 > 值 = pageImgPath = res://Pages/
	[UnicodeString]类型 > 值 = leftMouseDownMoment = 0
	[UnicodeString]类型 > 值 = underAutoTurnPage = false
	[UnicodeString]类型 > 值 = leftMouseDownPos = (0, 0)
	[UnicodeString]类型 > 值 = dllStream[DllStream] = <DllStream#67024979098>
	[UnicodeString]类型 > 值 = AutoTurnObject = <RefCounted#-9223372009692462322>
	[UnicodeString]类型 > 值 = Node2D = <null>
	[UnicodeString]类型 > 值 = Transform = <null>
	[UnicodeString]类型 > 值 = position = (0, 0)
	[UnicodeString]类型 > 值 = rotation = 0
	[UnicodeString]类型 > 值 = rotation_degrees = 0
	[UnicodeString]类型 > 值 = scale = (1, 1)
	[UnicodeString]类型 > 值 = skew = 0
	[UnicodeString]类型 > 值 = transform = [X: (1, 0), Y: (0, 1), O: (0, 0)]
	[UnicodeString]类型 > 值 = global_position = (0, 0)
	[UnicodeString]类型 > 值 = global_rotation = 0
	[UnicodeString]类型 > 值 = global_rotation_degrees = 0
	[UnicodeString]类型 > 值 = global_scale = (1, 1)
	[UnicodeString]类型 > 值 = global_skew = 0
	[UnicodeString]类型 > 值 = global_transform = [X: (1, 0), Y: (0, 1), O: (0, 0)]
	[UnicodeString]类型 > 值 = CanvasItem = <null>
	[UnicodeString]类型 > 值 = Visibility = <null>
	[UnicodeString]类型 > 值 = visible = true
	[UnicodeString]类型 > 值 = modulate = (1, 1, 1, 1)
	[UnicodeString]类型 > 值 = self_modulate = (1, 1, 1, 1)
	[UnicodeString]类型 > 值 = show_behind_parent = false
	[UnicodeString]类型 > 值 = top_level = false
	[UnicodeString]类型 > 值 = clip_children = 0
	[UnicodeString]类型 > 值 = light_mask = 1
	[UnicodeString]类型 > 值 = visibility_layer = 1
	[UnicodeString]类型 > 值 = Ordering = <null>
	[UnicodeString]类型 > 值 = z_index = 0
	[UnicodeString]类型 > 值 = z_as_relative = true
	[UnicodeString]类型 > 值 = y_sort_enabled = false
	[UnicodeString]类型 > 值 = Texture = <null>
	[UnicodeString]类型 > 值 = texture_filter = 0
	[UnicodeString]类型 > 值 = texture_repeat = 0
	[UnicodeString]类型 > 值 = Material = <null>
	[UnicodeString]类型 > 值 = material[CanvasItemMaterial,ShaderMaterial] = <Object#null>
	[UnicodeString]类型 > 值 = use_parent_material = false
	[UnicodeString]类型 > 值 = Node = <null>
	[UnicodeString]类型 > 值 = _import_path = 
	[UnicodeString]类型 > 值 = name = Book
	[UnicodeString]类型 > 值 = unique_name_in_owner = false
	[UnicodeString]类型 > 值 = scene_file_path = res://book.tscn
	[UnicodeString]类型 > 值 = owner[Node] = <Object#null>
	[UnicodeString]类型 > 值 = multiplayer[MultiplayerAPI] = <SceneMultiplayer#-9223372011168857310>
	[UnicodeString]类型 > 值 = Process = <null>
	[UnicodeString]类型 > 值 = process_mode = 0
	[UnicodeString]类型 > 值 = process_priority = 0
	[UnicodeString]类型 > 值 = Editor Description = <null>
	[UnicodeString]类型 > 值 = editor_description = 
	[UnicodeString]类型 > 值 = script[Script] = <GDScript#-9223372010984307965>

Godot 4 源码分析 - 获取属性信息,godot,java,服务器

 这已具备RTTI的雏形。 文章来源地址https://www.toymoban.com/news/detail-603665.html

到了这里,关于Godot 4 源码分析 - 获取属性信息的文章就介绍完了。如果您还想了解更多内容,请在右上角搜索TOY模板网以前的文章或继续浏览下面的相关文章,希望大家以后多多支持TOY模板网!

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处: 如若内容造成侵权/违法违规/事实不符,请点击违法举报进行投诉反馈,一经查实,立即删除!

领支付宝红包 赞助服务器费用

相关文章

  • Godot 4 源码分析 - Path2D与PathFollow2D

    学习演示项目dodge_the_creeps,发现里面多了一个Path2D与PathFollow2D  研究GDScript代码发现,它主要用于随机生成Mob 这个有这么大的作用,不明觉厉 但不知道如何下手 查看源码,有编辑器及类源码 先从应用角度,到B站上找找有没有视频,结果发现这个 Godot塔防游戏 - 01 -核心路径

    2024年02月14日
    浏览(28)
  • godot引擎c++源码深度解析系列二

    记录每次研究源码的突破,今天已经将打字练习的功能完成了一个基本模型,先来看下运行效果。 godot源码增加打字练习的demo 这个里面需要研究以下c++的控件页面的开发和熟悉,毕竟好久没有使用c++了,先来看以下代码吧。 就这样就实现了文本框,输入框和按钮的实现,以

    2024年02月15日
    浏览(36)
  • Godot引擎 4.0 文档 - 入门介绍 - Godot简介

    本文旨在帮助您确定 Godot 是否适合您。我们将介绍该引擎的一些广泛功能,让您了解使用它可以实现什么,并回答诸如“我需要了解什么才能开始使用?”等问题。 这绝不是详尽的概述。我们将在本入门系列中介绍更多功能。 Godot 是一个通用的 2D 和 3D 游戏引擎,您还可以

    2024年02月05日
    浏览(59)
  • 【Godot4自学手册】第一节配置Godot运行环境

    各位同学大家好!我是相信神话,从今天开始,我开始自学2D游戏开发,用到的是Godot4。我准备用视频记录整个开发过程,为自学2D开发的同学趟趟路。让我们开始吧。 首先介绍一下Godot是什么东西,在2D游戏开发中是干啥的? Godot是一款自由开源、由社区驱动的 2D 和 3D 游戏

    2024年01月23日
    浏览(50)
  • 【Godot测试】【在Godot中添加VRM模型和VMD动画并播放】

    观看本文最好是有点GD脚本编程基础 如果没有,请看:https://www.bilibili.com/video/BV1PJ411i7hK 需要的Godot版本不推荐超过3.3.3,因为实测当前最新的3.5标准版崩掉了 要问什么,那当然是作者插件发布日期推算出的版本号就是3.3.3或以下 已经测试Godot_v3.3.2-stable_win64和Godot_v3.3.3-stable

    2024年02月08日
    浏览(35)
  • Godot 4 练习 - 制作粒子

    演示项目dodge_the_creeps中,有一个Trail,具体运行效果 想要看看咋实现的,看完也不清晰,感觉是要设置某些关键的属性  ChatGPT说:以下是一些重要的属性: texture :用于渲染粒子的纹理。您可以使用一个2D纹理或者一个动画纹理(AnimatedTexture)。 size :粒子的尺寸。 speed :

    2024年02月14日
    浏览(68)
  • Godot 单元测试

    单元测试是我们常用的功能,Godot作为一个游戏,单元测试和热重载是我们常用的功能。这里我们讲解最简单的单元测试的情况。 我们添加一个最简单的节点,挂载一个最简单的脚本。 运行成功!

    2024年02月08日
    浏览(24)
  • Godot中的锚点

    关于锚点的用处,Godot的官方文档是如此叙述的。 如果一个游戏总是用同一分辨率在同样的设备上运行, 摆放控件将是一个简单的事, 只要逐个设置它们的位置属性和大小属性即可. 不幸的是, 能像这样处理的情况很少. 在游戏开发中,处理不同分辨率和纵横比的屏幕可以是一项

    2024年02月10日
    浏览(26)
  • 基于Godot的康威的生命游戏

    在_ready()函数中创建了一个“滑翔机”,坐标系以左上角为原点 创建了一个定时器,每隔0.1秒调用一次_on_timer_timeout(),所以更新代码也在这

    2024年02月17日
    浏览(41)
  • Godot 导出项目文件错误解决办法

    摘要: 1.必须在编辑器设置中配置rcedit工具(导出WindowsRcedit)才能修改图标或应用信息数据 [资源修改]:无法启动redit可执行文件。请在编辑器设置中配置recdit路径(导出WindowsRecdit),或在导出预设中禁用“应用修改资源”。  2.Error:Can’t run project: no main scene defined in the project.  本

    2024年02月06日
    浏览(22)

觉得文章有用就打赏一下文章作者

支付宝扫一扫打赏

博客赞助

微信扫一扫打赏

请作者喝杯咖啡吧~博客赞助

支付宝扫一扫领取红包,优惠每天领

二维码1

领取红包

二维码2

领红包