Godot Version
4.4.1
Question
animation_name property not showing on inspector panel. why ?
@tool
class_name AnimationSplashScreen
extends BaseSplashScreen
@export var animation_player: AnimationPlayer:
set(new_value):
animation_player = new_value
if animation_player:
# Reset animation_name if invalid
var anims = animation_player.get_animation_list()
if animation_name != "" and not animation_name in anims:
animation_name = anims[0] if anims.size() > 0 else ""
notify_property_list_changed()
@export var auto_finish_on_complete: bool = true
var animation_name: String = ""
func _ready() -> void:
super._ready()
if animation_player:
animation_player.animation_finished.connect(_on_animation_finished)
else:
push_error("AnimationSplashScreen: No AnimationPlayer assigned!")
func start_content() -> void:
if not animation_player:
push_error("AnimationSplashScreen: No AnimationPlayer assigned!")
finish()
return
if animation_name == "":
push_error("AnimationSplashScreen: No animation selected!")
finish()
return
if not animation_player.has_animation(animation_name):
push_error("AnimationSplashScreen: Animation '%s' not found!" % animation_name)
finish()
return
animation_player.play(animation_name)
func stop_content() -> void:
if animation_player and animation_player.is_playing():
animation_player.stop()
func _on_animation_finished(anim_name: String) -> void:
if anim_name == animation_name and auto_finish_on_complete:
finish()
# --- Dynamic Export for animation_name ---
func _get_property_list() -> Array:
var props: Array = []
var anim_prop := {
"name": "animation_name",
"type": TYPE_STRING,
"usage": PROPERTY_USAGE_DEFAULT
}
# Fill with AnimationPlayer list
if animation_player:
var anims: PackedStringArray = animation_player.get_animation_list()
if anims.size() > 0:
anim_prop["hint"] = PROPERTY_HINT_ENUM
anim_prop["hint_string"] = ",".join(anims)
if animation_name == "" or not animation_name in anims:
animation_name = anims[0]
else:
anim_prop["hint"] = PROPERTY_HINT_NONE
anim_prop["hint_string"] = ""
props.append(anim_prop)
return props
func _get(property: StringName):
if property == "animation_name":
return animation_name
return null
func _set(property: StringName, value) -> bool:
if property == "animation_name":
animation_name = value
return true
return false
1 Like
Would be great if you properly format your code
1 Like
ok so , what do you think Iām doing wrong here ?
use ``` in the start of your code and finish with it ,it creates a formatted code box like
print("howdy")
it makes easy to read.
ohh that was maybe a bug.
do you mean this one?
var animation_name: String = ""
You gotta use
@export var animation_name: String = ""
yeah but i want to be dynamic
if animation_player:
var anims: PackedStringArray = animation_player.get_animation_list()
if anims.size() > 0:
anim_prop["hint"] = PROPERTY_HINT_ENUM
anim_prop["hint_string"] = ",".join(anims)
what ever you want does it work?
soo you want the animation_name to be seen in your inspector panel?
simple suggestion for properties (better developer experience)
this is my old code, it works here, but not in recent one . why ?
@tool class_name N_SplashScreen extends Control
@export var NextPanel : N_SplashScreen
@export_group("Animation Times")
@export var FadeInTime :float = 1.0 # in second
@export var FadeOutTime :float = 1.0 # in second
@export_group("Animation Type")
@export_enum("Simple Timer","Animation Player") var Type = 0:
set(value):
Type = value
notify_property_list_changed()
var Animation_Time: float = 1.0 # in second
var Animation_Node: AnimationPlayer = null
var AnimationName:String = "intro"
signal load_next_scene()
@onready var _tween :Tween
var isShown = false
func _input(_event):
if(isShown and AL_DeviceHandler.any_button_pressed(_event)):
_finished()
func _init():
set_anchors_preset(PRESET_FULL_RECT)
modulate.a = 0
hide()
pass
func _ready():
match Type:
1: #For Animation Player
pass
if Animation_Node:Animation_Node.animation_finished.connect(IntroDone)
# play animation for current Panel
func PlayIntro():
show()
isShown = true
_tween = self.create_tween()
_tween.finished.connect(_start_intervel)
_tween.tween_property(self,"modulate:a",1,FadeInTime)
func _start_intervel():
_tween.kill()
match Type:
0: #For simple timer
_tween = self.create_tween()
_tween.finished.connect(_finished)
_tween.tween_interval(Animation_Time)
1: #For Animation Player
Animation_Node.play(AnimationName)
func _finished() -> void:
match Type:
0:_tween.kill()
isShown = false
var OutTWEEN = self.create_tween()
await OutTWEEN.tween_property(self,"modulate:a",0,FadeOutTime).finished
_exit()
func _exit():
hide()
if NextPanel:
NextPanel.PlayIntro()
else:
load_next_scene.emit()
return
#code for play next panel
func IntroDone( AName):
if(AName != AnimationName):return
_finished()
var list_of_animation=""
func _get_property_list():
var Properties = []
match Type:
0: #For Simple Timer
Properties.append({
"name":"Time",
"type":TYPE_INT,
})
1: #For Animation Player
Properties.append({
"name": "animtionNode",
"class_name": &"AnimationPlayer",
"type": TYPE_OBJECT,
"hint": PROPERTY_HINT_NODE_TYPE,
"hint_string": "AnimationPlayer",
"usage": 4102})
Properties.append({
"name": "AnimationName",
"class_name": &"",
"type": TYPE_STRING,
"hint": PROPERTY_HINT_ENUM,
"hint_string": list_of_animation,
"usage": 4102 })
return Properties
func _get(property):
match property:
"Time":
return Animation_Time
"animtionNode":
return Animation_Node
"AnimationName":
return AnimationName
_:return null
func _set(property, value):
match property:
"Type":
if Animation_Node:
list_of_animation = deriveEnumForPlayer(Animation_Node)
notify_property_list_changed()
return false
"Time":
Animation_Time = value
return true
"animtionNode":
list_of_animation = deriveEnumForPlayer(value)
Animation_Node = value
notify_property_list_changed()
return true
"AnimationName":
AnimationName=value
if Animation_Node:
list_of_animation = deriveEnumForPlayer(Animation_Node)
notify_property_list_changed()
_: return false
func deriveEnumForPlayer(Player:AnimationPlayer):
var Lib = Player.get_animation_library("")
if Lib:
return array_to_string(Lib.get_animation_list())
else: return ""
func array_to_string(array:Array):
var result = ""
for element in array:
result +=element
result +=","
return result
I am not familiar with godot 4 : /
Maybe someone else could help you
well after this neither do i 
1 Like
2 hour and finally , it works now Frozen_Fried
@tool
class_name AnimationSplashScreen
extends BaseSplashScreen
@export var animation_player: AnimationPlayer:
set(new_value):
animation_player = new_value
if animation_player:
# Reset animation_name if invalid
var Lib = animation_player.get_animation_library("")
if Lib:
var anims = Lib.get_animation_list()
if animation_name == "" and not animation_name in anims:
animation_name = anims[0] if anims.size() > 0 else ""
notify_property_list_changed()
@export var auto_finish_on_complete: bool = true
@export var animation_name: String = ""
func _ready() -> void:
#super._ready()
if animation_player:
animation_player.animation_finished.connect(_on_animation_finished)
else:
push_error("AnimationSplashScreen: No AnimationPlayer assigned!")
func start_content() -> void:
if not animation_player:
push_error("AnimationSplashScreen: No AnimationPlayer assigned!")
#finish()
return
if animation_name == "":
push_error("AnimationSplashScreen: No animation selected!")
#finish()
return
#
if not animation_player.has_animation(animation_name):
push_error("AnimationSplashScreen: Animation '%s' not found!" % animation_name)
#finish()
return
animation_player.play(animation_name)
func stop_content() -> void:
if animation_player and animation_player.is_playing():
animation_player.stop()
func _on_animation_finished(anim_name: String) -> void:
if anim_name == animation_name and auto_finish_on_complete:
pass
#finish()
# --- Dynamic Export for animation_name ---
func _validate_property(property: Dictionary):
if property.name == "animation_name" :
var list_of_animation=""
if animation_player:
list_of_animation = deriveEnumForPlayer(animation_player)
property.hint = PROPERTY_HINT_ENUM_SUGGESTION
property.hint_string = list_of_animation
func deriveEnumForPlayer(Player:AnimationPlayer):
var Lib = Player.get_animation_library("")
if Lib:
return ",".join(Lib.get_animation_list())
else: return ""
1 Like
system
Closed
16
This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.