c# - Unity 5.3 non-generic type error with WeakReference -


i'm using unity 5.3.5f1 visual studio community 2015 , keep getting error: "the non-generic type `system.weakreference' cannot used type arguments" when try use weakreference generics. know supported here.

snippet of code:

using system; using system.diagnostics; using system.collections.generic; using system.collections;  namespace aim4.util {  /** initial id */     private int initid;     /** next id */     private int nextid;     /** mapping ids weak references of objects */     private sorteddictionary<int, weakreference<t>> idtoobj =       new sorteddictionary<int, weakreference<t>>(); 

i have feeling related unity because if load script in vs outside of project doesn't complain. appreciated. thanks.

[converting comment answer] rule of thumbs: if works in vs latest .net fw not in unity (mono, .net v2.0) it's either bug or implementation detail. need workaround either way.

of question in comment. porting unity java project challenge. better prepare bump issues of kind. in case either have workaround again, or refactor.
that, wouldn't recommend "hacking things" engine (like mention, mono source code weakreference).
might work if , when it's not, can't neither unity nor here you've built own , unique framework. long story short (imho) it'll backfire sooner or later.
unity game engine, mono/.net behind scripting, not full scale oo programming. reason is, in game engines items create self-contained, living in own little bubble, not robust applications serving single purpose.
can make class hierarchies, abstractions, nest , seal etc "on level" there serious (and logical) limitations on kind of 'implementation detail' not important game engine.

so, again, if bump problem workaround (i.e. rid of weakreference , find out why important "early gc" particular object) or refactor (think through work in game engine purpose coded in java).

hope helps!
cheers!


Comments

Popular posts from this blog

java - Static nested class instance -

c# - Bluetooth LE CanUpdate Characteristic property -

JavaScript - Replace variable from string in all occurrences -