variable_instance_get_names


描述

With this function you can retrieve an array populated with the instance variable names for an instance, or the global variables for a game. When you pass in an instance ID value, each entry in the array will be a string of the variable name that corresponds to an instance scope variable that has been created in the instance. However if you pass in the keyword global, each entry in the array will be a string of the variable name that corresponds to an global scope variable.

注意: 该函数基本上是用于所导入工程的 兼容性脚本(Compatibility) 及拖拽按钮(Drag and Drop)动作转换而成的代码中的。


语法:

variable_instance_get_names(instance_id/global);


参数:

参数 描述
instance_id/global The unique ID value of the instance to check or the keyword global

返回:

Array(数组)(每个条目都是一个字符串)


例如:

var str = "";
var array = variable_instance_get_names(id);
show_debug_message("Variables for " + object_get_name(object_index) + string(id));
for (var i = 0; i < array_length_1D(array); i++;)
    {
    str = array[i] + ":" + string(variable_instance_get(id, array[i]));
    show_debug_message(str);
    }

上面的代码将检索运行代码块的实例的所有实例作用域变量的数组,然后在调试输出中显示这些变量及其值。