r.nikonov Posted November 11, 2015 Share Posted November 11, 2015 Hello Short example: class T { string a; T(string value) { a = value; } }; class My { int _flag = 0; int _test[0]; T _test2 = new T("old"); void test() { log.message("before:\t" + string(_test.size()) + "\t" + _test2.a + "\n"); int local[] = (1); T local2 = new T("temp"); log.message("after:\t" + string(_test.size()) + "\t" + _test2.a + "\n"); local.append(10); _test = local; local2 = new T("new"); _test2 = local2; if (_flag == 0) { _flag = 1; test(); } } } Expected: before: 0 old after: 0 old before: 2 new after: 2 new Real result: before: 0 old after: 0 old before: 2 new after: 1 new Link to comment
r.nikonov Posted November 11, 2015 Author Share Posted November 11, 2015 I found almost answer in same tagged thread: https://developer.unigine.com/forum/topic/3042-solved-vectors-maps-and-recursion/ This: "That's because local variables in UnigineScript aren't actually local. They're global with local function scope." Link to comment
silent Posted November 11, 2015 Share Posted November 11, 2015 Hi Roman, Yes, this is expected result, sorry (all variables are "static" by default in UnigineScript). How to submit a good bug report --- FTP server for test scenes and user uploads: ftp://files.unigine.com user: upload password: 6xYkd6vLYWjpW6SN Link to comment
Recommended Posts