squash some weird editor errors with extending XRTools clases
@tool is definitely a wart in godot.
This commit is contained in:
		
							parent
							
								
									c390f6c745
								
							
						
					
					
						commit
						756ee40cd5
					
				
					 5 changed files with 23 additions and 5 deletions
				
			
		|  | @ -1,3 +1,3 @@ | |||
| [xr] | ||||
| 
 | ||||
| openxr/enabled=true | ||||
| openxr/enabled=false | ||||
|  |  | |||
|  | @ -1,3 +1,6 @@ | |||
| # annoying you have to @tool to successfully extend the XR tool classes, | ||||
| # which pollutes the the methods with editor only checks, oh well. | ||||
| @tool | ||||
| extends XRToolsSceneBase | ||||
| 
 | ||||
| 
 | ||||
|  | @ -7,7 +10,8 @@ func scene_loaded(user_data = null): | |||
| 
 | ||||
| func _ready(): | ||||
| 	# for editor testing when scene is directly loaded | ||||
| 	_reset_manipulators() | ||||
| 	if !Engine.is_editor_hint(): | ||||
| 		_reset_manipulators() | ||||
| 
 | ||||
| func _reset_manipulators(): | ||||
| 	# reset the manipulators (the loaded scene has them in the final position) | ||||
|  |  | |||
|  | @ -1,23 +1,38 @@ | |||
| # a vector field manipulator that can be picked up and radius resized by the | ||||
| # holding controller's joystick. | ||||
| # needs a VisualAttractorSphere child node to work. | ||||
| @tool | ||||
| class_name Manipulator | ||||
| extends XRToolsPickable | ||||
| 
 | ||||
| var held_controller: XRController3D = null | ||||
| 
 | ||||
| @onready var attractor: GPUParticlesAttractorSphere3D = $VisualAttractorSphere | ||||
| var attractor: GPUParticlesAttractorSphere3D  | ||||
| 
 | ||||
| const MIN_SCALE = 0.5 | ||||
| const MAX_SCALE = 10 | ||||
| const SCALE_SPEED = 1.0 | ||||
| 
 | ||||
| # Add support for is_xr_class on XRTools classes | ||||
| # I'm not sure why this is needed exactly, but you'll at least | ||||
| # get console errors wihtout it. | ||||
| func is_xr_class(name : String) -> bool: | ||||
| 	return name == "XRToolsPickable" | ||||
| 
 | ||||
| func _ready() -> void: | ||||
| 	super() | ||||
| 	picked_up.connect(_on_pickable_object_picked_up) | ||||
| 	dropped.connect(_on_pickable_object_dropped) | ||||
| 
 | ||||
| 	if Engine.is_editor_hint(): | ||||
| 		return | ||||
| 
 | ||||
| 	attractor = $VisualAttractorSphere | ||||
| 
 | ||||
| func _process(delta: float) -> void: | ||||
| 	if Engine.is_editor_hint(): | ||||
| 		return | ||||
| 
 | ||||
| 	if held_controller: | ||||
| 		var joystick_y = held_controller.get_vector2("primary").y | ||||
| 		if abs(joystick_y) > 0.1: | ||||
|  |  | |||
|  | @ -63,7 +63,6 @@ void fragment() { | |||
| 
 | ||||
| } | ||||
| " | ||||
| graph_offset = Vector2(-451.023, -134.578) | ||||
| nodes/fragment/0/position = Vector2(620, 180) | ||||
| nodes/fragment/2/node = SubResource("VisualShaderNodeInput_5b52k") | ||||
| nodes/fragment/2/position = Vector2(-940, 280) | ||||
|  |  | |||
|  | @ -151,7 +151,7 @@ top_radius = 0.3 | |||
| bottom_radius = 0.3 | ||||
| height = 5.0 | ||||
| 
 | ||||
| [node name="TitleScene" type="Node3D"] | ||||
| [node name="ValentineScene" type="Node3D"] | ||||
| script = ExtResource("1_fbwwc") | ||||
| 
 | ||||
| [node name="XROrigin3D" parent="." instance=ExtResource("2_i3vfe")] | ||||
|  |  | |||
		Loading…
	
		Reference in a new issue