- Home /
Lies! You don't need pragma.etc for lists!
I recently downloaded a FREE asset from the asset store called Save Game-JSON+Binary. While playing around with it I discovered that if you use a list var, ie
`var Foo : List<GamObject>;`
without adding pragma and system collections that it will NOT throw an error message! Every where I search about 'list' not working without those 2 lines of codes I see no bypass solutions or anything other than YOU HAVE TO ADD PRAGMA AND SYSTEM blah blah to the script. Here with the asset it works like a charm, without me having to utterly remake/update my whole Js just to use lists instead of arrays.
The thing I am confused with is which specific components of the package are allowing/making this happen? I don't want the asset anymore, but do want this feature. Can anyone PLEASE test this out/or provide some light (code) to make this work? Also I have seen this thread
http://forum.unity3d.com/threads/178611-Unknown-identifier-List
and it revealed something about changing script templates to allow it- How do I do that if no one can explain the above asset?
Thank you for any help
pragma strict, gives you hiden errors, maybe you dont know if your script even works anymore.
Answer by superventure · Oct 12, 2013 at 08:22 AM
Found out that simply putting #pragma downcast
in instead of #pragma strict
will bypass the error message that would pop up otherwise. It does still need import System.Collections.Generic;
, but it doesn't matter as long as you can use the list functions! I was having such a pain with it because pragma strict requires you make everything else in the script generic too. Now, no problem.
Your answer
Follow this Question
Related Questions
A node in a childnode? 1 Answer
Need help with converting an array to a list in C#` 4 Answers
How to make sense of error message? 1 Answer
Searching a List of GameObjects by name 2 Answers