此问题旨在跟踪我们希望在下次有机会时重命名的笨拙命名或已弃用的方法、属性和信号。
这不能轻易完成,因为它破坏了使用旧名称的用户的兼容性,因此必须进行任何此类更改:
为了正确弃用方法、属性和信号,我们需要实现 #4397。
A :tada: @akien-mga 或@Calinou添加的反应意味着评论中的建议已合并到此帖子中。
OS*
可以重命名为Platform*
https://github.com/godotengine/godot/issues/16863#issuecomment -403253127Label
:考虑重命名为TextLabel
https://github.com/godotengine/godot/issues/16863#issuecomment -502517425PHashTranslation
应重命名为CompressedTranslation
(匹配其标题)ResourceFormat*
:检查所有继承ResourceFormatLoader
、 ResourceFormatSaver
和ImageFormatLoader
,检查它们是否遵循相同的命名约定(类和文件名)ShortCut
应该更名为Shortcut
https://github.com/godotengine/godot/issues/16863#issuecomment -685236980 #41926TCP_Server
和IP_Unix
应该重命名为TCPServer
和IPUnix
#37700Viewport
应该查看一下,它非常复杂,可能会被简化https://github.com/godotengine/godot/issues/16863#issuecomment -631789777@GDScript
(和其他几个地方): instance
当用作动词/动作时应该是instantiate
https://github.com/godotengine/godot/issues/ 16863#issuecomment -367061984@GDscript
: decimals
应该重命名为step_decimals
#21425@GDscript
: stepify
应该重命名为snapped
以与向量保持一致https://github.com/godotengine/godot/issues/16863#issuecomment -655258916AcceptDialog
和ConfirmationDialog
: get_ok
和get_cancel
应该是get_ok_button
和get_cancel_button
(匹配WindowDialog.get_close_button
) https://github.com/godotengine/godot/issues/16863#issuecomment -421071469AnimatedSprite2D
和AnimatedSprite3D
: stop
应该是pause
https://github.com/godotengine/godot/issues/31168Animation
: track_remove_key_at_position
应该是track_remove_key_at_time
AnimationPlayer
: play_backwards
可以删除https://github.com/godotengine/godot/issues/16863#issuecomment -490298187Area
: set_audio_bus
和get_audio_bus
应重命名为set_audio_bus_name
和get_audio_bus_name
以匹配相关属性及其Area2D
同行#29670Array
(一些更改也适用于 PackedArrays) https://github.com/godotengine/godot/issues/16863#issuecomment -441376010:remove
重命名remove_at
(按索引删除)以避免歧义erase
重命名remove_value
(按值删除)以避免歧义invert
重命名reverse
以使用更成熟的命名duplicate
重命名clone
以使用更成熟的命名empty
重命名is_empty
以清楚表明这是一个布尔检查而不是清空数组的操作Camera
: set_znear
和set_zfar
应该重命名以匹配near
和far
属性https://github.com/ godotengine/godot/issues/16863#issuecomment -412810788Control
:属性名称与其 setter/getter 名称之间的差异https://github.com/godotengine/godot/issues/16863#issuecomment -381420942CollisionShape
: make_convex_from_brothers
应该是make_convex_from_siblings
https://github.com/godotengine/godot/issues/16863#issuecomment -493794313EditorInterface
: get_editor_viewport
可能是get_editor_main_screen
https://github.com/godotengine/godot/issues/16863#issuecomment -634258502 + 2 以下评论GridMap
: set_cell_item
(3 int
s) 应该替换为Vector3i
#39958InputMap
: load_from_globals
应该是load_from_project_settings
https://github.com/godotengine/godot/issues/16863#issuecomment -426457888ItemList
: unselect
和unselect_all
应该是deselect
和deselect_all
,匹配其他具有类似方法的类。 在FileDialog
还有deselect_items
FileDialog
,协调这个 #28558JSON
: print
应该重命名为别的东西https://github.com/godotengine/godot/issues/16863#issuecomment -557657413 + 以下 6 条评论KinematicBody
和KinematicBody2D
:API 有机地增长并且变得非常复杂,可能欢迎对某些方法参数进行重构/重新排序(参见例如 #16757 #19648)。MainLoop
: _iteration
应该重命名为_physics_process
, _idle
应该是_process
。 非虚方法应该不公开, input_text
什么都不做,应该删除#30096Mesh
: surface_get_material
-> get_surface_material
和surface_set_material
-> set_surface_material
https://github.com/godotengine/godot/问题/16863#issuecomment -652067884Node
: get_index
和get_position_in_parent
是同义词,应该去掉#21802 #37556Node
: is_a_parent_of
应该替换为is_ancestor_of
或is_descendant_of
https://github.com/godotengine/godot/issues/16863#issuecomment - 564532042Node
: set_as_toplevel
可能是set_as_top_level
,但它的行为可能也需要调整https://github.com/godotengine/godot/issues/16863#issuecomment - 498428024 https://github.com/godotengine/godot/issues/24154 #42451Node2D
和Node3D
:与对象本地翻译代码不一致https://github.com/godotengine/godot/issues/16863#issuecomment -530519327OptionButton
: get_selected_id
在 #21837 之后可能会过时OS
: can_draw
更适合Engine
单例OS
: execute
应该分成两种不同的方法,一种是阻塞的,另一种是非阻塞的。execute
/ exec_process
(阻塞)和spawn_process
(非阻塞)#19302add_force
和apply_impulse
方法需要协调它们的参数顺序https://github.com/godotengine/godot/issues/16863#issuecomment -416791048 #37350Quat
:考虑弃用 set 方法https://github.com/godotengine/godot/issues/16863#issuecomment -515892880Rect2
:将clip
重命名intersection
以与AABB
保持一致。 https://github.com/godotengine/godot/issues/16863#issuecomment -655299536RichTextLabel
: set_use_bbcode
和set_bbcode
应该重命名为set_use_fixed_bbcode
和set_fixed_bbcode
。 如果 bbcode 被另一个函数修改,则应该抛出警告 #19118Skeleton
: set_bone_global_pose
应该重命名为set_bone_skeleton_pose
(getter 也是如此)。 get_bone_transform
也应该重命名,或者在不必要时删除#19551Sprite
, Sprite3D
: set_region
和is_region
应该重命名为set_region_enabled
和is_region_enabled
https:// github.com/godotengine/godot/issues/16863#issuecomment -380225780String
: ord_at
认为不清楚,建议将其重命名为unicode_at
#15519String:
right
行为是不直观的,大部分是substr
重复https://github.com/godotengine/godot/issues/16863#issuecomment -419635744String
:将http_escape
重命名uri_encode
,将http_unescape
重命名http_escape
uri_decode
https://github.com/godotengine/godot/issues /16863#issuecomment -503491938Texture2D
: get_data
应该是get_image
https://github.com/godotengine/godot/issues/16863#issuecomment -652064475TileMap
: set_y_sort_mode
和is_y_sort_mode_enabled
应该重命名为set_y_sort_enabled
和is_y_sort_enabled
https://github.com/godotengine/ godot/issues/16863#issuecomment -380250110 #38635TileMap
:属性名称与其 setter/getter 名称之间的差异https://github.com/godotengine/godot/issues/16863#issuecomment -382545668TileMap
: set_cell
(2 int
s) 和set_cellv
( Vector2
) 应该替换为Vector2i
的版本Tree
: get_selected
应该重命名为get_active
https://github.com/godotengine/godot/issues/16863#issuecomment -425712040Tween
:很多方法无故返回bool
,应该改成void
https://github.com/godotengine/godot/issues/16863#issuecomment -420286639 #36844UndoRedo
: is_commiting_action
有一个错字,应该是“提交”VisualServer
: sync
和draw
绑定应该被弃用,以支持现有的force_sync
和force_draw
#15892Vector2
: tangent
被认为不明确/不准确,应该是perpendicular
https://github.com/godotengine/godot/issues/16863#issuecomment -618294043 https ://github.com/godotengine/godot/pull/39685XRPositionalTracker
: get_type
-> get_tracker_type
和get_name
-> get_tracker_name
https://github.com/godotengine/godot/问题/16863#issuecomment -571283702 https://github.com/godotengine/godot/issues/15763#issuecomment -568908661 #36382 https://github.com/godotengine/godot/issues/16863#issuecomment -494437342BoxShape
, CubeMesh
和CSGBox
:它们的维度属性不一致, CubeMesh
应该重命名为BoxMesh
https:/ /github.com/godotengine/godot/issues/16863#issuecomment -403253127Camera2D
: offset
和offset_h
/ offset_v
很容易混淆,因为它们指的是完全不同的东西。 它也应该与Camera
协调,它有h_offset
和v_offset
https://github.com/godotengine/godot/issues/16863#issuecomment -407133383 #7489Camera2D
: limit_
值可以更改为Rect2i
或类似的https://github.com/godotengine/godot/issues/16863#issuecomment -595585595Control:
将margin
Control:
重命名margin
offset
现在它们可以是负数了? https://github.com/godotengine/godot/issues/16863#issuecomment -401824810Control:
rect_rotation
以度为单位,因此应将其重命名为rect_rotation_degrees
以匹配Node2D
的rotation_degrees
,以及一个新的应添加使用弧度的rect_rotation
属性。CPUParticles2D
:将normalmap
重命名normal_map
以保持一致性https://github.com/godotengine/godot/issues/16863#issuecomment -615254863Engine
: 将iterations_per_second
重命名physics_fps
以匹配同名的项目设置https://github.com/godotengine/godot/issues/16863#issuecomment -554682554 https://github.com/godotengine/godot/pull/41956ImageTexture
: lossy_quality
应该更改为枚举(低、中、高等)而不是解释为任意平台的浮动比率(与Image::compress()
) https://github.com/godotengine/godot/pull/21167#issuecomment -414234160LightOccluder2D
: light_mask
-> occluder_light_mask
https://github.com/godotengine/godot/issues/16863#issuecomment -571283702 https://github.com/ godotengine/godot/issues/ 15763 https://github.com/godotengine/godot/pull/36382Label
和Button
:不再需要clip_text
,因为所有控件都有rect/clip_content
#20228LineEdit
: cursor_*
属性应该重命名为caret_*
#16116LineEdit
和TextEdit
:它们各自的 API 可以尽可能同质化https://github.com/godotengine/godot/issues/16863#issuecomment -409058538Node2D
, Spatial
: position
(2D) 和translation
(3D) 之间的不一致 #9128NoiseTexture
:将as_normalmap
重命名as_normal_map
以保持一致性https://github.com/godotengine/godot/issues/16863#issuecomment -615254863RayCast
:将cast_to
重命名target_position
https://github.com/godotengine/godot/issues/16863#issuecomment -676512989RayCast
和其他:将disabled
属性更改enabled
属性https://github.com/godotengine/godot/issues/16863#issuecomment -511037393 + 以下 2注释Resource
: resource_name
未使用,应该删除 #13358TileMap
: collision_friction
属性应该重命名为friction
#18191CanvasItem
: hide
应该重命名为hidden
Tabs
: tab_close
和tab_hover
应该拼写为tab_closed
和tab_hovered
Tree
: item_activated
(双击标签)和item_double_clicked
(双击图标),名称不能正确表达他们的行为#16839XRController
: button_release
应该拼写为button_released
(如button_pressed
)ArrayMesh
: ArrayType
枚举是重复的,删除它https://github.com/godotengine/godot/issues/16863#issuecomment -571283702 https://github.com/godotengine /godot/issues/ 15763 https://github.com/godotengine/godot/pull/36382CPUParticles
: Flags
枚举 -> ParticleFlags
https://github.com/godotengine/godot/issues/16863#issuecomment -571283702 https://github.com /godotengine/godot/issues/ 15763 https://github.com/godotengine/godot/pull/36382Mesh
: BlendShapeMode
枚举只被ArrayMesh
,所以给ArrayMesh
https://github.com/godotengine/godot/issues/ 16863#issuecomment -571283702 https://github.com/godotengine/godot/issues/15763#issuecomment -568908661 https://github.com/godotengine/godot/pull/36382Viewport
: ClearMode
和UpdateMode
枚举应该使用相同的后缀 (#19404)XRPositionalTracker
: TRACKER_LEFT_HAND
-> TRACKER_HAND_LEFT
等https://github.com/godotengine/godot/issues/16863#issuecomment -494437342ButtonList
枚举重命名为MouseButton
https://github.com/godotengine/godot/issues/16863#issuecomment -612792875 #38054PROPERTY_USAGE_STORE_IF_NONZERO
和PROPERTY_USAGE_STORE_IF_NONONE
应该完全删除,同样来自 GDNativeItemList
、 LineEdit
、 RichTextLabel
、 TextEdit
和Tree
: font_color_selected
应该重命名为font_selected_color
匹配其他_color
属性。 #30018CapsuleShape
默认应该是垂直的 #36488WORLD_MATRIX
实际上是一个模型视图矩阵,应该重命名。 @reduz建议用实际的视图和模型矩阵替换它(和CAMERA_MATRIX
,这是一个视图矩阵),例如CANVAS_MATRIX
和ITEM_MATRIX
。display/window/size/test_width
和test_height
应该重命名为window_width
和window_height
。 我们还应该考虑重命名width
和height
设置,可能是render_width
和render_height
。 https://github.com/godotengine/godot/issues/16863#issuecomment -412308210RES_BASE_EXTENSION
) https://github.com/godotengine/godot/issues/16863#issuecomment -413620204对我来说太乏味了,但是对于将instance
修复为instantiate
用作动词的人来说,上帝保佑。
Sprite.set_region(val) -> Sprite.set_region_enabled(val)
Sprite.is_region() -> Sprite.is_region_enabled()
TileMap.set_y_sort_mode(val) -> TileMap.set_y_sort_enabled(val)
TileMap.is_y_sort_mode_enabled() -> TileMap.is_y_sort_enabled()
rect_min_size
Control.set_custom_minimum_size(value) -> Control.set_rect_min_size(value)
Control.get_custom_minimum_size() -> Control.get_rect_min_size
Control 类中还有更多,get/set 都应该与变量具有相同的名称,每次知道变量名称时都要检查停靠栏很烦人。
TileMap
类有一堆不符合各自属性的getter 和setter 方法。 事实上,我建议重命名该类中的大多数 getter 和 setter,以便它们同意它们的属性以及其他类中的命名。
Animation.track_remove_key_at_position 应该是
Animation.track_remove_key_at_time
方法
OS
: execute
应该分成两种不同的方法,一种是阻塞的,另一种是非阻塞的。execute
/ exec_process
(阻塞)和spawn_process
(非阻塞)#19302LineEdit 在“text_changed”上有一个参数 new_text,但 TextEdit 没有。
https://github.com/godotengine/godot/blob/master/scene/gui/text_edit.cpp#L6104
https://github.com/godotengine/godot/blob/master/scene/gui/line_edit.cpp#L1466
我想如果 VBoxContainer/HBoxContainer/GridContainer 重命名为简单的 VBox/HBox/Grid ...
后来它会再次重命名,因为它太短了,就像 pos->position :D
他们有点长,你是对的。
我注意到 Godot 目前在其方法名称中有两种不同的命名约定。
有时,它遵循可以在 C# 或 Java 等语言的 API 中找到的通用约定,例如[action][object]()
形式:即)
Mesh.GetBlendShapeName()
AnimationPlayer.GetCurrentAnimation()
Button.GetButtonIcon()
但是,在其他地方,它遵循[prefix][action][object]()
的不同约定,例如:
Mesh.SurfaceGetFormat()
AnimationTreePlayer.NodeGetInputCount()
CollisionObject.ShapeOwnerGetOwner()
它们只是众多示例中的几个。
如果我们有能力在将来的某个时候进行彻底的兼容性破坏性更改,我希望看到它们可以重命名以遵循单一的、定义良好的命名约定(希望是前者,因为它在 Godot 内部和外部都更常用)。
但是,在其他地方,它遵循
[prefix][action][object]()
的不同约定,例如:
Mesh.SurfaceGetFormat()
AnimationTreePlayer.NodeGetInputCount()
CollisionObject.ShapeOwnerGetOwner()
我没有仔细检查所有用法,但从我所看到的这种方法命名风格来看,虽然有点尴尬,但也遵循特定的约定。 例如shape_owner_get
方法:
doc/classes/CollisionObject.xml
101: <method name="shape_owner_get_owner" qualifiers="const">
110: <method name="shape_owner_get_shape" qualifiers="const">
121: <method name="shape_owner_get_shape_count" qualifiers="const">
130: <method name="shape_owner_get_shape_index" qualifiers="const">
141: <method name="shape_owner_get_transform" qualifiers="const">
“前缀”指的是第一个参数, get
之后的部分是您在该前缀中实际获得的内容。 例如, shape_owner_get_shape_index(owner_id, shape_id)
在概念上类似于get_shape_owner(owner_id)->get_shape_index(shape_id)
,但是没有ShapeOwner
暴露给脚本 API,因此是这个“快捷方式”。
surface_get
方法的相同故事:
doc/classes/ArrayMesh.xml
88: <method name="surface_get_array_index_len" qualifiers="const">
97: <method name="surface_get_array_len" qualifiers="const">
106: <method name="surface_get_arrays" qualifiers="const">
114: <method name="surface_get_blend_shape_arrays" qualifiers="const">
122: <method name="surface_get_format" qualifiers="const">
131: <method name="surface_get_material" qualifiers="const">
140: <method name="surface_get_name" qualifiers="const">
148: <method name="surface_get_primitive_type" qualifiers="const">
doc/classes/VisualServer.xml
2363: <method name="mesh_surface_get_aabb" qualifiers="const">
2374: <method name="mesh_surface_get_array" qualifiers="const">
2385: <method name="mesh_surface_get_array_index_len" qualifiers="const">
2396: <method name="mesh_surface_get_array_len" qualifiers="const">
2407: <method name="mesh_surface_get_arrays" qualifiers="const">
2418: <method name="mesh_surface_get_blend_shape_arrays" qualifiers="const">
2429: <method name="mesh_surface_get_format" qualifiers="const">
2440: <method name="mesh_surface_get_index_array" qualifiers="const">
2451: <method name="mesh_surface_get_material" qualifiers="const">
2462: <method name="mesh_surface_get_primitive_type" qualifiers="const">
2473: <method name="mesh_surface_get_skeleton_aabb" qualifiers="const">
或者 ATP 中的*node_get
方法:
doc/classes/AnimationTreePlayer.xml
35: <method name="animation_node_get_animation" qualifiers="const">
44: <method name="animation_node_get_master_animation" qualifiers="const">
53: <method name="animation_node_get_position" qualifiers="const">
109: <method name="blend2_node_get_amount" qualifiers="const">
146: <method name="blend3_node_get_amount" qualifiers="const">
172: <method name="blend4_node_get_amount" qualifiers="const">
225: <method name="mix_node_get_amount" qualifiers="const">
255: <method name="node_get_input_count" qualifiers="const">
264: <method name="node_get_input_source" qualifiers="const">
275: <method name="node_get_position" qualifiers="const">
284: <method name="node_get_type" qualifiers="const">
315: <method name="oneshot_node_get_autorestart_delay" qualifiers="const">
324: <method name="oneshot_node_get_autorestart_random_delay" qualifiers="const">
333: <method name="oneshot_node_get_fadein_time" qualifiers="const">
342: <method name="oneshot_node_get_fadeout_time" qualifiers="const">
478: <method name="timescale_node_get_scale" qualifiers="const">
523: <method name="transition_node_get_current" qualifiers="const">
532: <method name="transition_node_get_input_count" qualifiers="const">
541: <method name="transition_node_get_xfade_time" qualifiers="const">
我已经用迄今为止给出的大部分建议更新了 OP。
我想如果 VBoxContainer/HBoxContainer/GridContainer 重命名为简单的 VBox/HBox/Grid
我不相信,在 Godot 中,我们尝试为所有内容提供明确的名称,例如Grid
并没有告诉我它是一个容器。 对于VBox
和HBox
可以认为盒子是容器的定义,但由于我们有BoxContainer
与Container
,我认为冗长仍然是有道理的。
LineEdit 在“text_changed”上有一个参数 new_text,但 TextEdit 没有。
我认为将new_text
到 TextEdit 没有用。 在 LineEdit 上,它只包含 LineEdit 的整个文本,而不是更改的文本,所以我什至认为它不应该出现在 LineEdit 的text_changed
。 然而,更常见的是您希望在输入时使用 LineEdit 的全文,而不是在按下新字符时使用多行 TextEdit 的全文。
@akien-mga
我没有仔细检查所有的用法,但是从我所看到的这种方法命名风格虽然有点尴尬,但也遵循特定的约定
我知道这是它自己的命名约定。 但它仍然不是 Godot 之外常用的东西,也有点令人困惑,因为有时在遵循两种不同命名约定的方法中使用像BlendShape
这样的同一个词。
就个人而言,我希望看到它们都重命名为GetPrefix*
和SetPrefix*
以保持一致性,但也许其他人可能对此有不同的看法。
方法在 #16757 中发生了变化。 参数顺序更有意义,但它破坏了 3.0 和 3.1 (#19648) 之间的 API 兼容性。
我将再次提出#9128:3D 中的translation
与 2D 中的position
是一个奇怪的不同之处。
它在 3.0 之前被提出,但在 3.0 退出后关闭,因为...... 3.0 退出。
OS.execute
应该使用posix_spawn
。
另一种可能是将控制节点的“边距”重命名为“偏移量”。
由于右侧的边距为负,这会误导人们,尤其是在与 StyleBoxes 进行比较时
@groud我觉得偏移太笼统了,边距曾经是正确的词,因为它们在第一次引入时并没有消极地指向右侧
@groud我觉得抵消太笼统了,利润率是一个很好的术语(并且在第一次引入时并不是负数)
好吧,既然它们是负数,保证金就具有误导性。 Offset 是通用的,但更有意义。 我不认为它们是通用的问题,因为它是在控制节点的上下文中。
无论如何,我愿意接受更好的建议。 我只是想在这里放弃这个想法,因为已经建议了这样的属性名称更改。 例如,请参见此处。
盒子/立方体的大小命名不一致。
碰撞的 BoxShape 使用范围。
CubeMesh 有一个带有 x、y 和 z 的 size 属性,它们都是范围的一半。
CSGBox 具有 Width、Height 和 Depth 属性,它们的定义类似于 CubeMesh 中的 x、y 和 z 大小。
除了大小属性,有时使用“Cube”,有时使用“Box”。 对所有东西都使用“Box”是有意义的,因为 CubeMesh 的 x、y 和 z 可以独立设置,因此它也是一个盒子。
因为我们有 HTML5 和 UWP 作为目标,它们不完全是操作系统,我建议将操作系统重命名为平台(PlatformWindows、PlatformUnix 等)。
操作系统/显示拆分也很有意义。
从这个#20228 开始, Label.clip_text
不再需要了。 我相信 Button.clip_text 也是如此。
Camera2D 目前有两个不同的属性,它们都命名为offset
(常规偏移量和一个在 V 和 H 中分开的),这是两个完全不同的东西,这真的很令人困惑。
方法
- Dictionary
: erase_checked
应该被删除(这个方法不暴露给脚本)。
- Dictionary
: erase
应该更改为返回bool
以确定是否删除了具有指定键的对(参见erase_checked
实现)。
@neikeq现在可以在 IMO 中完成,将Dictionary.erase
的返回值从void
更改bool
不应破坏任何项目。
@akien-mga 但它会破坏 GDNative API 兼容性,不是吗?
@akien-mga 这不会打破向前兼容性吗? 我们是否允许进行可能使 3.1 脚本在 3.0 等旧版本中不起作用的更改?
@neikeq是的,3.1 脚本已经与 3.0 不兼容( class_name
,大量 API 更改带有新的可选参数或全新的属性/方法、新类等)。 我们只关心向后兼容,而不是向前兼容。
原来如此! 如果是这种情况,我将立即进行这些更改。
如果我可以将一个添加到列表中,那么 LineEdit 和 TextEdit 控制节点将真正受益于彼此一致的 API,因此它们可以(主要)互换使用。 现在,尝试与它们一起工作感觉就像一团糟,以至于查看一个节点让我对另一个节点感到困惑。
@eska014此外, scons
选项已经是platform
。 保持一致是有意义的。
项目设置display/window/size/test_width
和test_height
应该重命名为window_width
和window_height
。 我们还应该考虑重命名width
和height
设置,可能是render_width
和render_height
。
相机的Near和far属性与其 setter/getter 具有不同的名称(例如 set_znear/set_zfar)。 这个应该改?
znear
和zfar
令人困惑。 它与世界空间中的 Z 轴没有任何关系。 它可以更改为clip_near
和clip_far
因为它们控制剪裁平面,或者只是near
和far
。
是的,有两种方法可以解决这个问题。
我们应该摆脱(或认真讨论)二进制资源扩展.. (RES_BASE_EXTENSION)
gdscript_function.cpp
和gdscript_functions.cpp
的名字非常相似,我一直把它们混在一起。 值得改名吗? @vnen
我更改了https://github.com/godotengine/godot/pull/21425以将“decimals”重命名为“step_decimals”,但保留“decimals”作为别名。 假设它已合并,我们可以在下一次兼容性破坏中删除“小数”,如果没有,只需重命名。
@mysticfall在我看来,在不必要的时候,最好不要在方法名称中使用“get”这个词。
有时您希望属性能够同时被获取和设置,但控制访问。 在 C# 中,属性允许您执行此操作并仅通过像字段一样读取和分配来控制访问,这很好。
var thing = CollisionObject.ShapeOwner;
CollisionObject.ShapeOwner = thing;
然而,在 GDScript 中,属性不是一个东西(?)。 我们也可以有一个没有 get 一词的方法名。 大多数方法都会返回一些东西,因此使用隐式 get-ness 比 set-ness 更好:由于 GDScript 具有属性,我建议更频繁地使用它们。 请注意,我找不到任何关于此的文档。 我确实找到了有关如何使用setget
在 GDScript 中执行此操作的文档,但是如何通过 C++ 添加呢?
简而言之,我同意在不一致的地方使用“get”是不好的,但我认为理想的解决方案目前在 GDScript属性中或者我们可以删除“get”并保留“set” .
@aaronfranke GDScript 确实在某种程度上具有属性,因为引擎类可以定义 getter 和 setter(或仅一个 getter)并将其作为属性公开给 GDScript。 也就是说,我反对从方法中删除get
和set
,因为 1) 它使名称更清晰,并且 2) 它区分了 getter 和 setter。 例如Mesh.SurfaceFormat()
听起来像是一种“格式化表面”的方法,而不是“获取格式”的方法。 此外,大多数(如果不是全部)都可以忽略并用作属性。
现在,我不太关心gdscript_function.cpp
和gdscript_functions.cpp
。 一个有 GDScriptFunction 类,另一个包含 GDScript 函数的定义,我总是很清楚哪个是哪个(尽管我已经习惯了)。 这也不是一个重大变化,所以它不需要在这里。
是的,GDScript 有属性。 C# 属性是从 ClassDB 生成的,这是 GDScript 从中获取它们的地方。
RigidBody
有几个方法,它的相关类的参数应该交换以保持一致性:
RigidBody.add_force(force, position)
到add_force(position, force)
PhysicsDirectBodyState.add_force(force, position)
到add_force(position, force)
PhysicsServer.body_add_force(force, position)
到add_force(position, force)
@TGRCdev我非常喜欢将apply_impulse
更改为 (force, position) 而不是将add_force
更改为 (position, force)。 力的位置是一个可选参数,所以它应该放在最后。 但是所有的力和冲量都必须有一个力矢量。
@aaronfranke公平点。 在这种情况下,所需的掉期清单是:
RigidBody.apply_impulse(position, impulse)
到apply_impulse(impulse, position)
RigidBody2D.add_force(position, force)
到add_force(force, position)
RigidBody2D.apply_impulse(position, impulse)
到apply_impulse(impulse, position)
PhysicsDirectBodyState.apply_impulse(position, impulse)
到apply_impulse(impulse, position)
Physics2DDirectBodyState.add_force(position, force)
到add_force(force, position)
Physics2DDirectBodyState.apply_impulse(position, impulse)
到apply_impulse(impulse, position)
PhysicsServer.body_apply_impulse(position, impulse)
到body_apply_impulse(impulse, position)
Physics2DServer.body_add_force(position, force)
到body_add_force(force, position)
Physics2DServer.body_apply_impulse(position, impulse)
到body_apply_impulse(impulse, position)
@aaronfranke我同意使用Get-
或Set-
前缀是一种“Javaism”,最好在 C# 中避免。
我主要关心的是像shape_owner_get_shape
或node_get_input_count
这样的情况下使用“域前缀”,所以如果我们可以将它们重新实现为没有Get-
或Set-
适当的 C# 属性
附带说明一下,我一直认为 Godot 的 C# API 中的属性具有一组匹配的 getter 和 setter 很奇怪,例如Node.Name
和Node.GetName()
/ Node.SetName()
。
我觉得这有点多余,但如果我们有任何理由保持这样的约定,我想我们会得到NodeInputCount
和GetNodeInputCount()
/ SetNodeInputCount()
无论如何,如果我们是按照建议重命名node_get_input_count
。
伙计们,请继续讨论 C# API 和此问题之外的常规约定,该问题侧重于 Godot API。 Godot API(C++、C 和 GDScript)不会为了 C# 进行调整,除非它也是对其他语言的改进。
@akien-mga 我不认为讨论node_get_input_count
是否可以重命名为get_node_input_count
类的东西不是 C# 特定的事情。
不,我的意思是任何特定于 C# 的内容都不应该出现在这个问题中。 如果需要,C# 特定的兼容性损坏可能会出现另一个问题(尽管已经有几个这样的 IINM)。
将 Spatial 重命名为 Node3D 怎么样? 我一直觉得很奇怪。
@KoBeWi Godot 当前使用的命名方案是“Thing2D”表示 2D 内容,而“Thing”表示 3D 内容,因此它与 2D 代码的其余部分相当一致。 当然,按照删除“2D”的模式,调用“空间”的合乎逻辑的将是“节点”,但该名称当然已经被采用了。
Godot 目前使用的命名方案是“Thing2D”表示 2D 内容,而“Thing”表示 3D 内容
那么也许将所有 3D 内容更改为“Thing3D”? 我也想到了这一点,但听起来有点矫枉过正。
无论如何,我只是建议。 不是很重要。 此外,Spatial2D 甚至比 Spatial 还要糟糕。
因此, String.right() 从给定位置返回 n 个正确的字符。 如果它只返回从右边数起的 n 个字符,会不会更直观?
"abcdef".right(2)
而不是“cdef”将返回“ef”。 海事组织会更好。
我期待同样的。
Python 具有大多数用户喜欢将 GDScript 与 Python 进行比较的相同方法。 改变它可能会更加混淆。
@KoBeWi我同意。 我没有看到当前实现和子字符串之间的区别。
Godot substr
强制您指定字符串的大小,如果您希望所有内容都在右侧。
@Zylann大多数实现允许省略第二个参数。 我认为这是戈多方面的一个问题。 此外,我宁愿让substr
将第二个参数设为可选,而不是使用不同名称的新方法。
@Zylann @neikeq这是具有不可重载方法的不幸结果,无法同时具有长度规范和无长度规范。
@aaronfranke嗯,但确实存在默认参数。 0 或 -1 可以算作未指定长度。
需要从OptionButton
删除get_selected_id()
OptionButton
目前它总是返回 -1。 https://github.com/godotengine/godot/pull/21837合并后get_selected_id()
将返回与get_selected()
。
有很多 tween 方法每次都返回 true,它们可能应该被设置为空。
WindowDialog.get_close_button()
ConfirmationDialog.get_cancel() -> ConfirmationDialog.get_cancel_button()
AcceptDialog.get_ok() -> AcceptDialog.get_ok_button()
Tree 节点有一个get_selected()
函数,它似乎返回了焦点 TreeItem。 将其重命名为get_active()
可能是值得的,因为焦点和选择是不同的东西。
InputMap 中的load_from_globals()
应该是load_from_project_settings()
。
我将添加 :tada: 对已集成到 OP 中的所有建议的反应,以获得更好的概览。
global_rotate
应该重命名为rotate_global
并且rotate_object_local
应该重命名为rotate_local
以保持一致性,以便所有旋转方法都以“rotate”开头。
global_rotate 应重命名为rotate_global,而rotate_object_local 应重命名为rotate_local 以保持一致性,以便所有旋转方法都以“rotate”开头。
好吧,另一方面,我喜欢与全局相关的函数(如 global_position、global_scale 和 global_transform)在自动完成建议中彼此相邻。 恕我直言,这两种解决方案都有意义。
也许tree_exiting
可以重命名为tree_exited
因为它现在似乎引起了一些混乱。 见#22840。
@groud已经有tree_exited
信号了吧?
@groud已经有一个 tree_exited 信号对吗?
该死的你是对的。 我猜 #22840 中的请求是有效的
MenuItems.MENU_MAX
从未在LineEdit
和TextEdit
,我们应该删除它吗?
Tabs.ALIGN_MAX
https://github.com/godotengine/godot/blob/master/scene/gui/tabs.cpp#L750
Position3D
和Position2D
节点有点不明确。 如果不阅读描述,人们可能会认为它们类似于 Spatial 和 Node2D,但没有旋转或缩放。 它们可能应该重命名为PositionHint
和PositionHint2D
或者可能像Gizmo
这样的其他词,因为它只是在编辑器或AxisMarker
的一个小工具,因为它看起来像一个小轴标记。
如果将它们重命名为Gizmo
那么也许它们可以得到更广泛的用途。
请注意,控制树中的同一节点是ReferenceRect
,因此, ReferenceAxis/2D
也可能起作用。
现在喜欢这个问题。 以后可能会在破损实际发生时讨厌它;)
对于不起眼的Array
类的一些建议:
duplicate
→ copy
或clone
。 我不知道有任何语言将这个概念称为“复制”。 copy
是Python和C++ 中的名称,因此它是 Godot 的自然选择。 clone
来自Java和JavaScript ,可能更精确一些。invert
→ reverse
。 文档甚至将其描述为“反向”,因此真的没有任何借口。remove
vs. erase
令人困惑。 建议: remove_at
和remove_value
。最后两个也适用于所有Pool*Array
类。
注意:复制→复制/克隆也适用于字典。
Rect2
:
clip
→ intersection
AABB
有intersection
方法但没有clip
,裁剪通常意味着我们剪掉了一些东西,这在任何一个类中都没有实现。 文档将其描述为:
Returns the intersection of this Rect2 and b.
还不如重命名:
intersects
→ overlaps
intersection
操作混淆:Returns true if the Rect2 overlaps with another.
grabber_area
-> slider_progress
slider
-> slider_background
对于不起眼的 Array 类的一些建议:
复制 → 复制或克隆。
...
注意:复制→复制/克隆也适用于字典。
以及节点和资源(基本上是任何脚本公开的数据结构对象,afaik)。
我更喜欢“克隆”这个词,我认为它的作用更清楚。
早晨! @akien-mga 不能将instance
重命名new
而不是instantiate
吗? 例如,在PackedScene
与Object
相同的界面,尤其会删除一些用于创建插件的样板,但可能更普遍。 @willnationsdev你怎么看? 我知道你以前遇到过这种情况。
抱歉,如果已经在某处讨论过这个问题,我无法通过浏览找到它。
grabber_area
->slider_progress
slider
->slider_background
要不就:
grabber_area
-> progress
slider
-> background
?
我不知道这是否已经讨论过,但是AnimationPlayer
有root_node
和set_root
和get_root
,它们应该是set/get_root_node
将CanvasItem.visible
重命名CanvasItem.is_visible
(以及所有其他使用它的地方)? 与所有(或大多数,也许我错过了一些) bool
属性一致?
将Tween.tween_completed
重命名Tween.tween_finished
? 就像Animation.animation_finished
? 通常比_completed
更喜欢_finished
_completed
? 感觉started/finished
的关系比started/completed
更紧密 - 偏向于竞技运动: start/finish
- 也许:D
请考虑将类JavaScript
重命名为HTML5
或其他名称。
这个类只有一个方法,它不是从Script
扩展而来的,也没有在其他平台上使用。
JavaScript
可以作为JavaScript 语言绑定的类名。
正如@clayjohn所指出的,CanvasItem 着色器中的WORLD_MATRIX
实际上是一个模型视图矩阵。 @reduz同意在 4.0 中我们应该用实际模型和视图矩阵替换它,例如CANVAS_MATRIX
和ITEM_MATRIX
。
考虑将Array.invert
重命名Array.reverse
。 反转更像是颠倒或“倒数”类型的事物。 请参阅https://docs.godotengine.org/en/latest/classes/class_color.html#class -color-method-inverted
将CanvasItem.visibility_changed()
信号更改CanvasItem.visibility_changed(visibility: bool)
,即。 发送可见性状态。 既然这样就足够了,那么删除CanvasItem.hide()
信号
删除Resource::notify_change_to_owners
, Resource::{un}register_owner
。
它们仅由 GridMap 和 CollisionShape 使用,其余代码使用"changed"
信号。
Rect2
: has_no_area
应该重命名为has_area
以防止双重否定逻辑检查条件中的相反情况。 同样适用于AABB
: has_no_surface
。
在@lupoDharkael所说的基础上,Godot 有几个地方使用了双重否定。 诸如“Condition !Math::is_nan(x) is false”之类的错误令人困惑。
parse_input_event( 输入事件事件 )
向游戏提供 InputEvent。 可用于从代码人为触发输入事件。
解析具有误导性,解析将接收和处理但描述表明发送或触发输入
根据#24153 - CanvasLayer
使用 layer 来描述在哪个层上绘制其节点。 但是几乎所有其他 2D 节点都使用术语“Z 索引”( z_index
) 来描述(最初看起来是什么)相同的事物。 正如@swarnimarun建议的那样https://github.com/godotengine/godot/issues/24153#issuecomment -444950584 改进层的名称。
OS.has_feature() / Platform.has_feature() 在诸如 ProjectSettings 之类的东西中会更明智,因为它们并没有专门传达有关操作系统的任何信息?
set_cell_item 可以重命名为 set_cell 以统一 GridMap 和 TileMap 吗?
set_cell_item 可以重命名为 set_cell 以统一 GridMap 和 TileMap 吗?
想想看,也许GridMaps也应该有一个set_cellv
?
ARVR接口:
ar_is_anchor_detection_enabled
-> anchor_detection
或类似的interface_is_initialized
-> is_initialized
或is_interface_initialized
动画播放器:
play_backwards
可以被删除,因为play
有一个可选的 bool 。BaseButton / CollisionShape / CollisionPolygon / CollisionShape2D / CollisionPolygon2D:
disabled
bool 更改为enabled
bool。骨骼2D:
get_index_in_skeleton
-> get_skeleton_index
play_backwards
可以被删除,因为play
有一个可选的 bool 。
这对可读性是不利的,至少只要没有实现 #6866。 这在 C# 中不是问题,因为它支持命名参数。
id_pressed( int ID )
和id_focused( int ID )
ID 应该是小写的。
^
这种变化实际上不会破坏任何兼容性。 它可能会得到一个单独的问题。
^
这种变化实际上不会破坏任何兼容性。 它可能会得到一个单独的问题。
这是正确的!
Node.replace_by
作为名称可能会造成混淆。 不知道究竟什么可能是一个更好的名字。@bojidar-bg 也许replace_self
或swap_by
? 但我认为避免任何混淆的唯一方法是正确记录它。
如果我有一个Node2D
并附有包含class_name MyNode2D
的脚本,则get_class()
方法返回Node2D
而不是MyNode2D
。 这可能是故意的,但它令人困惑和误导。
编辑: https :
@aaronfranke get_native_class()
也许? 然后您可以从get_script().global_name
获取脚本名称(如果有)。
make_convex_from_brothers()
我想“兄弟”应该改为“兄弟姐妹”,因为这是兄弟节点到处使用的词。
AVRPositionalTracker: get_type()
-> get_tracker_type()
get_tracker_type()
更明确 - get_type()
可能与get_class()
混淆
GetType()
如指出已用于在C#别的东西在这里。
它返回TrackerType
,还有get_hand()
返回TrackerHand
,因此如果需要,也可以将其更改为get_tracker_hand()
以保持一致性。
AVRPositionalTracker 枚举 TrackerHand: TRACKER_LEFT_HAND
-> TRACKER_HAND_LEFT
(和右手)。 或者, TRACKER_HAND_UNKNOWN
-> TRACKER_UNKNOWN_HAND
,只要它是一致的。
Node.NOTIFICATION_TRANSLATION_CHANGED
可能应该变成NOTIFICATION_LOCALE_CHANGED
,因为在空间节点中使用“翻译”来表示“位置”而不是“语言”。
set_as_toplevel()
可以重命名为set_as_top_level()
,但应查看其行为。
应该查看 4.0 的 TouchScreenButton,因为此更改可能会破坏: https :
CanvasItem
方法:
RID get_canvas_item() const
返回 VisualServer 为此项目使用的画布项目 RID。
然后应该重命名为get_rid()
。
get_canvas_item()
令人困惑,因为我已经在CanvasItem
节点。 它还确保一致性,因为其他类已经有类似的get_rid()
方法: CollisionObject
, Resource
。
Label
应该改为TextLabel
吗? 有好几次我想放下一个文本对象但忘记了它的名字,所以我搜索“文本”并且只有RichTextLabel
出现。 TextLabel
与RichTextLabel
更一致,因为它仍然是文本但没有丰富的内容。
作为参考,Unity 有Text
和TextMesh
,我个人将其称为文本而不是标签。
我也一直想知道Tree
和GraphNode
被重命名为TreeView
和GraphEditNode
。
对于Tree
,原因是它对于全局 GUI 节点 IMO 的名称太宽泛了,我知道的所有其他 GUI 框架都使用TreeView
。
对于GraphNode
,是因为我最近做了一些涉及实际图形结构的原型,我既不能使用Node
也不能使用GraphNode
,这很烦人。
@Zylann由于 Graph 节点是图形(不是树)的可视化/控件,GraphContainer 可能更好。 不确定关于 GraphNode。
我们应该有lerpf
/ lerpv
/ lerpc
而不是Color/Vector2/3.linear_interpolate
吗? 至少将Color/Vector2/3.linear_interpolate
重命名Color/Vector2/3.lerp
如#29598 http_escape
/ http_unescape
到uri_encode
/ uri_decode
我们应该有
lerpf
和lerpv
而不是Vector2/3.linear_interpolate
吗? 至少将Vector2/3.linear_interpolate
重命名Vector2/3.lerp
缩短到 vector.lerp() 听起来不错。 至少从https://github.com/godotengine/godot/pull/16106 开始,脚本中lerp()
使用有一个支持向量和颜色的开关。
Vector2.angle_to_point()
应该被重命名。 它的名称与当前描述不一致。 不确定一个好名字是什么,以及这个功能是否值得保留。
原始问题:#16307
@razcore-art 已经有一个关于这个https://github.com/godotengine/godot/pull/20371的公关公开,它保持向后兼容性(我认为)。
编辑:不再。
Area
真的应该是Volume
,因为它是 3D 的。 然后Area2D
应该是Area
。 一个区域本质上是二维的。
GridMap
应该是CubeMap
。 不确定这个,只是那个“网格”对我来说听起来像一个二维的东西。
CheckButton
控件应该是SwitchButton
什么的。 这很令人困惑,因为还有Checkbox
。 或者也许它应该完全删除。 无论如何,据我所知,它的功能与 Checkbox 相同。
我同意:CheckButton,其他的只是装饰性的。
或者也许它应该完全删除。 无论如何,据我所知,它的功能与 Checkbox 相同。
尽管具有相同的功能,但在 UX 方面,CheckBox 和 CheckButton 是不同的东西。
https://uxmovement.com/buttons/when-to-use-a-switch-or-checkbox/
@Rodeo-McCabe Area 被这样调用是为了与 2D 对应物保持一致, area
的定义之一是a particular extent of space or surface
。
立方体贴图是 3D 图像,语法正确性必须取决于上下文,否则只会增加混乱。
grabber_area
->slider_progress
slider
->slider_background
要不就:
grabber_area
->progress
slider
->background
?
也许:
grabber_area
-> progress_area
或progressed_area
slider
-> progress_background
?
立方体贴图是 3D 图像,语法正确性必须取决于上下文,否则只会增加混乱。
@eon-s 很公平,我不知道。
像这样调用区域是为了与 2D 对应物保持一致
问题是 2D 对应物也不一致。 在数学中,面积是长度 * 高度,只是没有任何第三维。 所以说Area2D没有意义,因为它应该是2D的,因为它是一个区域。 “区域”的另一个更数学化的定义是:
包含在一组线中的表面,特别是:与表面相等的单位正方形的数量
类似地,数学中的 3D 空间称为“体积”。 当我发现 Area 实际上是一个 3D 节点时,起初我很困惑,而这些区域被奇怪地称为“Area2D”。 由于这是一个游戏引擎,因此我们应该采用数学定义。
虽然我理解其中的原因,但我不知道更改名称是否有任何特别的好处,尤其是对新人而言。 我确实同意“体积”可能是更合适的术语,但我觉得 3D 的“体积”和 2D 的“面积”可能有点混乱。 毕竟,很多既有 2D 又有 3D 变体的节点会被命名为“ 我认为,命名方案摆在首位在那里(尽可能有一些节点谁大多只坚持方案)的手段,我们不应该有一个例外,即使在另一个术语的一种变体将使更有意义,否则它可能会使用户感到困惑。 但是,如果我可以……也许将 编辑:除非您转义 <>,否则似乎不会出现由 <> 包围的文本Area2D
重命名Area
,将Area
重命名Area2D
Area3D
?
@Rodeo-McCabe 我的印象是节点命名意图是用人类语言而不是数学来表达事物。 所以“区域”并不意味着是一个几何图形,而是一个可以存在的地方,比如关卡或舞台的内部。 IE - 区域 1。
节点本身不直接有任何几何体或者它本身就是一个几何体,所以像我这样的其他人在创建它时会想知道它的面积/体积在哪里,然后为什么我必须将面积和体积(形状)附加到一个区域和体积?
如果要对其进行重命名以避免将其与几何区域混淆,则同义词可能是要走的路。
他们可能被称为:
顺便说一句,除了这个跟踪器仅用于方法、属性和信号(而不是节点), @reduz最近提到有意图最大限度地减少 4.0 上的兼容性破坏,所以在我们继续添加之前,这个庞大的列表可能需要核心开发人员的审查永远的事情...
听起来目标是保持现在的样子,所以像这样的东西可能会被退回到 4.0 之后的下一个主要版本?
请把这个问题留给核心贡献者,它不是一个到处提出大改名建议的地方,目的是解决使 API 变得麻烦的实际不一致。
OP 中概述的更改不是很大的兼容性破坏,大多数将针对 4.0 完成, @reduz所指的是“您的项目无法再打开”类型的兼容性破坏,例如 2.1 和 3.0 之间(更多改变的不仅仅是当时重命名的东西,例如完全重写的音频和粒子系统,导入系统的更改等)。
将有4.0一些兼容性破损,否则就不叫4.0。 这将是合理的并且移植将很容易,可能使用转换器来确保重命名的属性、方法和信号在场景和脚本中使用时正确转换。 无论如何,这不是讨论它的地方:)
Control
的_set_anchor()
也应该去掉开头的“_”。
PopupMenu 的index_pressed(index)
和id_pressed(id)
工作正常,还有id_focused
实际是用索引而不是项目的id发出的。
这还没有问题,但在今天向 Akien 建议后值得列入名单。
重构 ARVRServer,使其称为 XRServer。 当我们设计它时,术语 XR 表示 VR 和 AR 尚未得到广泛使用。 不,我不打算使用 MRServer ;)
RayCast 是否应该具有“禁用”属性而不是“启用”? CollisionShape 有一个“禁用”,默认为false
(这意味着它们默认启用)。 相比之下,RayCast 的“启用”属性默认为false
,使它们默认禁用。
或者,要使用肯定形式(我认为总体上不太容易混淆),CollisionShape 是否应该具有“启用”属性(默认true
)而不是“禁用”?
@Calinou我不知道这是否需要一个单独的问题,但如果我们需要保持一致,我真的更喜欢这样的布尔值总是Enabled
。 将布尔值设置为true
以禁用经常让我感到困惑的东西。
@Calinou我同意@Zylann双重否定令人困惑,应尽可能避免。 我们应该改为将“禁用”布尔值更改为“启用”布尔值。 如果某物的默认值是“true”,那就没问题了。 我在 #17212 和 #21822 中有过这个讨论。
鼠标和触摸输入事件的speed
属性应重命名为velocity
因为它是 Vector2。
InputMap
: get_action_list( String action )
函数名称并没有说明它的作用。
由于它返回与给定操作关联的 EventInputs,因此它可能是get_action_events(String action)
也可以帮助避免可能的混淆,因为InputMap
有另一个名为get_actions( )
函数,并且这两个名称在上下文之外可能意味着相同的事情。
与#30736 相关,我们应该将两个 Godot 物理引擎重命名为“GodotPhysics2D”和“GodotPhysics3D”之类的名称,因为用“GodotPhysics”说某些东西坏了可能意味着两种截然不同的意思。
将Object._init()
重命名Object._new()
怎么样?
get
— _get
get_property_list
— _get_property_list
notification
— _notification
set
— _set
new
— _init
我猜_init
实际上遵循 Python 的__init__
,而new
是类的方法,而不是实例。
类似于String
: empty()
-> is_empty()
适合该线程? 我一直认为它是一个首先清除字符串的函数。
@vortexofdoom如果谈论方法名称不一致和/或它们应该如何命名,那么是的。
我可以添加String
和NodePath
有empty
和is_empty
方法,它们做同样的事情。 核心其余内置类型似乎更喜欢empty
名称,所以也许is_empty
可以在改名NodePath
做出过这个一致的所有内置类型,但是这我认为可能会涉及一些严重的兼容性破坏。
我一直认为它是一个首先清除字符串的函数。
大多数方法在 Godot 中使用clear
名称。
@Xrayez ,
为此,大多数方法在 Godot 中使用明确的名称。
我知道,只是指的是empty
既是动词又是形容词这一事实,并且添加is_
可以明确表示哪个意思。
我赞成在该 bool 的所有内置函数中使用is_empty
。
在 Godot 3.0 和 3.1 中,我们在 C# 中有Set
方法。 然而,与仅使用构造函数和赋值相比,这些实际上并没有添加任何实际功能,但允许代码静默失败,因此它们已被淘汰。 它们主要是我添加的,以尝试保持一致,因为 Quat 的方法已经存在,它来自具有 set 方法的核心。 有关更多信息,请参阅 #30744
GDScript 确实有set_euler
和set_axis_angle
,但也有做同样事情的构造函数( q.set_axis_angle(myvec3, myval)
可以替换为q = Quat(myvec3, myval)
。Core 也有这些方法为基础,但他们没有接触到 GDScript。
那么问题来了,应该怎么办呢? 是否应该弃用 Quat set 方法以支持构造函数并与 C# 保持一致,或者是否值得让它们对正在执行的操作保持明确? 如果是后者,Basis 方法也应该公开吗?
@aaronfranke我总是觉得很奇怪,那些构造函数有专用的方法,而基本上没有其他任何东西,所以如果可能的话,我
@aaronfranke这个问题是关于重命名 API 中的东西,而不是引擎功能或错误。
Geometry
的point_is_inside_triangle()
到is_point_in_triangle()
,以匹配在同一类中也返回bool
的其他方法。
TreeItem.get_children()
应该更名为get_first_child()
。 该文档还应说明它不返回子项。 子级使用get_next()
进行迭代。
在处理 #31976 时,我注意到阴影图集值必须是 2 的幂(对于定向阴影和全向/点阴影)。 但是,这些方法接受任何整数值; 如果它不是 2 的幂,则该方法会将其四舍五入到最接近的 2 的幂。我们可能应该让它接受值的枚举,以便它可以在项目设置中以用户友好的方式呈现。
同样,各向异性过滤级别应该是一个枚举(2×、4×、8×、16×),因为这里只有二的幂值才有意义。
VisualServer
的instance_create2()
应该更改为实际描述它与instance_create()
。
对于对象相关的翻译, Spatial
有translate_object_local
接受Vector3
, Node2D
有move_local_x
和move_local_y
,这需要浮点数。 Spatial
和Node2D
都应该有分别接受Vector3
和Vector2
, translate_local
或local_translate
比translate_object_local
更简单的名称。
@leonkrause而不是render_width
和render_height
将它称为viewport_width
和viewport_height
或者canvas_width
和canvas_height
会更有意义
@akien-mga 请考虑将树导航方法添加到您的列表中。 它们的名称非常混乱,并且没有很好的记录。
当我第一次遇到它们时,我认为 get_child() 和 get_next()、get_prev() 操作迭代器,就像 Directory 的工作方式一样。 我不得不自己进行测试,以发现它们所做的只是在每次调用它们时生成相同的指针。
get_children() 应该重命名为 get_first_child()。
get_next() 和 get_prev() 应重命名为 get_next_sibling() 和 get_prev_sibling()
为了与项目设置保持一致,将Engine.iterations_per_second
重命名Engine.physics_fps
怎么样?
is_processing
:
如果启用处理,则返回 true。
can_process
:
如果在场景树暂停时节点可以处理,则返回 true
这可能是更好的重命名can_process
喜欢的东西can_process_paused
为了避免混淆, is_processing
方法。
----
String print( Variant value, String indent="", bool sort_keys=false )
我认为这个方法应该重命名。
@dalexeev它应该重命名为什么,为什么?
@Calinou此方法实际上并未在屏幕上打印任何内容; 它返回一个字符串。 第一个想法是JSON.print
就像Node.print_tree
或OS.print_all_resources
或所有其他print*
方法一样工作。
应该改名为什么? 我不知道。 JavaScript 为此使用JSON.stringify
。 PHP 有一个json_encode
函数。 直接在 GDScript 中有一个类似的函数 - to_json
。
更新。 JSON.serialize
也是可能的,但就字符数而言,它与JSON.stringify
。 :微笑:
我建议不要使用“序列化”这个词,因为它通常用于二进制序列化,并且这样的输出需要有进一步的步骤才能获得这种形式。
由于这个类只有两种在 JSON 和 Variant 类型之间转换的方法,我建议不要使用包含单词json
因为它毫无意义。
现在,对于那些会是个好名字的东西,现有的parse
方法并没有真正明确的反义词(请参阅此处)。 也许其中之一: encode
、 create
、 compose
、 generate
? 如果使用encode
,将另一个方法重命名为decode
是有意义的。
我见过format
和write
被用作parse
的倒数。 然而,由于在 JavaScript 中使用, stringify
的好处是在开发人员中更广为人知。
我见过
format
和write
被用作parse
的倒数。 然而,由于在 JavaScript 中使用,stringify
的好处是在开发人员中更广为人知。
str2var
是VariantParser
和var2str
是VariantWriter
内部(例如,参见 #33241,我什至使用相同的术语来描述它)。
所以我支持write
,一致性获胜。 😛
@Xrayez 将print
更改write
? 从 Python 到 Pascal? :笑:
正如https://github.com/godotengine/godot-proposals/issues/252#issuecomment -557901552 中所建议的,将与clear_color
相关的所有内容重命名为background_color
(包括项目设置)。
由于更好的性能、GI 探测改进、普遍炒作等,我预计 4.0 会为 Godot 带来一大批新人。
如果这些更改是在 4.0 中进行的,这些人将获得硬着陆,因为几乎没有现有的教程(除了官方的“第一款游戏”教程)对他们有用。
如果这些更改是在 4.0 之后进行的,比如说在 4.1 中,对于这些人来说,这将是一次非常颠簸的旅程。 他们刚刚学习了新引擎的基础知识,现在他们必须重新学习。 开始是艰难的,不得不一次又一次地经历两次这样的过程可能会令人沮丧到完全放弃。
因此,在 4.0 版本之前有一个“3.3”或“3.9”版本,其中包含所有那些破坏兼容性的 API 更改,但是在预期的新用户大量涌入之前给教程创建者足够的时间来创建一些教程,是否没有意义?
不确定这是否是正确的地方,但由于这可能是重命名问题的可能部分解决方案,我将在这里提出。
为什么不进行所有需要的重命名更改,然后将一种新语言添加到名为 GodotOldNames/GodotPre4.0 的翻译中,它具有所有更改的所有旧名称。
这样,如果有人在旧教程中找不到旧名称,他们可以将语言更改为 GodotPre4.0 。 这也将使切换到新名称更容易。
这并不能解决整个问题,但可能与 #4397 一起使用。
@Anutrix这会增加很多复杂性(非英语语言呢?)。 此外,并非编辑器中显示的所有字符串首先都是可本地化的。
物理“层”,渲染“层”
我记得在我学习戈多的最初几周里,我和这个可怜的人经历了同样的困惑。
物理“层”,渲染“层”对于来自面向对象设计的人
层(复数,与单层相反)似乎意味着在所有这些情况下都堆叠在一起。
对于许多人来说,“分层”尤其是在处理 2D 图形或动画时意味着处理前景、背景和中间或顶部的图层。 许多人将图层视为背景之上的赛璐珞薄膜,而实际上 Godot 像许多其他游戏引擎一样使用各种“排序”方式来完成这项任务。
我们将物理对象或渲染对象可能共享“层”的抽象共性称为这一事实,而同时这些抽象共性与视觉层的堆叠外观(即“排序”)无关,这就是对某些人来说太混乱了。
当我了解了Physics“Layer”、Render“Layer”的真正用途和含义时,我立刻想知道为什么这些不是Physics Group、Render Group,说实话,我还是不知道。 它们彼此之间当然没有任何 ontop-stackable 关系,这意味着它们的顺序或彼此之间的关系完全无关。 将它们命名为图层,恕我直言,只会混淆人,“组”,“受组影响”是面具,或者也许我现在想不到的其他术语会更准确。
动画播放器方法
.stop(false)应该被称为.pause(true)
因为这就是它的作用。
项目 > 项目设置 > 显示 > 窗口 > 拉伸 > 模式:
Stretch Mode "2D"应该叫Stretch Mode "display" , or "general purpose"
因为当它在 3D 用例中同样适用时,将其称为 2D 会令人困惑,但对于所有 2D 用例(如像素艺术项目,而 Godot 2D 项目几乎有一半似乎是像素艺术)。
“显示”还可以更详细地描述它的实际作用:以显示分辨率渲染所有图形,包括 2D 图形、3D 对象、2D 网格、Line2D 和多边形。
更多关于这里。
可以澄清动画播放器、计时器和类似节点的循环、重复、单次拍摄。
循环、重复和不是一个人,都是一样的东西。
我觉得is_a_parent_of()
应该重命名为is_parent_of()
@KoBeWi请参阅 #19801 中的讨论。
我觉得
is_a_parent_of()
应该重命名为
is_parent_of()
我不这么认为, is_parent_of() 建议它只考虑第一个父级,而该函数递归地检查所有父级。
@groud在这种情况下,它应该被称为is_ancestor_of()
。 如果也有相反的相应函数,则应将其称为is_descendant_of()
。
@groud在这种情况下,它应该被称为 is_ancestor_of()。 如果反过来也有相应的函数,那么它应该被称为 is_descendant_of()。
是的,但是考虑一下,没有太多需要同时拥有这两个函数,因为区别只是切换“调用”对象和函数参数的问题。 也许我们可以简单地将函数替换为is_descendant_of()
类的东西,我们就完成了。
我们可能想将push_error()
和push_warning()
重命名push_error()
print_error()
和print_warning()
。 由于自动完成,这将使它们更容易被发现:slightly_smiling_face:
@Calinou print_error()
可能会与printerr()
混淆
请考虑更改TreeItem.get_children()
方法的名称,顾名思义,该方法的返回值是一个子项集合,实际上它是返回的第一个子项,然后您必须遍历其余的子项他们使用get_next()
(如#19796 中所述)。
从#31404引用@Zylann:
[将
rpc()
/rset()
重命名rpc()
]remote_call()
/remote_set()
?
这些方法的名称也很短,不确定别名是否足够。 你真的需要做很多多人游戏,每个脚本都有大量的这些调用来证明 3 字符标识符的合理性(我相信大多数游戏都没有)。
编辑(2020-01-03):再想一想, call_remote()
和set_remote()
可能更有意义,因为我们已经有了call_deferred()
和set_deferred()
。
编辑:不要介意下面的关闭/重新打开,我点击得太快了。
以下方法
OS.find_scancode_from_string
OS.get_scancode_string
OS.is_scancode_unicode
应该从OS
类移动到Input
类以与方法保持一致:
Input.get_joy_axis_index_from_string
Input.get_joy_axis_string
Input.get_joy_button_index_from_string
Input.get_joy_button_string
TabContainer
应该编辑它的tab_close
和tab_hover
信号。
light_mask
-> occluder_light_mask
Flags
枚举 -> ParticleFlags
get_type
-> get_tracker_type
get_name
-> get_tracker_name
rotate
-> 别的东西ArrayType
枚举 -> 删除这个BlendShapeMode
枚举 -> 给 ArrayMeshhttps://github.com/godotengine/godot/issues/15763#issuecomment -568908661中的说明
RichTextLabel 的meta_hover_started
和meta_hover_ended
信号应该重命名以匹配大多数其他类似的命名约定: meta_hover_entered
和meta_hover_exited
。 这不仅使它更接近地模仿 Godot API 的其余部分,而且由于字母排序,当前的命名方案导致它们的顺序颠倒。 当您阅读文档时,这有点令人困惑,因为很明显,操作的时间顺序是先进入然后退出。 它只是提高了可读性和一致性来改变它。
我注意到没有 Texture.size 属性。 我需要调用 Texture.get_size() getter。
我在 Discord 中询问是否有意这样做。 一个建议是在这里发帖询问是否需要将其转换为属性,另一个建议是由于没有“setter”,因此使用 get_size() 是当前预期的行为。
@jmbjr我们是否有任何只读属性公开为属性(而不仅仅是 getter 方法)? 我记得在尝试设置只读属性时看到了一个内置的错误处理程序。 我只是不确定它是否首先暴露于 GDScript。
是的,我认为如果您要开始支持只读公开属性,那么您需要一个 USAGE 标志,并添加支持它的 GDScript 解析器/编译器代码。
SoftBody
有一个areaAngular_stiffness
应该是area_angular_stiffness
(所有相关方法都一样)。
Input.joy_connection_changed
(方法)似乎不应该暴露给脚本 API,它由每个平台的操纵杆处理代码在内部调用。
@akien-mga 当我第一次看到这种方法时,很早就发现 Godot 后,我有类似的想法,然后我想起小岛是如何围绕一种与此非常相似的方法在 MetalGearSolid 中构建一些传奇游戏的,我想:“ Godot甚至给了我用一行代码就可以像Kojima一样打破第四堵墙的方法,这真是太棒了!”
Label
和RichTextLabel
主题属性不一致:
Label:
int line_spacing [default: 3]
Color font_color [default: Color( 1, 1, 1, 1 )]
RTL:
int line_separation [default: 1]
Color default_color [default: Color( 1, 1, 1, 1 )]
另外,由于默认值不同,相同的字体在Label
和RichTextLabel
高度也不同。
TextEdit 的request_completion
信号可以重命名为completion_requested
以使用过去时。 当前版本听起来有些势在必行,这与信号的回调性质相反。
与物理身体信号的另一个不一致
区域:
area_shape_entered( int area_id, Area area, int area_shape, int self_shape )
area_shape_exited( int area_id, Area area, int area_shape, int self_shape )
body_shape_entered( int body_id, Node body, int body_shape, int area_shape )
body_shape_exited( int body_id, Node body, int body_shape, int area_shape )
我想这最后两个中的 area_shape 应该是 self_shape 吗? 或者 ...
刚体:
body_shape_entered( int body_id, Node body, int body_shape, int local_shape )
body_shape_exited(int body_id, Node body, int body_shape, int local_shape )
这里它被称为 local_shape ...
@FrederickDesimpel据我所知,可以在不破坏兼容性的情况下重命名参数。 请随意为此打开一个拉取请求:slightly_smiling_face:
在变体中:
真实 -> 浮动
无 -> 无?
我个人喜欢“real”这个名字,因为“float”这个词通常专门用于 32 位浮点数,但 Variant 的 real 是一个双精度数,而且大多数引擎使用real_t
两者都可以。
我们是否考虑过重命名这些:
shader_type canvas
=> shader_type 2d
shader_type spatial
=> shader_type 3d
CanvasItemMaterial
=> Material2D
SpatialMaterial
=> Material3D
@Zylann SpatialMaterial 已在 master 中重命名为 StandardMaterial3D。
是否应该将limit_
Camera2D
上的limit_
值更改为Rect2i
? 现在它们只有四个整数。
编辑:拖动边距也可以更改为Rect2
。
String::begins_with
到String::starts_with
。
就像在严肃的编程语言(Java、Python 等)中一样。
InputEvent.is_action_pressed to InputEvent.is_action_just_pressed
InputEvent.is_action_released to InputEvent.is_action_just_released
https://github.com/godotengine/godot-proposals/issues/316#issuecomment -589426014
尽管缺少“just”这个词,但 event.is_action_...() 对应于 Input.is_action_just...()。
我们可能应该交换Node.add_child_below_node()
的前两个参数,因此第一个参数与Node.add_child()
。 见#19642。
_语义恐惧症说话......_
Node2D.draw_circle
应该是Node2D.draw_disk
因为它绘制的是一个圆盘而不是一个圆?
Node2D.draw_circle
仍然可以作为draw_arc
从0
到TAU
的快捷方式存在。
@Goutte在英语中,“圆”可以指空心圆或实心圆。 我认为现在的名字更容易被发现,所以我不会改变它。
https://www.merriam-webster.com/dictionary/circle
1 b :闭合平面(参见平面条目 6 方向 2b)曲线,其每个点与曲线内的固定点等距(参见等距方向 1)
1 c : 由这样的曲线包围的平面
(1 b) 是数学圆(周长),(1 c)是数学圆盘(曲面)。
在 API 方面,拥有draw_rect(bool filled)
和draw_circle(bool filled)
比draw_rect()
、 draw_filled_rect()
、 draw_circle()
和draw_disk()
(或者填充矩形的数学名称是什么?)。
编辑:实际上draw_circle()
还没有filled
参数。 我认为我们应该添加一个,以便它可以用于绘制圆(周长)和圆盘(实心圆)。
不错,谢谢。 我的大多数学生都是法国人,他们都对此感到困惑,我也是,他们责怪戈多,我当然不能让他们。
实心矩形的数学名称是什么?
这是一个很好的问题; 我能找到的只是“矩形区域”或“矩形内部”,没有一个是足够的。 维基甚至指出,大多数人滥用 _polygon_ 一词来表示多边形的 _内部_,而没有提供其他词。
我想filled
参数可以帮助缓解歧义,但决定将它放在参数列表中的哪个位置会很痛苦。
@Goutte但是决定将它放在参数列表中的哪个位置会很痛苦。
由于它是一个可选参数(它有一个默认值),而且为了与draw_rect
保持一致,它应该放在最后。
在某些情况下,控制节点被称为模态节点。 https://github.com/godotengine/godot/search?q=modal&unscoped_q=modal主要与 Viewport.get_modal_stack_top() 函数有关
EditorInterface
的get_selected_path
和get_current_path
方法在名称和功能上令人困惑。 他们也缺乏文档。
这些方法只是FileSystemDock
同名方法之上的一个薄层:
String FileSystemDock::get_selected_path() const {
if (path.ends_with("/"))
return path;
else
return path.get_base_dir();
}
String FileSystemDock::get_current_path() const {
return path;
}
它们都应该适应“选定的”或“当前的”(或其他东西,但对于它们两者),一个是get_*_path
,另一个是get_*_dir
。
@Goutte实心矩形不是填充矩形的替代品吗?
OP 是否会根据 2019 年 6 月之后发布的建议进行更新? 我知道这是很多工作,但这种类型的跟踪器也非常适合贡献者一起解决。 而且我认为现在是我们可以开始重命名更多内容的时候了?
更新 OP 也意味着发布的建议被团队接受为值得的。
@Anutrix “填充”是比“固体”更好的词,因为“固体”可能意味着“不是液体或气体”。
@pycbouh如果有每个问题,链接 PR 也是一个好主意。 OP 已经这样做了,但不是为了它下面的评论。
我不知道它是否被提出,但我没有意识到我多久停下来看看这个文档:
Array.remove
=> remove_at
(如 C#)按索引删除Array.erase
=> remove_value
,或者只是remove
(如 C#)按值删除(或erase
变体)
因为现在, erase
和remove
对我来说意义相同,除了一个是按索引,另一个是按值,我一直忘记哪个是哪个。
已经提出了,我的坏。 没注意,Github在折叠线程,我的Ctrl+F搜索漏了xD
还没有进入 OP
@Zylann给你: https :
借用 Zylann,我一直忘记删除是按索引...
ButtonList
枚举可能应该重命名为MouseButtonList
因为它们是鼠标按钮。
JoystickList
枚举是否应该拆分? 它包含按钮和轴,它可能更有意义JoypadButtonList
和JoypadAxisList
或类似的。
只是一个问题,为什么不MouseButton
?
如果按钮 == MouseButton.LEFT:
读起来比
如果按钮 == MouseButtonList.LEFT:
好主意。 在这种情况下,还有KeyList
-> Key
, MidiMessageList
-> MidiMessage
,并且操纵杆需要移除List
.
我注意到一些方法/属性使用normal_map
,而其他方法/属性使用normalmap
。 我们应该选择其中任何一个,但可能不是两者都解决。 我更喜欢normal_map
,但我也可以使用normalmap
。
GDScript
range_lerp() = 地图()
种子 = set_seed()
map() 可能是为新的函数式编程特性保留的。
Vector2.tangent()
在文档中被描述为: Returns a perpendicular vector.
,这是orthogonal
或orthonormal
如果返回的向量被归一化的定义。 由于Vector2.tangent()
返回一个非标准化向量,我建议我们应该将其重命名为Vector2.orthogonal()
甚至Vector2.perpendicular()
如果人们有一些反对数学命名法甚至Vector2.normal()
,但人们可能会在normalized()
和normal()
之间混淆
关于我的轶事,但我第一次寻找这个,我在文档中的第一次搜索是 _perpendicular_。
您也可以保留.tangent()
作为.perpendicular()
的别名,不是吗?
我不喜欢orthogonal
这个名字,因为与其他单词相比,它不是一个常见的英语单词。 我之前没有发现tangent
,但我认为perpendicular
无论如何是一个更好的名字。
是的,正交很少见。 我投票支持 .perpendicular() 但保留 tangent() 别名为 compat 以及,它更短。
@ Zireael07如果我们只有一种获得切线的方法,我会更喜欢。 毕竟我不认为这是一个很常见的操作。
你会惊讶我在我的 procgen 脚本中使用它的频率:)
我没想到这会引发争论,但我个人反对保留Vector2.tangent()
因为这是对通常数学术语的不正确用法。 Vector2.tangent()
的乘积在定义上是错误的。 这个线程的名称是下一个计划的兼容性破坏,所以我看不出有任何理由我们应该向后弯曲以保持兼容性。 我个人对Vector2.perpendicular()
。
建议:默认将find_node()
的owner
参数设为 false。
建议:重命名Tree
的方法/信号,以减少与“选定”、“聚焦”和“无”等术语/状态相关的混淆。
我认为Tree::ensure_cursor_is_visible
具有误导性,应该重命名为ensure_focused_item_visible
或ensure_selected_item_visible
。
甚至类参考说:
Makes the currently focused cell visible.
This will scroll the tree if necessary. In SELECT_ROW mode, this will not do horizontal scrolling, as all the cells in the selected row is focused logically.
Note: Despite the name of this method, the focus cursor itself is only visible in SELECT_MULTI mode.
Script::get_instance_base_type()
专门返回下面的原生类型。 现在我们已经命名了脚本类,将其重命名为get_native_type()
更有意义,因为脚本的“基础”可能是脚本的名称。 这是误导。
@willnationsdev还有get_class()
https://github.com/godotengine/godot/issues/16863#issuecomment -491421079
@aaronfranke好吧, get_class()
普遍用于指代“我目前正在查看的事物的名称是什么?”。 因此,在Script
的情况下,我希望取回"GDScript"
、 "CSharpScript"
或类似的东西。 但是是的,对于非Script
类,它应该是一个方法,如果它被命名,则返回实际脚本类的名称。 甚至还有一个专门的问题。 https://github.com/godotengine/godot/issues/21789#issuecomment -618588900
编辑:哦,我想,如果我们有get_class()
、 get_base_class()
和get_native_class()
,你真的需要get_instance_base_type()
变成get_instance_native_class()
遵守命名约定并澄清它是实例而不是脚本的信息。
我认为autotile_coord
(属性和方法)的TileMap
应改名为tile_coord
或tile_coordinate
因为两个AUTO_TILE
和ATLAS_TILE
使用这个名称可能会让新用户感到困惑。 文档也需要更新。 如果没有问题,我可以进行此更改。
考虑从LineEdit.text_changed
删除new_text
参数,因为它与LineEdit.text
具有相同的行为。
还可以考虑添加old_text
作为new_text
补充或替代。
相关https://github.com/godotengine/godot/issues/16863#issuecomment -394745886
将“碰撞层”、“VisualInstance层”、“渲染层”等重命名为
“碰撞组”、“VisualInstance组”、“渲染组”、“灯光组”
关于为什么那些“层”没有堆叠的困惑像社区频道上的分钟时钟一样出现。
请注意,它们在 Maya、Lumberyard 和 Unity 中称为层。
仅仅因为别人做了某事并不意味着它仍然不会导致
混乱,是个好主意。
在星期一,2020年5月18日,13:09 Jummit [email protected]写道:
请注意,它们在 Maya、Lumberyard 和 Unity 中称为层。
—
您收到此消息是因为您订阅了此线程。
直接回复本邮件,在GitHub上查看
https://github.com/godotengine/godot/issues/16863#issuecomment-630349336 ,
或取消订阅
https://github.com/notifications/unsubscribe-auth/ABBEIS43HMTPCIFY4GYYK3LRSF2UTANCNFSM4ERRCEZA
.
我很惊讶还没有人提到它buuut
Camera2D.zoom
当变焦更大时,相机会缩小,这不是“变焦”的工作方式,而且是违反直觉的。 不确定将它重命名为什么,也许view_scale
或类似的东西。
@KoBeWi而不是重命名zoom
,我们不应该反转它的比例,以便在增加值时放大吗?
这将破坏兼容性,就像重命名属性一样。 不幸的是,如果我们走“反转比例”路线,则无法自动修复。 尽管如此,从长远来看,它可能会减少混乱。
@Calinou @KoBeWi是否有直接使用此缩放属性的用例,还是每个人都需要每次都将其反转以应用于缩放?
Viewport.get_final_transform()
=> Viewport.get_final_transform_2d()
?
Viewport.get_final_transform()
=>Viewport.get_final_transform_2d()
?
也许吧,但是我们在哪里划清界线,比如Node2D.get_position_2d()
?
也许我们可以将类命名为 Viewport2D,但除非我们制作 Viewport3D,否则不需要这样做。
@nathanfranke我提出这种方法是因为仅凭名称无法判断它是 2D 还是 3D,因为Transform
有两种类型。 (而其他成员已经有canvas_
或mouse_
)
@Zylann这种方法实际上很奇怪。 有属性叫做canvas_transform
和global_canvas_transform
,和的描述canvas_transform
是这样的:
视口的画布变换,用于更改所有子 CanvasItems 在屏幕上的位置。 这与视口的全局画布变换有关。
因此,您会期望get_final_transform
将这两个转换组合在一起。 但是,如果您查看代码,就会发现它实际上并非如此。
这个代码是return stretch_transform * global_canvas_transform;
。 我一直在试图弄清楚stretch_transform
的用途,但我不知道,它没有公开,而且在更改canvas_transform
时肯定没有设置。 还有一个名为_stretch_transform
,它不使用stretch_transform
。 它由set_size
调用,它将_stretch_transform
生成的值分配给stretch_transform
。 还有canvas_transform_override
我什至没有提到也没有公开,但在内部使用。
最后我觉得这整个班级都应该看看。 Viewport 有 4 个不同的 Transform2D 成员、4 个 Rect2(i) 成员、9 个 Vector2(i) 成员和 2 个 Transform (3D) 成员。 这已经是 264 字节(带有单精度浮点数)的仅存储转换信息的数据结构,如果将所有指针相加,则可能接近 1 KB。 也许 Viewport 确实需要所有这些,但它似乎过于复杂,至少应该有评论(这个文件中的评论太少了)。
应该删除 Node2D/Node3D to_global
和to_local
吗? 我在#38902 上提供了反馈,它建议添加仅适用于基础的方法,但这些方法存在一些问题。
在demo工程中, to_local
没有在任何地方使用, $ grep -RIn "to_global"
只返回5个结果,都是在3D demo的GUI中,可以通过修改来提高demo的性能这样它就可以缓存全局转换并使用xform
而不是to_global
。
简而言之,这些方法的问题在于它们不常用,而且它们鼓励编写性能不佳的代码,因为它会多次重新计算全局变换。
AnimationPlayer
的animation_started
和animation_finished
有点违反直觉。 第一个为队列中的所有动画调用,而后者仅在到达队列末尾时调用。 文档中没有明确提到它。
如果我们想检测任何特定动画何时结束,我们必须同时使用animation_changed
和animation_finished
,这很不方便。
我真的很喜欢@txigreman在那个问题上的建议:每当队列中的任何单个动画结束时,我们都可以使用animation_finished
并添加一个新信号animation_all_finished
(类似于Tween
' s tween_all_completed
) 仅在我们到达队列末尾时触发。
animation_queue_finished
和/或animation_queue_started
呢?
我在这里找不到,所以我建议,
find
和findn
对。
来自 3.2 最后一个稳定版本的图像。
也许我们可以重命名一个以提及它们处理区分大小写的性质。
说, find_ignorecase
而不是findn
?
@swarnimarun我们还有许多其他以n
结尾的不区分大小写的方法。 如果我们重命名其中一个,我们应该重命名所有的。
这些方法( find
/ findn
等)基本上是一样的。 我们可以添加一个参数是否应该区分大小写。
@Calinou我更喜欢这样,在放弃它几个月后使用 GDScript 有点让我对 API 有了新的看法,我想说,
越明显越好。 记住 API 本身就很困难,在函数命名中稍微冗长一点似乎是明智的改变。
非常感谢@KoBeWi能够用函数名称告诉它做什么,而不必记住添加另一个字段或在阅读代码时(在忘记/不知道 API 的那部分之后)。
所以我仍然更喜欢不同的函数,即使另一个函数只是用不同的参数或其他东西调用第一个函数。
EditorInterface.get_editor_viewport()
=> get_editor_main_container()
此函数不返回Viewport
,只返回Control
,它恰好是保存 2D、3D、脚本编辑器和资产库的中心函数。 作为记录,返回的节点甚至是VBoxContainer*
,但被抽象掉了(但知道这一点很重要,因为它会影响您对设置的选择)。
该文档也是错误的,因为它的描述链接到Viewport
类。 https://docs.godotengine.org/en/stable/classes/class_editorinterface.html#class -editorinterface-method-get-editor-viewport
@Zylann应该是get_editor_main_screen()
因为它不是容器,而是主屏幕。
@aaronfranke这也是一个Container
节点,实际上^^ 但是是的...主屏幕也可以工作
我想问:有人跟踪这个主题的提案吗?
例如,上面(https://github.com/godotengine/godot/issues/16863#issuecomment-557657413)我建议重命名JSON.print
方法。 提出了几个选项,但没有一个出现在第一篇文章中。
我只是担心有用的想法会在这么多帖子中丢失。 :微笑:
@dalexeev我最近在更新第一篇文章时做了第一遍,但我还没有完全浏览所有评论。
我有一个可能修复RichTextLabel
一些错误。 目前我们有bbcode_text
和text
,但两者在内部使用相同的数据结构。 只有被调用的方法不同,而当use_bbcode
未启用时, set_bbcode
会回退到set_text
。 所以我继续在#39148 中删除它们。 我在那里添加了一些其他要点。
Node 中的GetSceneInstanceLoadPlaceholder()
看起来非常错误,首先它没有返回顾名思义的占位符,而是一个布尔值,其次这会将继承实现的细节泄漏到基类中而没有真正的要求(测试类型节点的其他方式是可能的)
RayShape
→ SeparationRayShape
,最初在 godotengine/godot-proposals#711 中建议。
删除sort_custom
并使sort
成为可选的 Callable 怎么样?
我们应该分别删除OS.get_ticks_msec()
和OS.delay_msec()
以支持OS.get_ticks_usec()
和OS.delay_usec()
吗? 这将避免有两种方法来实现同一件事。 如果您需要一个以毫秒为单位的值,您可以将其乘以或除以 1000。
此外,GDScript 和 C++ 都允许在整数文字中添加分隔符,这使得大值更具可读性。
# Since Godot 3.2.
OS.delay_usec(123_456_789)
// Since C++14.
OS::get_singleton()->delay_usec(123'456'789);
此外,GDScript 和 C++ 都允许在整数文字中添加分隔符,这使得大值更具可读性。
如果删除发生, get_ticks_usec()
描述应该提到分隔符。
@Calinou一方面,您是对的,但另一方面 - 在大多数情况下,不需要如此高的准确性。
空间素材中的“阿尔法剪刀”应该成为标准的“阿尔法剪辑”
@Flavelius我还没有看到经常使用的术语“alpha 剪辑”。 不过,我已经看到“alpha 测试”的使用频率肯定比“alpha 剪辑”和“alpha 剪刀”要多得多。
有很多东西要改变! 有人致力于实施这些建议吗?
@MCrafterzz人们定期打开拉取请求以重命名事物。 这是逐步完成的,而不是一次性完成。
纹理 (Texture2D) 和图像
IMO: get_image
是的, get_bytes
否。
texture.get_image().get_data()
网格/网格实例
surface_get_material/surface_set_material
get_surface_material/set_surface_material
我猜应该是同一个名字吧?
@Coldragon它应该是get_surface_material
/ set_surface_material
和。surface_material
的属性
@Coldragon它应该是
get_surface_material
/set_surface_material
和surface_material
的属性。
这不是“正常”的设置/获取,它们有目标表面的索引(它是 Mesh 类中的 Vector)
Array
我们应该将empty()
重命名is_empty()
以更好地说明它是布尔值
String
我们应该放弃find_last()
以支持rfind()
。 不完全是重命名,但仍然值得讨论保留哪个。
对于单个数字,我们有stepify
。 对于 Vector2/Vector3,我们有snapped
。
它们做同样的事情,向量为每个组件调用stepify
。 应该选择一个名称,但选择哪一个?
Poll: :heart: = 两者都应该是stepify
, :rocket: = 两者都应该是snapped
, :-1: = 不要重命名。
AABB 有intersection
,而 Rect2 有clip
。 他们做同样的事情。 应该选择一个名称,但选择哪一个?
Poll: :heart: = 两者都应该是intersection
, :rocket: = 两者都应该是clip
, :-1: = 不要重命名。
@aaronfranke是的,我之前在https://github.com/godotengine/godot/issues/16863#issuecomment -449628319 中建议了intersection
名称。 然后我们有intersects
可以在Rect2
重命名为overlaps
,但不确定AABB
关于intersects
→ overlaps
重命名。
我认为 find_node 和/或 get_node 应该重命名,因为名称根本不表明它们 2 之间的差异。
既然 find_node 只看孩子,也许 find_child_node ?
我不确定 get_node 的替代名称是什么。 我的第一个想法是 get_tree_node,因为它可以从树中的任何位置获取节点,但它也可以在具有相对路径的场景树之外使用。
我发现get_node
不错,但find_node
可以重命名为find_child
@MuffinManKen我认为get_node
是完全可以理解的,因为正如您所说,它可以在任何地方获取任何节点,只要它与给定节点连接到同一棵树,无论它们是否属于场景树与否。
@Coldragon我不确定我是否喜欢将find_node
重命名find_child
,因为它给我的印象是它出于某种原因只适用于直系孩子。 另一种方法是将它称为find_descendant
或其他名称,但这太冗长/复杂了。 将其减少到find()
也没有意义,因为那时我们还不清楚我们在寻找什么。 因此,我认为除非寻求其他替代方案,否则find_node
应该保持原样。 它应该只是有明确记录的 API 文档行为差异。
exported
或release
呢?
@aaronfranke exported
表示该项目已导出,但不一定如此。 您可以使用导出模板二进制文件直接从其源文件运行项目,只要资产是事先导入的。
此外, release
已用于发布模式二进制文件(与用于调试模式二进制文件的debug
形成对比)。
runner
对我来说似乎不太清楚。 standalone
。 删除它也可以,因为您可以只使用!OS.get_feature("editor")
。
删除它也可以,因为您可以只使用
!OS.get_feature("editor")
。
但是,这不能用于覆盖项目设置,因为那里没有.not
选择器。 通过交换默认设置及其覆盖可能是可行的,但感觉有点复杂。
那么为什么不将app
或game
与editor
形成对比呢? 或者那只会更混乱? 也许有no-editor
的功能标志更明确?
@willnationsdev game
暗示 Godot 只能用于游戏。 许多人成功地将 Godot 用于非游戏应用程序,因此我更愿意使用更具包容性的术语:slightly_smiling_face:
此外,它并不是不言自明:人们可能认为它仍然适用于从编辑器运行的项目(毕竟您是从编辑器运行“游戏”)。 app
。
何为“独立”?
2020 年 7 月 25 日星期六,上午 5:49 Hugo Locurcio,通知@github.com
写道:
@willnationsdev https://github.com/willnationsdev游戏暗示戈多
只能用于游戏,事实证明并非如此 🙂此外,它并不是不言自明:人们可能仍然认为它
适用于从编辑器运行的项目。 应用程序也是如此。—
你收到这个是因为你被提到了。
直接回复本邮件,在GitHub上查看
https://github.com/godotengine/godot/issues/16863#issuecomment-663835822 ,
或取消订阅
https://github.com/notifications/unsubscribe-auth/AFMN5DM5U3KLXVUVIC2OGHTR5KTDXANCNFSM4ERRCEZA
.
@MuffinManKen independent
对我来说也不是很容易解释。
Editor vs Standalone 可能是标准命名(至少我在许多不同的引擎中看到过一个)所以没有理由重新发明轮子恕我直言。
Get_node 不限于获取后代,所以这将是一个非常
误导性的名字。 这两种方法需要非常不同的名称,因为它们
做是非常不同的。
2020 年 7 月 25 日星期六,下午 3:14 golddotasksquestions,<
[email protected]> 写道:
我记得一开始我很长时间的困惑
find_node 和 get_node。 我真的很喜欢 find_descendant 和
get_descendant,因为这些都是真实的,而且信息量很大@willnationsdev
https://github.com/willnationsdev @Coldragon
https://github.com/Coldragon
“罗嗦”可能不是每个人的茶,但 imho 并不是一个真正的
问题,因为有自动完成和速记“$”。—
你收到这个是因为你被提到了。
直接回复本邮件,在GitHub上查看
https://github.com/godotengine/godot/issues/16863#issuecomment-663890652 ,
或取消订阅
https://github.com/notifications/unsubscribe-auth/AFMN5DJNBNB6ZOUIV62VX2DR5MVJBANCNFSM4ERRCEZA
.
我认为在Transform
和Transform2D
方法中inverse
和xform_inv
应该被重命名/删除,因为这些方法实际上做的不是人们期望他们做的. 更多详情: https :
RayCast.cast_to
应该重命名为RayCast.segment
。 我刚刚有人说他花了 40 分钟才意识到这是一个属性而不是一个函数。 可能因为它也是一个动词。
RayCast.target
呢?
@razcore-art 我最近回答了一个与光线投射相关的问题,我用segment
这个词来描述它,所以我认为是有道理的。 但这也可以重写为direction
和length
,因此它实际上将变得更接近射线而不是线段,从几何上讲(或者只是提供可以共存的替代属性) . 问题是无法在检查器中轻松设置归一化方向向量。 我写了一个提案,至少是为 2D 制作一个提案:godotengine/godot-proposals#397,但也许这太牵强了。
编辑:经过进一步思考, segment
在RayCast
node方面没有多大意义,但在Physics2DDirectSpaceState.intersect_ray()
方面有意义。
RayCast.target
呢?
@nathanfranke我假设目标是Node
或NodePath
。 所以至少这可能是RayCast.target_position
。 也许RayCast.cast_position
或 。 不要忘记光线投射可以旋转,这可以改变全局坐标中的实际投射位置。RayCast.cast_offset
PhysX API证实了我关于配置光线投射的单位方向 + 长度的想法。 😛
也就是说,我倾向于cast_position
... 因为重写光线投射的工作方式需要更多的核心更改。
@Xrayez我会避免在属性开头使用“cast”这个词,因为我很自然地将它读作动词“cast”而不是名词“cast”,因此cast_position
可能不会有解决了不知道这是一个属性而不是一个方法的原始问题(很容易假设cast_position
是一个转换到一个位置的方法)。 我喜欢target_position
。
来自https://github.com/godotengine/godot/issues/19325#issuecomment -394155128:
可以将KEY_BACK
重命名KEY_MEDIA_BACK
并将KEY_FORWARD
重命名KEY_BACK
KEY_MEDIA_FORWARD
。 可能还有其他媒体密钥可以使用MEDIA
前缀。
我们应该考虑将String
begins_with()
更改starts_with()
。
在 Java、C#、Python、JavaScript 等中就是这种方式。
Bugsquad 编辑: https : //github.com/godotengine/godot/issues/16863#issuecomment -596069130
bool
、 float
、 int
是唯一名称以小写字母开头的类型/类。 我认为它们应该重命名(在 GDScript 中)为Bool
、 Float
、 Int
。 这将自动修复错误类型语法突出显示的问题。
并且bool
、 float
、 int
应该仅用于来自@GDScript页面的内置 Python 类函数(它们还包括len
和str
)。
请注意,情况与str
/ String
类似: str(x)
和String(x)
给出相同的结果。
添加。 它应该是这样的:
# `Int` is type.
func get_key() -> Int:
# `int` is Python-like function.
return int(config.get_value("sect", "key"))
@dalexeev它们是小写的,因为它们是原始类型。 您将在大多数其他语言中看到这一点。
像Node
是引用类型,不会在赋值时复制。
var a := Node2D()
var b = a
a.position = Vector2(2, 2)
print(b.position) # (2, 2)
如果有的话,我们应该考虑将String
重命名string
因为String
是不可变的,并且其行为更类似于int
不是Node
。
暂时编辑此内容,因为Vector2
、 Vector3
等也是这种情况。
@nathanfranke在不同的语言中是不同的。 例如,在 Kotlin、Haxe、Ada 中所有类型的名称都大写。
此外,原始性是一个有条件的概念。 对我来说String
、 Color
、 Vector2
等是原始类型,特别是因为它们是通过值而不是通过引用传递的。
唯一的障碍是违反了向后兼容性。
因为
String
是不可变的
令人惊讶的是,GDScript 中的字符串是可变的:
var s = "abc"
s[0] = "xyz"
print(s) # xyzbc
Vector2
不是原语,因为它由 2 float
。 但是, Vector2
和float
是内置变体类型。
@Zylann是不是应该反映在类型名称中的根本区别?
(对我来说,“原始”是“简单”,而不是“一体式”。)
我不想解释这一点对我有利,但是:
原始类型的名称大写。 :微笑:
以下是我理解的术语:
| 输入名称 | 原始类型 | 值类型 | 可变类型 | 内置型 |
| ------------- | ------------- | ------------- | ------------- | ------------- |
| 国际| 是 | 是 | 不适用 | 是 |
| 矢量2 | 没有 | 是 | 不适用 | 是 |
| 节点 | 没有 | 没有 | 是 | 是 |
| 字符串 | 没有 | 没有 | 没有 | 是 |
无论如何,这些名称不会改变。 它们按原样很好,并且为各种语言的程序员所熟悉。 我们应该结束这里的讨论,以避免用毫无意义的讨论填充这个跟踪器。
Mutable 类型列错误:只有 Object-derived、Dictionary 和 Array 是可变的。 ( Vector2
可能看起来可变,因为您可以执行vec2.x = 0
,但它实际上转换为类似vec2 = vec2.with_x(0)
)
将ShortCut
重命名Shortcut
以下方法应改
之间的不一致
Input.is_action_just_pressed(action: String) -> bool
Input.is_action_just_released(action: String) -> bool
Input.is_action_pressed(action: String) -> bool
到
Input.is_action_pressed(action: String, allow_echo: bool = false) -> bool
Input.is_action_released(action: String) -> bool
为了与
和
InputEvent.is_action_pressed(action: String, allow_echo: bool = false) -> bool
InputEvent.is_action_released(action: String) -> bool
需要纠正。
PS我从“相似方法越少越好”的原则出发。
@dalexeev布尔参数通常比使用不同的方法可读性差,因为true
和false
没有上下文。
是的,但一致性也会很好。 去掉 InputEvent 中的布尔参数呢?
@Calinou在大多数情况下,您不需要检查回声事件。
我不认为这是一个大问题。 当您键入代码时,会出现参数提示。 阅读代码时,您可以使用 Shift + 单击。 常用函数的参数很容易记住(例如, String.split
)。
此外,在doc/classes
目录中发现了 208 个可选的布尔参数(这只是核心,还有 16 个模块有一个嵌套目录doc_classes
)。
AcceptDialog.xml
17: <argument index="1" name="right" type="bool" default="false">
AnimatedSprite2D.xml
26: <argument index="1" name="backwards" type="bool" default="false">
AnimationNode.xml
53: <argument index="5" name="optimize" type="bool" default="true">
74: <argument index="6" name="optimize" type="bool" default="true">
AnimationPlayer.xml
146: <argument index="3" name="from_end" type="bool" default="false">
201: <argument index="1" name="update" type="bool" default="false">
223: <argument index="0" name="reset" type="bool" default="true">
Animation.xml
349: <argument index="2" name="exact" type="bool" default="false">
Array.xml
130: <argument index="1" name="before" type="bool" default="true">
146: <argument index="3" name="before" type="bool" default="true">
172: <argument index="0" name="deep" type="bool" default="false">
366: <argument index="3" name="deep" type="bool" default="false">
AStar2D.xml
79: <argument index="2" name="bidirectional" type="bool" default="true">
114: <argument index="1" name="include_disabled" type="bool" default="false">
276: <argument index="1" name="disabled" type="bool" default="true">
AStar.xml
74: <argument index="2" name="bidirectional" type="bool" default="true">
94: <argument index="2" name="bidirectional" type="bool" default="true">
113: <argument index="2" name="bidirectional" type="bool" default="true">
131: <argument index="1" name="include_disabled" type="bool" default="false">
293: <argument index="1" name="disabled" type="bool" default="true">
Camera3D.xml
15: <argument index="0" name="enable_next" type="bool" default="true">
CanvasItem.xml
274: <argument index="2" name="filled" type="bool" default="true">
376: <argument index="4" name="transpose" type="bool" default="false">
403: <argument index="4" name="transpose" type="bool" default="false">
411: <argument index="8" name="clip_uv" type="bool" default="true">
ClassDB.xml
55: <argument index="1" name="no_inheritance" type="bool" default="false">
66: <argument index="1" name="no_inheritance" type="bool" default="false">
88: <argument index="1" name="no_inheritance" type="bool" default="false">
110: <argument index="1" name="no_inheritance" type="bool" default="false">
134: <argument index="2" name="no_inheritance" type="bool" default="false">
CodeHighlighter.xml
19: <argument index="3" name="p_line_only" type="bool" default="false">
Color.xml
251: <argument index="0" name="with_alpha" type="bool" default="true">
Control.xml
586: <argument index="2" name="keep_margin" type="bool" default="false">
588: <argument index="3" name="push_opposite_anchor" type="bool" default="true">
605: <argument index="3" name="push_opposite_anchor" type="bool" default="false">
629: <argument index="1" name="keep_margins" type="bool" default="false">
720: <argument index="1" name="keep_margins" type="bool" default="false">
758: <argument index="1" name="keep_margins" type="bool" default="false">
779: <argument index="1" name="keep_margins" type="bool" default="false">
CryptoKey.xml
26: <argument index="1" name="public_only" type="bool" default="false">
38: <argument index="1" name="public_only" type="bool" default="false">
49: <argument index="1" name="public_only" type="bool" default="false">
59: <argument index="0" name="public_only" type="bool" default="false">
Curve2D.xml
121: <argument index="1" name="cubic" type="bool" default="false">
Curve3D.xml
145: <argument index="1" name="cubic" type="bool" default="false">
158: <argument index="1" name="apply_tilt" type="bool" default="false">
Dictionary.xml
89: <argument index="0" name="deep" type="bool" default="false">
Directory.xml
127: <argument index="0" name="skip_navigational" type="bool" default="false">
129: <argument index="1" name="skip_hidden" type="bool" default="false">
DisplayServer.xml
647: <argument index="2" name="multiline" type="bool" default="false">
EditorInterface.xml
212: <argument index="1" name="with_preview" type="bool" default="true">
EditorNode3DGizmoPlugin.xml
40: <argument index="3" name="cancel" type="bool" default="false">
60: <argument index="1" name="billboard" type="bool" default="false">
73: <argument index="2" name="on_top" type="bool" default="false">
88: <argument index="2" name="billboard" type="bool" default="false">
90: <argument index="3" name="on_top" type="bool" default="false">
92: <argument index="4" name="use_vertex_color" type="bool" default="false">
EditorNode3DGizmo.xml
37: <argument index="2" name="billboard" type="bool" default="false">
39: <argument index="3" name="secondary" type="bool" default="false">
53: <argument index="2" name="billboard" type="bool" default="false">
66: <argument index="1" name="billboard" type="bool" default="false">
103: <argument index="2" name="cancel" type="bool" default="false">
EditorProperty.xml
30: <argument index="3" name="changing" type="bool" default="false">
Expression.xml
36: <argument index="2" name="show_error" type="bool" default="true">
File.xml
211: <argument index="0" name="allow_objects" type="bool" default="false">
439: <argument index="1" name="full_objects" type="bool" default="false">
Font.xml
47: <argument index="5" name="outline" type="bool" default="false">
GIProbe.xml
19: <argument index="1" name="create_visual_debug" type="bool" default="false">
HTTPClient.xml
32: <argument index="2" name="use_ssl" type="bool" default="false">
34: <argument index="3" name="verify_host" type="bool" default="true">
HTTPRequest.xml
110: <argument index="2" name="ssl_validate_domain" type="bool" default="true">
ImageTexture.xml
43: <argument index="1" name="immediate" type="bool" default="false">
Image.xml
226: <argument index="0" name="renormalize" type="bool" default="false">
415: <argument index="0" name="square" type="bool" default="false">
433: <argument index="1" name="grayscale" type="bool" default="false">
ImmediateGeometry3D.xml
24: <argument index="3" name="add_uv" type="bool" default="true">
InputEvent.xml
54: <argument index="1" name="allow_echo" type="bool" default="false">
Input.xml
40: <argument index="1" name="update_existing" type="bool" default="false">
InstancePlaceholder.xml
16: <argument index="0" name="replace" type="bool" default="false">
33: <argument index="0" name="with_order" type="bool" default="false">
ItemList.xml
19: <argument index="1" name="selectable" type="bool" default="true">
32: <argument index="2" name="selectable" type="bool" default="true">
58: <argument index="1" name="exact" type="bool" default="false">
235: <argument index="1" name="single" type="bool" default="true">
JavaScript.xml
18: <argument index="1" name="use_global_execution_context" type="bool" default="false">
JSONRPC.xml
59: <argument index="1" name="recurse" type="bool" default="false">
JSON.xml
28: <argument index="2" name="sort_keys" type="bool" default="false">
KinematicBody2D.xml
78: <argument index="1" name="infinite_inertia" type="bool" default="true">
80: <argument index="2" name="exclude_raycast_shapes" type="bool" default="true">
82: <argument index="3" name="test_only" type="bool" default="false">
96: <argument index="2" name="stop_on_slope" type="bool" default="false">
102: <argument index="5" name="infinite_inertia" type="bool" default="true">
125: <argument index="3" name="stop_on_slope" type="bool" default="false">
131: <argument index="6" name="infinite_inertia" type="bool" default="true">
145: <argument index="2" name="infinite_inertia" type="bool" default="true">
KinematicBody3D.xml
80: <argument index="1" name="infinite_inertia" type="bool" default="true">
82: <argument index="2" name="exclude_raycast_shapes" type="bool" default="true">
84: <argument index="3" name="test_only" type="bool" default="false">
98: <argument index="2" name="stop_on_slope" type="bool" default="false">
104: <argument index="5" name="infinite_inertia" type="bool" default="true">
127: <argument index="3" name="stop_on_slope" type="bool" default="false">
133: <argument index="6" name="infinite_inertia" type="bool" default="true">
158: <argument index="2" name="infinite_inertia" type="bool" default="true">
Marshalls.xml
35: <argument index="1" name="allow_objects" type="bool" default="false">
65: <argument index="1" name="full_objects" type="bool" default="false">
Navigation2D.xml
43: <argument index="2" name="optimize" type="bool" default="true">
Navigation3D.xml
46: <argument index="2" name="use_collision" type="bool" default="false">
65: <argument index="2" name="optimize" type="bool" default="true">
NavigationServer3D.xml
209: <argument index="3" name="use_collision" type="bool" default="false">
Node2D.xml
63: <argument index="1" name="scaled" type="bool" default="false">
74: <argument index="1" name="scaled" type="bool" default="false">
Node.xml
126: <argument index="1" name="legible_unique_name" type="bool" default="false">
146: <argument index="1" name="legible_unique_name" type="bool" default="false">
159: <argument index="1" name="persistent" type="bool" default="false">
189: <argument index="1" name="recursive" type="bool" default="true">
191: <argument index="2" name="owned" type="bool" default="true">
540: <argument index="2" name="parent_first" type="bool" default="false">
599: <argument index="1" name="keep_data" type="bool" default="false">
737: <argument index="1" name="recursive" type="bool" default="true">
Object.xml
378: <argument index="1" name="reversed" type="bool" default="false">
OS.xml
73: <argument index="2" name="blocking" type="bool" default="true">
77: <argument index="4" name="read_stderr" type="bool" default="false">
141: <argument index="0" name="utc" type="bool" default="false">
150: <argument index="0" name="utc" type="bool" default="false">
303: <argument index="0" name="utc" type="bool" default="false">
451: <argument index="0" name="short" type="bool" default="false">
PacketPeerDTLS.xml
17: <argument index="1" name="validate_certs" type="bool" default="true">
PacketPeer.xml
36: <argument index="0" name="allow_objects" type="bool" default="false">
57: <argument index="1" name="full_objects" type="bool" default="false">
PCKPacker.xml
33: <argument index="0" name="verbose" type="bool" default="false">
PhysicsDirectSpaceState2D.xml
62: <argument index="4" name="collide_with_bodies" type="bool" default="true">
64: <argument index="5" name="collide_with_areas" type="bool" default="false">
89: <argument index="5" name="collide_with_bodies" type="bool" default="true">
91: <argument index="6" name="collide_with_areas" type="bool" default="false">
107: <argument index="4" name="collide_with_bodies" type="bool" default="true">
109: <argument index="5" name="collide_with_areas" type="bool" default="false">
PhysicsDirectSpaceState3D.xml
63: <argument index="4" name="collide_with_bodies" type="bool" default="true">
65: <argument index="5" name="collide_with_areas" type="bool" default="false">
PhysicsServer2D.xml
21: <argument index="3" name="disabled" type="bool" default="false">
351: <argument index="3" name="disabled" type="bool" default="false">
PhysicsServer3D.xml
21: <argument index="3" name="disabled" type="bool" default="false">
351: <argument index="3" name="disabled" type="bool" default="false">
426: <argument index="1" name="init_sleeping" type="bool" default="false">
PopupMenu.xml
36: <argument index="2" name="global" type="bool" default="false">
70: <argument index="3" name="global" type="bool" default="false">
118: <argument index="3" name="global" type="bool" default="false">
133: <argument index="3" name="global" type="bool" default="false">
195: <argument index="2" name="global" type="bool" default="false">
219: <argument index="2" name="global" type="bool" default="false">
526: <argument index="2" name="global" type="bool" default="false">
ProjectSettings.xml
93: <argument index="1" name="replace_files" type="bool" default="true">
Rect2.xml
146: <argument index="1" name="include_borders" type="bool" default="false">
RenderingDevice.xml
29: <argument index="4" name="sync_with_draw" type="bool" default="true">
413: <argument index="3" name="arg3" type="bool" default="false">
493: <argument index="1" name="allow_cache" type="bool" default="true">
565: <argument index="6" name="sync_with_draw" type="bool" default="false">
591: <argument index="9" name="sync_with_draw" type="bool" default="false">
677: <argument index="2" name="sync_with_draw" type="bool" default="false">
691: <argument index="3" name="sync_with_draw" type="bool" default="false">
RenderingServer.xml
847: <argument index="0" name="swap_buffers" type="bool" default="true">
1812: <argument index="3" name="color_format" type="bool" default="false">
1814: <argument index="4" name="custom_data_format" type="bool" default="false">
2455: <argument index="3" name="use_filter" type="bool" default="true">
2557: <argument index="2" name="is_2d_skeleton" type="bool" default="false">
ResourceLoader.xml
61: <argument index="2" name="no_cache" type="bool" default="false">
100: <argument index="2" name="use_sub_threads" type="bool" default="false">
Resource.xml
24: <argument index="0" name="subresources" type="bool" default="false">
RigidBody2D.xml
106: <argument index="1" name="infinite_inertia" type="bool" default="true">
SceneState.xml
142: <argument index="1" name="for_parent" type="bool" default="false">
SceneTree.xml
65: <argument index="1" name="pause_mode_process" type="bool" default="true">
ScriptCreateDialog.xml
25: <argument index="2" name="built_in_enabled" type="bool" default="true">
27: <argument index="3" name="load_enabled" type="bool" default="true">
Script.xml
107: <argument index="0" name="keep_state" type="bool" default="false">
Skeleton3D.xml
238: <argument index="3" name="persistent" type="bool" default="false">
SkeletonIK3D.xml
25: <argument index="0" name="one_time" type="bool" default="false">
StreamPeerSSL.xml
33: <argument index="1" name="validate_certs" type="bool" default="false">
StreamPeer.xml
128: <argument index="0" name="allow_objects" type="bool" default="false">
274: <argument index="1" name="full_objects" type="bool" default="false">
String.xml
587: <argument index="0" name="with_prefix" type="bool" default="false">
855: <argument index="1" name="allow_empty" type="bool" default="true">
924: <argument index="1" name="allow_empty" type="bool" default="true">
947: <argument index="1" name="allow_empty" type="bool" default="true">
957: <argument index="0" name="left" type="bool" default="true">
959: <argument index="1" name="right" type="bool" default="true">
SurfaceTool.xml
216: <argument index="0" name="flip" type="bool" default="false">
TextEdit.xml
61: <argument index="1" name="adjust_viewport" type="bool" default="true">
73: <argument index="1" name="adjust_viewport" type="bool" default="true">
75: <argument index="2" name="can_be_hidden" type="bool" default="true">
Texture2D.xml
23: <argument index="3" name="transpose" type="bool" default="false">
50: <argument index="4" name="transpose" type="bool" default="false">
77: <argument index="4" name="transpose" type="bool" default="false">
89: <argument index="10" name="clip_uv" type="bool" default="true">
TileMap.xml
137: <argument index="1" name="ignore_half_ofs" type="bool" default="false">
153: <argument index="3" name="flip_x" type="bool" default="false">
155: <argument index="4" name="flip_y" type="bool" default="false">
157: <argument index="5" name="transpose" type="bool" default="false">
183: <argument index="2" name="flip_x" type="bool" default="false">
185: <argument index="3" name="flip_y" type="bool" default="false">
187: <argument index="4" name="transpose" type="bool" default="false">
TileSet.xml
323: <argument index="3" name="one_way" type="bool" default="false">
TreeItem.xml
22: <argument index="3" name="disabled" type="bool" default="false">
205: <argument index="0" name="wrap" type="bool" default="false">
229: <argument index="0" name="wrap" type="bool" default="false">
439: <argument index="2" name="just_outline" type="bool" default="false">
567: <argument index="4" name="expr" type="bool" default="false">
UndoRedo.xml
103: <argument index="0" name="increase_version" type="bool" default="true">
Viewport.xml
117: <argument index="1" name="in_local_coords" type="bool" default="false">
165: <argument index="1" name="in_local_coords" type="bool" default="false">
添加。 如果/何时可以指定参数的名称,那么这肯定不再是问题:
if e.is_action_pressed("ui_left", allow_echo = true):
velocity += Vector2.LEFT
var arr = s.split(",", allow_empty = false)
@dalexeev你能考虑把它放在
@dalexeev在很多情况下,您需要检查某个键是否被按下,而不仅仅是是否刚刚按下。 例如,用于移动角色的脚本需要使用 WASD 或箭头键来执行此操作。 几乎每个游戏都需要处理输入,所以我认为只有两种方法来处理这些事情并没有浪费。
阅读代码时,您可以使用 Shift + 单击。
如果您正在 GitHub 上查看差异,则不会。 如果代码需要 IDE 可读,那么它就不是好代码。
@aaronfranke对于其他 207 个案例,您是否还建议创建单独的函数? 如果不是,那么这个论点就不是决定性的。 另外,我上面写过,如果你可以指定参数名称,那么它在没有IDE的情况下变得可读。
在很多情况下,您需要检查某个键是否被按下,而不仅仅是是否刚刚按下。
经常,但不会比没有回声更频繁。
三个方法( is_action_just_pressed
、 is_action_just_released
、 is_action_pressed
)的存在令人困惑,因为您期望有一个is_action_released
方法。
添加。 哪个选项更容易,至少在视觉上是这样?
is_action_released
可以用not is_action_pressed
。 这不适用于just
方法。
如上所述,应避免使用原始布尔值。 像 INPUT_ALLOW_ECHO/INPUT_NO_ECHO 这样的标志会比 bool 好得多。
@dalexeev那只会引起混乱。 is_action_pressed()
和 echo 是两个不同的东西。 你可以自己检查一下,第一次按下后有轻微延迟后收到回声事件,而is_action_pressed()
没有延迟。
@KoBeWi你可能是对的
is_action_pressed(action: String, allow_echo: bool = false) -> bool
应该改为
is_action_pressed(action: String, allow_echo: bool = true) -> bool
因为这与
func _input(e):
if !e.is_action("ui_left"):
return
$Label.text += "pressed: %s, echo: %s\n" % [e.is_pressed(), e.is_echo()]
pressed: True, echo: False
pressed: True, echo: True
pressed: True, echo: True
pressed: True, echo: True
pressed: False, echo: False
@dalexeev您提出的建议不正确。 当我们谈论回声事件时,我们谈论按下一个键时重复的键盘事件,在这里使用这个术语没有多大意义,因为动作系统不直接依赖于事件,它的状态以每帧的方式更新。 此外,动作也可以与其他设备一起使用,如控制器或鼠标按钮,其中“echo”事件不存在。
TreeItem 的 get_children() 只返回第一个孩子,而不是像名称(或文档中的描述)建议的所有孩子。
[编辑]
Nvm 文档。 方法描述在master中更新,抱歉。
我建议 Resource 的local_to_scene
应该是local_to_instance
或unique_per_instance
。 “本地到场景”表示作为场景本地的行为,当它实际上是一个场景的每个实例时。
重命名Image.load()
→ Image.load_from_file()
。
load("image.png")
文件可能造成的混淆,请参阅 #42412 处的文档更改。Image.load()
将不再突出显示为 GDScript 内置名称:#28866。Image.load_*_from_buffer()
一致。 缓冲区相关的方法可以潜在地统一到同一个接口中以防止 API 膨胀,但这是另一个要讨论的话题。@Xrayez删除load
也可能值得: https :
ProjectSettings 中的变量registering_order
和相关方法set_registering_order
未使用。
RandomNumberGenerator
应该重命名为Random
并且应该弃用或删除randf
和rand_range
等全局随机函数。
我看到在指定随机种子时调用不受信任的函数的可能问题
seed(123)
randf()
call_method() # This could change the seed for its own random reasons!
randf()
应弃用或删除
randf
和rand_range
等全局随机函数。
作为 godotengine/godot-proposals#1590 的一部分进行了讨论。
我更喜欢这些基本的随机方法在全局范围内用于可访问性和原型设计目的,至少是其中一些。 但是seed()
和rand_seed()
肯定可以删除。
看起来FuncRef
自从添加了Callable
后就变得多余了。
我在 Inspector 中发现了property_can_revert
和property_get_revert
,并在 #43078 中报告了它们。 但是,我认为它们应该用前导下划线重命名,以遵循_get
、 _set
和_get_property_list
的约定。
EditorImportPlugin
和EditorExportPlugin
看起来是相关的,但是一个是关于导入资源,另一个是关于导出项目。 我建议我们将EditorImportPlugin
重命名EditorResourceImportPlugin
或类似的内容。
编辑: EditorPlugin.add_import_plugin
必须相应地重命名。
为什么不是ResourceImportPlugin
? 许多(大多数?)编辑器类已经不包含“编辑器”一词,例如SceneTreeDock
或所有动画内容。
应将ARVRInterface
的TrackingStatus
,以与其他枚举名称的样式保持一致。
看看上面的ARVRInterface
,名字的质量总体来说很差。 以下是我建议的重命名:
ar_is_anchor_detection_enabled
→ anchor_detection_enabled
(财产)interface_is_initialized
→ initialized
(属性,可以进一步重写为enabled
,因为它有一个 setter)interface_is_primary
→ primary
(财产)get_render_targetsize()
→ get_render_target_size()
(方法)uninitialize()
→ finalize()
(方法)否则文档是错误的。 🙂
请注意,我根本没有使用过这个类,但是仅通过查看该类,这些名称看起来就很奇怪。
我们应该将Control.MOUSE_FILTER_PASS
重命名Control.MOUSE_FILTER_PASSTHROUGH
吗? 这将使事件通过Control 节点传递到位于其下方的节点变得更加明显。 不过,我不确定它是否真的值得重命名。
@Calinou我不认为它会受到伤害,所以我会支持。 就像您提到的那样,这种更改将使鼠标过滤器模式的作用一目了然。
@Calinou我发现当前的行为不寻常。 此场景设置产生“单击 Child2,单击场景”
(注意,都设置为Pass)
:smile:命题 A :对于当前的行为,可能类似于Control.MOUSE_FILTER_PASSPARENTS
类的东西,因为输入事件似乎只发送给父母。
:rocket:命题 B :将常量更改为:
:eyes:命题 C :节点是否接受 gui 输入并不真正相关,因为人们不能连接任何信号(或使用布尔标志)。 我们可以将选项更改为Control.propagation_mode
并具有以下常量:
在我看来,那看起来会干净很多。
这超出了重命名的范围,应该作为提案进行讨论。
为什么所有这些重命名都这么长? 您正在将一些简单而简短的内容更改为非常长的内容。
您将clip
更改intersection
两倍输入时间。
您还将Control.MOUSE_FILTER_PASS
更改Control.MOUSE_FILTER_PASSTHROUGH
等等
我更喜欢更简单、更短、更简洁的更改。 它是一个函数名,而不是函数的描述。
我更喜欢更简单、更短、更简洁的更改。 它是一个函数名,而不是函数的描述。
名称应该是描述性的。 如果您利用自动完成功能(内置在 Godot 编辑器中),长度也无关紧要。
我在 IRC 上提到过一次,但没有得到回复,但 TextureRect 有一个拉伸模式,称为“Scale On Expand (Compat)”。 这听起来像是可以删除的东西。
如果我们想在我们的 Godot 项目中拥有健壮的代码库,“不那么冗长”绝对不在菜单上。 现代编码工具提供自动完成和其他智能功能,即使名称很长,您也可以快速输入。 另外,如果您阅读了这些更改的论证,那么您的目标是让使用它们的开发人员对这些功能不那么含糊。 短名称可能很甜蜜,但令人困惑且不易发现。
永远记住:输入代码是软件开发的快速部分。 之后阅读和理解代码更为重要。 这就像分别怀孕和抚养孩子。
我不同意你们两个。 我是 Godot 用户,我特别使用 Godot,因为 GDScript 简洁且编写迅速。 如果你想让它们长两倍,那么速度优势就会消失,因为我将被迫两次写入两倍,并且必须滚动两倍才能水平地看到整行代码。
当您编码时,您不想输入非常长的函数或变量名称。 其中一些提议的更改为了“清晰”而增加了极长的函数和变量名称,而牺牲了其他一切。 如果您有任何疑问,可以阅读内置帮助。 Plus 编程是关于学习 API。 无论名称如何,您第一次使用时都会查找该函数。 在 C 中使用 printf 简洁明了。 在 Godot 中,您将其命名为send_formatted_string_to_standard_out.
不仅您强迫每个人重新学习 api,而且其中一些更改甚至没有统一的愿景。 在我看来,就像一大群人聚在一起,每个人都改变了引擎的一个部分。
以数组为例
remove
-> remove_at
_at 在这里添加了什么? 您已经拥有 remove_value。 你还能去除什么?
erase
-> remove_value
还是不够清楚。 来自文档“从数组中删除第一次出现的值。” 此外,人们可能认为您可以从整个数组中删除一个值。 为清楚起见,它实际上应该是remove_first_occurance_of_value
因为这就是函数的实际作用。 所以你让函数变得更长,同样令人困惑的时间更长。
你有remove
和erase
两个不同的函数,但是你在remove
用额外的字母把它们变成了相同的变体。 但它们的功能不同。 删除从特定索引中删除,其中擦除删除找到的值的第一个实例。
除了强迫人们更新他们的代码之外,这些都没有用。
反转 -> 反转
复制 -> 克隆
空 -> is_empty
如果没有损坏,请不要修复它。
@CarlGustavAlbertDwarfsteinYung但你不会打字两倍。 在您输入的前 3 个字母之后,自动补全将启动,您可以选择需要的内容,而不是输入整个单词。
至于其他名称,例如,当您查看empty -> is_empty
,需要更改以说明其作用。 当您查看empty
时,您是否可以判断这是一个清空某些内容的方法,它是检查某些内容是否为空的书,还是其他内容? 使用is_empty
您可以一眼看出这是一个布尔值,如果某物为空则为真,否则为假。 仅通过阅读它们的名称,您就应该知道函数或变量的作用。 你不能用像empty
这样的名字来做到这一点
@Feniks-Gaming 我可以告诉你 empty 或 is_empty 同样令人困惑,只是一个比另一个长。
@CarlGustavAlbertDwarfsteinYung empty
可以是一个动作,如果它被读作动词。 is_empty
绝对是一种品质。 当然,这种混淆可能取决于您的英语水平。
此外,即使一个函数在现代代码编辑器中被称为send_formatted_string_to_standard_out
,它也可以输入为sfstso
,或者中间字母的任何其他组合,如果你愿意,自动完成会给你唯一的选择。
@pycbouh人们已经使用这个引擎多少年了? 而且我还没有听到有人来找我说你知道这个引擎最大的问题是什么。 数组具有empty
而不是is_empty
的事实。
你们坐在这里修理没人想要或要求的东西。 是的,措辞令人困惑,但并不是一个真正的问题,自从我 2015 年开始使用这个引擎以来从来没有成为一个问题。一些提议的更改非常受欢迎,公平地说,我确实使用 is_ 。 是空的就好了。 但是有些变化太长而且同样令人困惑。 我不是在专门谈论这些变化。
这个大线程的整个存在就是人们要求它的证据。 这些问题对您或其他人来说可能无关紧要,但由于命名不当,人们确实在理解 API 方面存在问题。 这就是本期收集的问题类型。 至于这些变化的总体意义,信不信由你,但跟踪和实施这些变化并不会占用其他开发时间。
看看你给出的例子并试图解释:
删除从特定索引中删除,其中擦除删除找到的值的第一个实例。
你写了那个并且认为没有理由改进命名至少对所有当前和未来的Godot 用户更清晰一点?
@pycbouh事实上,我什至给出了数组remove_at
和remove_value
的例子。 remove_value
与擦除的描述不同,仍然同样令人困惑。 从哪里移除价值? 从末尾删除值,从头删除? 从数组中删除所有出现的值?
如果您真的需要更改内容,请使用remove
和remove_first_occurence
,这使得它既简洁又具有描述性。
@pycbouh我不是要它。 这个线程的存在是因为有些人过度设计和修复没有打破经典程序员时尚的东西。 未来的用户呢? 他们呢? 我曾经是一个未来的用户,我学会了 api。 我对函数命名没有问题。 50% 的评论是不同意提议的更改的人。 似乎这些变化中的大部分是由少数社区成员推动这些变化到每个人身上的。 我们可以对提议的更改进行投票吗?
事实上,这是一个提案。 API 命名的任何更改都应包括贡献者/捐赠者/用户的意见。 如果他们都同意,那么我也在船上。 进行民意调查,看看每个人的事情。 不要试图猜测别人想要什么。 对你有好处的可能对其他人没有好处。
根据我所看到的,我反对这里提出的大约 50% 的更改。
50% 的评论是不同意提议的更改的人。
我们可以把编好的统计数字留在门口好吗?
我们可以对提议的更改进行投票吗?
这就是讨论和反应的目的。
根据我所看到的,我反对这里提出的大约 50% 的更改。
如果你反对他们只是因为“我是这样学的,所以我希望我之后的每个人都遭受同样的痛苦”,那么这是对该命题的无效批评,将被忽略。
对你有好处的可能对其他人没有好处。
同上。
我们可以把编好的统计数字留在门口好吗?
喜欢这个关于整个社区的说法吗?
这些问题对您或其他人来说可能无关紧要,但由于命名不当,人们确实在理解 API 方面存在问题。
你怎么知道人们有什么问题? 你问他们了吗? 是否有关于此的民意调查或研究或任何问卷调查? 你是怎么得到这些信息的?
我就是这样一位从零开始学习 API 的用户。 命名没有问题。 所有 API 都有一些奇怪的命名约定。 所有函数都需要简洁一些,以便您可以在代码中编写它们。
@pycbouh如果你想让我相信这里的所有命名建议都是好的,我将不得不恭敬地不同意你的观点。 这是一个讨论更改的线程,我在这里要说的是,一些提议的更改不仅没有必要/或要求,而且时间更长而且同样令人困惑。 有些确实很好,很受欢迎。 让我们不要因为像您这样的少数人认为整个社区对 API 名称有问题而大量重命名所有内容。 我没有也从来没有,我从初学者开始。 我知道其他一些人也没有。 我相信其中一些变化很重要,应该由整个社区或至少在完整版本之前由贡献者进行同行评审。
你怎么知道人们有什么问题? 你问他们了吗?
该线程中的大多数条目都是由遇到问题的人产生的,无论是在 GitHub 上(在这些情况下,问题都已链接)或使用其他社区或个人渠道。 不要以为我们只是坐在这里舔自己的私人部分,因为我们无事可做,只能考虑在引擎中重命名哪些其他功能或属性。
此外,这里提出的许多更改甚至还没有被执行,也没有 PR 或任何其他活动。 他们被列出,就是这样。 密切关注 PR,如果有人冒犯你,请毫不犹豫地发表评论。 之后,由 Godot 的 PM 批准和合并更改。 要有建设性,你可以防止一些不必要的修改,但不要忘记你自己曾经说过的话:
对你有好处的可能对其他人没有好处。
因此,即使到目前为止您对 API 没有任何问题,但这并不意味着其他人也没有或他们将来不会有任何问题。
所有 API 都有一些奇怪的命名约定。
如果有一个约定可言,那就太好了。 但是 Godot 中的一些 API 早在它开源之前就已命名,并且可能不像人们希望的那样经过深思熟虑。 我再次要求您不要假设这里的人建议更改。
请不要在这里进行此类讨论。 如果您想讨论特定的 API 更改,那很好,但是您不喜欢这里的建议的笼统声明无济于事。
核心开发人员将一一审查这些建议。 许多人很可能最终不会被接受。
暂时锁定,稍后解锁。
我们可以将以下几点添加到列表中吗?
AnimationPlayer
:将stop()
重命名pause()
(https://github.com/godotengine/godot/issues/16863#issuecomment-562363660,godotengine/godot-proposals#287)AnimatedSprite
: 将stop()
重命名pause()
(#31168)AnimatedSprite3D
: 将stop()
重命名pause()
(#31168)Tween
:将stop()
重命名pause()
,将stop_all()
重命名stop()
pause_all()
(PR #41794, #43442)Tween:将 stop() 重命名为 pause(),将 stop_all() 重命名为 pause_all() (#43442)
这由 #41794 涵盖
@opl- 这也在此处讨论: https :
一些重命名可能会使这些全局作用域 RNG 函数的作用更加清晰:
seed()
-> set_seed()
(也可能添加get_seed()
以匹配 RandomNumberGenerator)——目前,不清楚这是一个 setter 函数。rand_seed()
-> rand_from_seed()
- 目前,听起来它可能会随机化种子或其他东西,但实际上它会根据提供的种子给出随机数。rand_seed() -> rand_from_seed() - 目前,听起来它可能会随机化种子或其他东西,当它实际上根据提供的种子给出随机数时。
除了它确实随机化种子。 阅读文档。
rand_seed() -> rand_from_seed() - 目前,听起来它可能会随机化种子或其他东西,当它实际上根据提供的种子给出随机数时。
除了它确实随机化种子。 阅读文档。
对不起。 我的意思是听起来它只是随机化种子。 也许它应该是rand_int_from_seed()
,因为它返回一个整数? 实际上,文档没有指定它返回的类型,只提到了一个“随机……数字”。 它是一个整数吗?
因此,它会根据您传递给它的种子生成一个新种子,然后根据该新种子生成一个新数字? 不确定重命名,但如果发生这种情况,描述可以在那里使用一些返工。
如果它的作用听起来像这个方法应该分成 2 个较小的方法 tharmt 做一件事而不是重命名
Control::pending_resize
没用过。
Object::is_class(name)
→ Object::inherits_class(name)
。
我现在明白这个方法基本上等同于 GDScript is
(顺便说一句是extends
),但是 C++ 需要更明确的表达。
我遇到的困惑是检查特定对象是否属于现有类型(没有继承):
// Use case: we're only interested in editing "Node2D" classes directly.
node = Object::cast_to<Node2D>(p_edited);
if (!node) {
return;
}
if (node->get_class() != "Node2D") {
return; // OK, any class other than "Node2D" is not edited.
}
// vs.
if (!node->is_class("Node2D")) {
return; // ERROR: derived classes like "Sprite" will also be edited...
}
底层实现到处使用“继承”宏/模板,因此我将其重命名为inherits_class
对我来说很有意义。
另见https://github.com/godotengine/godot/issues/21461#issuecomment -416155187:
get_class()
和is_class()
通常让我感到困惑
最有用的评论
对我来说太乏味了,但是对于将
instance
修复为instantiate
用作动词的人来说,上帝保佑。