Initial Commit
This commit is contained in:
21
Scripts/Helper/hCamera.gd
Normal file
21
Scripts/Helper/hCamera.gd
Normal file
@@ -0,0 +1,21 @@
|
||||
class_name hCamera
|
||||
|
||||
var name_to_id: Dictionary = {}
|
||||
var id_to_name: Dictionary = {}
|
||||
|
||||
# Explicit setup function
|
||||
func setup(cameras_dict: Dictionary) -> void:
|
||||
if cameras_dict == null:
|
||||
push_error("Cameras dictionary is null!")
|
||||
return
|
||||
|
||||
name_to_id = cameras_dict.duplicate()
|
||||
id_to_name.clear()
|
||||
for name in name_to_id.keys():
|
||||
id_to_name[int(name_to_id[name])] = name # ensure keys are ints
|
||||
|
||||
func getID(cameraName: String) -> int:
|
||||
return name_to_id.get(cameraName.to_upper(), -1)
|
||||
|
||||
func getName(cam_id: int) -> String:
|
||||
return id_to_name.get(cam_id, "UNKNOWN")
|
||||
Reference in New Issue
Block a user