How to auto update the resource_name while update other properties in inspector

Godot Version

4.2.2

Question

how to auto update the resource_name while update other properties in inspector

extends Resource

class_name Impact

@export var impactItem:Reason.ReasonItem

@export var value:float = 0.0

help

solved.(not auto, button trigger)
add a inpestor plugin.

modify Impact to

@tool
extends Resource

class_name Impact

@export var impactItem:Reason.ReasonItem

@export var value:float = 0.0


func _add_inspector_buttons() -> Array:
	var buttons = []
	buttons.push_back({
		"name": "update Resource_name button",
		"icon": preload("res://icon.svg"),
		"pressed": _on_test_button_pressed
	})
	buttons.push_back({
		"name": "Another button",
		"pressed": _on_another_button_pressed
	})
	buttons.push_back({
		"name": "Other button with lambda",
		"pressed": func(): print('Lambda callback')
	})
	return buttons


func _on_test_button_pressed(edited:Object) -> void:
	if edited is Impact:
		var temp:Impact = edited
		#print('Test pressed on object: %s' % str(temp.position))
		temp.resource_name = Reason.ReasonItem.keys()[temp.impactItem]+str(temp.value)


func _on_another_button_pressed(edited:Object) -> void:
	print('Another button pressed')

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.