- Home /
System.Attribute errors when compiling for Windows Store / Phone 8.1
I use a Singleton that will load a Prefab (from Resources) if the singleton instance isn't found. Its a modified version of what can be found here: http://kleber-swf.com/singleton-monobehaviour-unity-projects/
This seems to work fine for most builds (tested on iOS and Standalone Windows builds)
However, when trying to create a Windows Phone 8.1 Visual Studio Project (or Windows Universal 8.1), Unity reports the following errors that keep it from building the project (the code that generates the error is listed above)
if (System.Attribute.IsDefined (myType, typeof(SingletonPrefabAttribute)))
{
...
}
error CS0117: 'System.Attribute' does not contain a definition for 'IsDefined'
SingletonPrefabAttribute attr = (SingletonPrefabAttribute) System.Attribute.GetCustomAttribute (myType, typeof(SingletonPrefabAttribute));
error CS0117: 'System.Attribute' does not contain a definition for 'GetCustomAttribute'
Any ideas as to what could be causing this?
Note that this only occurs when compiling when building against the $$anonymous$$icrosoft C# compiler. It works as expected when building with $$anonymous$$ono.
Same problem here. Not sure there's any option when building to HoloLens
Answer by AccentDave · Jul 30, 2016 at 04:34 PM
I got around this by surrounding the code with
if UNIYT_EDITOR
. Attribute.notgonnawork #endif