浏览代码

Enable singletons to be recognized as constant expressions

Fix #14681
George Marques 7 年之前
父节点
当前提交
38284bc6da
共有 1 个文件被更改,包括 8 次插入0 次删除
  1. 8 0
      modules/gdscript/gdscript_parser.cpp

+ 8 - 0
modules/gdscript/gdscript_parser.cpp

@@ -716,6 +716,14 @@ GDScriptParser::Node *GDScriptParser::_parse_expression(Node *p_parent, bool p_s
 					expr = constant;
 					bfn = true;
 				}
+
+				if (!bfn && GDScriptLanguage::get_singleton()->get_named_globals_map().has(identifier)) {
+					//check from singletons
+					ConstantNode *constant = alloc_node<ConstantNode>();
+					constant->value = GDScriptLanguage::get_singleton()->get_named_globals_map()[identifier];
+					expr = constant;
+					bfn = true;
+				}
 			}
 
 			if (!bfn) {