Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. Dismiss Notice

trying to get around missing reference types

Discussion in 'Windows' started by laggyluk, Jan 23, 2016.

  1. laggyluk

    laggyluk

    Joined:
    Oct 7, 2011
    Posts:
    32
    In my app I have a file browser and on windows phone platform many used methods are missing.

    In the generated VS solution NETFX_CORE is not defined. Windows.Storage namespace? nope, doesn't exist.
    Compile errors pop up only in unity console and not in english but in my localized language which also doesn't help. Build settings: phone 8.1 sdk, Unity C# projects, development build.
    Tried setting up compilation override to 'none' and it seems to compile without errors but file browser doesn't work and I get errors post-launch.
    Using VS 2015 but I had 2013 previously and same problems.

    Any advice?
     
    Last edited: Jan 23, 2016
  2. Aurimas-Cernius

    Aurimas-Cernius

    Unity Technologies

    Joined:
    Jul 31, 2013
    Posts:
    3,624
    You have to set compilation overrides to .NET Core for NETFX_CORE to be defined, only then platform specific things will become available.
    Can you show a sample of code you have problems with?
     
  3. laggyluk

    laggyluk

    Joined:
    Oct 7, 2011
    Posts:
    32
    I did set that override. Thought that NETFX_CORE should be defined when I switch platform to wp8.1 but it appears it's only active when I hit 'build' in Unity. So no assist in visual studio whatsoever. I've made separate wp project in visual studio so I could at least see what WinRTLegacy library has to offer and that way I've managed to fix compile time errors.

    Still things go wrong when I launch the app on the phone from VS and for some reason there's no on-device debugging? All info I get is console output.
     
    Last edited: Jan 24, 2016
  4. Tautvydas-Zilys

    Tautvydas-Zilys

    Unity Technologies

    Joined:
    Jul 25, 2013
    Posts:
    10,478
    Debugging should work just fine - what exactly isn't working?
     
  5. laggyluk

    laggyluk

    Joined:
    Oct 7, 2011
    Posts:
    32
    Well it looks like in VS project there are only compiled files for the player + some wrapping code in App.xaml.cs & MainPage.xaml.cs. No source to set break points in, also won't break on exceptions so it's not much of help.
     
  6. Tautvydas-Zilys

    Tautvydas-Zilys

    Unity Technologies

    Joined:
    Jul 25, 2013
    Posts:
    10,478
    You can open your scripts in that visual studio instance where the project is open (don't add them to the project itself). Breakpoints should work just fine, even though the files are not part of the solution.

    To break on exceptions, in Visual Studio go to Debug -> Exceptions or Debug -> Windows -> Exception Settings (depends on your VS version), and enable "Common Language Runtime Exceptions".
     
  7. laggyluk

    laggyluk

    Joined:
    Oct 7, 2011
    Posts:
    32
    I can work with that, thanks!
     
  8. TGKG

    TGKG

    Joined:
    Dec 31, 2014
    Posts:
    180
    Well, I have the same problem, that I cannot see my scripts inside VS2015. I have "Common Language Runtime Exceptions" enabled and yet I do not see anywhere that I can access my scripts? Please explain further how I access my scripts in VS2015 if I have built in Unity with the Unity C# project unchecked.
     
  9. laggyluk

    laggyluk

    Joined:
    Oct 7, 2011
    Posts:
    32
    What Tautvydas Zilys wrote worked for me, to debug & set breakpoints open the project builded for wp8 in VS. There are no scripts in solution but now you can drag&drop C# scripts from unity folder onto VS and debugging works with that.
     
  10. TGKG

    TGKG

    Joined:
    Dec 31, 2014
    Posts:
    180
    Hmmm, I am confused (that seems to be the norm these days).
    It says to NOT add them to the project itself !!
    Which is correct??
     
  11. Aurimas-Cernius

    Aurimas-Cernius

    Unity Technologies

    Joined:
    Jul 31, 2013
    Posts:
    3,624
    Just drag and drop script files to VS for debugging.
    However, this VS solution has a project for main application, which has it's own source files. Don't make scripts part of this project (drag&drop does not do that, so your safe).
     
  12. laggyluk

    laggyluk

    Joined:
    Oct 7, 2011
    Posts:
    32
    yeah you just need to open files, don't "add" them through solution explorer
     
  13. TGKG

    TGKG

    Joined:
    Dec 31, 2014
    Posts:
    180
    Okay what do I do to open the script files. I don't see them anywhere?
     
  14. laggyluk

    laggyluk

    Joined:
    Oct 7, 2011
    Posts:
    32
    right click on a script in unity > 'show in explorer
     
  15. TGKG

    TGKG

    Joined:
    Dec 31, 2014
    Posts:
    180
    I am trying to see my scripts in Visual Studio2015
     
  16. Aurimas-Cernius

    Aurimas-Cernius

    Unity Technologies

    Joined:
    Jul 31, 2013
    Posts:
    3,624
    Select "Unity C# project" checkbox in Unity Build Settings window and build to an empty directory. You'll get a VS solution with multiple projects, two of them containing you C# scripts.
    Note, that there are limitations to modifying the scripts in there. You can do that, but in case of some mystical errors, do a new build from Unity.
     
  17. TGKG

    TGKG

    Joined:
    Dec 31, 2014
    Posts:
    180
    If I select "Unity C# project" checkbox, yes I can see my scripts within VS2015. However then I am unable to "Project / Store / Create App Package". Is that correct?
     
  18. TGKG

    TGKG

    Joined:
    Dec 31, 2014
    Posts:
    180
    okay, I have selected Unity C# project (checked) and have done a new build in Unity. When I open in VS2015 I have 3 projects in the Solution Explorer (Assembly-CSharp, Assembly-CSharp-firstpass, and my game). When I try to debug ( 2 succeed and 1 fails). Thus I cannot debug. The errors are:

    3>: XamlCompiler error WMC1006: Cannot resolve Assembly or Windows Metadata file 'System.Runtime.dll'
    3>C:\Program Files (x86)\MSBuild\Microsoft\WindowsXaml\v14.\8.2\Microsoft.Windows.UI.Xaml.Common.targets(263,5): Xaml Internal Error error WMC9999: Type universe cannot resolve assembly: System.Runtime, Version=4.0.0.0, Culture=neutral,

    As far as I can tell "System.Runtime.dll" cannot be found?

    How do I debug my game in VS2015?
     
  19. Tomas1856

    Tomas1856

    Unity Technologies

    Joined:
    Sep 21, 2012
    Posts:
    3,647
    Usually that means that you have NuGet disabled in VS 2015, but without the full Build window output, I am only guessing.

    Additionally see if you can create Universal app directly from VS 2015.
     

    Attached Files:

  20. TGKG

    TGKG

    Joined:
    Dec 31, 2014
    Posts:
    180
    Ok,
    NuGet set. Debug run and this is the error I get
    upload_2016-2-3_3-24-22.png

    upload_2016-2-3_3-36-3.png

    upload_2016-2-3_3-34-14.png
    System.TypeInitializationException occurred
    HResult=-2146233036
    Message=The type initializer for 'WinRTBridge.WinRTBridge' threw an exception.
    Source=WinRTBridge
    TypeName=WinRTBridge.WinRTBridge
    StackTrace:
    at WinRTBridge.WinRTBridge.get_ExceptionHandling()
    at UnityPlayer.AppCallbacks.SetBridge(IBridge bridge)
    at Block_Ball.MainPage..ctor()
    InnerException:
    HResult=-2146233036
    Message=The type initializer for 'WinRTBridge.TypeInformation' threw an exception.
    Source=WinRTBridge
    TypeName=WinRTBridge.TypeInformation
    StackTrace:
    at WinRTBridge.TypeInformation..ctor()
    at WinRTBridge.WinRTBridge..cctor()
    InnerException:
    HResult=-2147024885
    Message=Duplicate type with name 'UnityEngine.Internal.$FieldNamesStorage' in assembly 'Assembly-CSharp, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null'.
    Source=UnityEngine
    StackTrace:
    at UnityEngineInternal.BootstrapHelpers.FillTypeMaps(Dictionary`2& typeToTypeIdMap, List`1& typeIdToTypeMap)
    at WinRTBridge.TypeInformation..cctor()
    InnerException:
     
  21. TGKG

    TGKG

    Joined:
    Dec 31, 2014
    Posts:
    180
    When I run Start without debugging I get this error
    upload_2016-2-3_3-40-34.png
     
  22. Tautvydas-Zilys

    Tautvydas-Zilys

    Unity Technologies

    Joined:
    Jul 25, 2013
    Posts:
    10,478
    There's no error. It succeeded.
     
  23. TGKG

    TGKG

    Joined:
    Dec 31, 2014
    Posts:
    180
    Why can I not debug? and if it worked why did my game not start?
     
  24. TGKG

    TGKG

    Joined:
    Dec 31, 2014
    Posts:
    180
    Well, I have unchecked "Development build" from my Unity build. Built again and Can debug in VS2015. I can build successfully.
    However when I try to "Create App Package" it fails. Oh so close!! Here is the entire error message:

    1>------ Build started: Project: Assembly-CSharp, Configuration: Master x86 ------
    2>------ Build started: Project: Assembly-CSharp-firstpass, Configuration: Master x86 ------
    2>C:\Users\Tom\Documents\Unity Projects\BlockBall Folder\BrickBreakerRev10WinStore\Assets\Standard Assets\ParticleSystems\Scripts\Explosive.cs(17,17,17,31): warning CS0436: The type 'ObjectResetter' in 'C:\Users\Tom\Documents\Unity Projects\BlockBall Folder\BrickBreakerRev10WinStore\UWP\Assembly-CSharp-firstpass\..\..\Assets\Standard Assets\Utility\ObjectResetter.cs' conflicts with the imported type 'ObjectResetter' in 'Assembly-CSharp-firstpass, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null'. Using the type defined in 'C:\Users\Tom\Documents\Unity Projects\BlockBall Folder\BrickBreakerRev10WinStore\UWP\Assembly-CSharp-firstpass\..\..\Assets\Standard Assets\Utility\ObjectResetter.cs'.
    2>C:\Users\Tom\Documents\Unity Projects\BlockBall Folder\BrickBreakerRev10WinStore\Assets\Standard Assets\Utility\ParticleSystemDestroyer.cs(44,17,44,38): warning CS0618: 'ParticleSystem.enableEmission' is obsolete: 'enableEmission property is deprecated. Use emission.enable instead.'
    2>C:\Users\Tom\Documents\Unity Projects\BlockBall Folder\BrickBreakerRev10WinStore\Assets\Standard Assets\ParticleSystems\Scripts\WaterHoseParticles.cs(41,27,41,56): warning CS0618: 'ParticleCollisionEvent.collider' is obsolete: 'collider property is deprecated. Use colliderComponent instead, which supports Collider and Collider2D components.'
    2>C:\Users\Tom\Documents\Unity Projects\BlockBall Folder\BrickBreakerRev10WinStore\Assets\Standard Assets\ParticleSystems\Scripts\Hose.cs(31,17,31,38): warning CS0618: 'ParticleSystem.enableEmission' is obsolete: 'enableEmission property is deprecated. Use emission.enable instead.'
    2>C:\Users\Tom\Documents\Unity Projects\BlockBall Folder\BrickBreakerRev10WinStore\Assets\Standard Assets\ParticleSystems\Scripts\Explosive.cs(23,45,23,59): warning CS0436: The type 'ObjectResetter' in 'C:\Users\Tom\Documents\Unity Projects\BlockBall Folder\BrickBreakerRev10WinStore\UWP\Assembly-CSharp-firstpass\..\..\Assets\Standard Assets\Utility\ObjectResetter.cs' conflicts with the imported type 'ObjectResetter' in 'Assembly-CSharp-firstpass, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null'. Using the type defined in 'C:\Users\Tom\Documents\Unity Projects\BlockBall Folder\BrickBreakerRev10WinStore\UWP\Assembly-CSharp-firstpass\..\..\Assets\Standard Assets\Utility\ObjectResetter.cs'.
    2>C:\Users\Tom\Documents\Unity Projects\BlockBall Folder\BrickBreakerRev10WinStore\Assets\Standard Assets\ParticleSystems\Scripts\ExtinguishableParticleSystem.cs(24,17,24,38): warning CS0618: 'ParticleSystem.enableEmission' is obsolete: 'enableEmission property is deprecated. Use emission.enable instead.'
    2>C:\Users\Tom\Documents\Unity Projects\BlockBall Folder\BrickBreakerRev10WinStore\Assets\Standard Assets\ParticleSystems\Scripts\ExplosionFireAndDebris.cs(18,45,18,69): warning CS0436: The type 'ParticleSystemMultiplier' in 'C:\Users\Tom\Documents\Unity Projects\BlockBall Folder\BrickBreakerRev10WinStore\UWP\Assembly-CSharp-firstpass\..\..\Assets\Standard Assets\ParticleSystems\Scripts\ParticleSystemMultiplier.cs' conflicts with the imported type 'ParticleSystemMultiplier' in 'Assembly-CSharp-firstpass, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null'. Using the type defined in 'C:\Users\Tom\Documents\Unity Projects\BlockBall Folder\BrickBreakerRev10WinStore\UWP\Assembly-CSharp-firstpass\..\..\Assets\Standard Assets\ParticleSystems\Scripts\ParticleSystemMultiplier.cs'.
    2>C:\Users\Tom\Documents\Unity Projects\BlockBall Folder\BrickBreakerRev10WinStore\Assets\Standard Assets\Vehicles\Aircraft\Scripts\AeroplaneController.cs(43,22,43,38): warning CS0169: The field 'AeroplaneController.m_WheelColliders' is never used
    2> Running SerializationWeaver...
    2> Symbols will be read from C:\Users\Tom\Documents\Unity Projects\BlockBall Folder\BrickBreakerRev10WinStore\WinBuildUni10_5.3.2p1_Feb2R3_C#\Block Ball\Unprocessed\UnityEngine.pdb
    2> Weaving assembly C:\Users\Tom\Documents\Unity Projects\BlockBall Folder\BrickBreakerRev10WinStore\UWP\Assembly-CSharp-firstpass\obj\x86\Master\x86\Master\Assembly-CSharp-firstpass.dll
    2> Symbols will be read from C:\Users\Tom\Documents\Unity Projects\BlockBall Folder\BrickBreakerRev10WinStore\UWP\Assembly-CSharp-firstpass\obj\x86\Master\x86\Master\Assembly-CSharp-firstpass.pdb
    2> + UnityStandardAssets.Vehicles.Aeroplane.AeroplaneController
    2> + UnityStandardAssets.Utility.ObjectResetter
    2> + UnityStandardAssets.Utility.ParticleSystemDestroyer
    2> + UnityStandardAssets.Effects.AfterburnerPhysicsForce
    2> + UnityStandardAssets.Effects.ExplosionFireAndDebris
    2> + UnityStandardAssets.Effects.Explosive
    2> + UnityStandardAssets.Effects.ExtinguishableParticleSystem
    2> + UnityStandardAssets.Effects.FireLight
    2> + UnityStandardAssets.Effects.Hose
    2> + UnityStandardAssets.Effects.ParticleSystemMultiplier
    2> + UnityStandardAssets.Effects.SmokeParticles
    2> + UnityStandardAssets.Effects.WaterHoseParticles
    2> Will export symbols of pdb format
    2> SerializationWeaver done.
    2> Assembly-CSharp-firstpass -> C:\Users\Tom\Documents\Unity Projects\BlockBall Folder\BrickBreakerRev10WinStore\UWP\Assembly-CSharp-firstpass\bin\x86\Master\Assembly-CSharp-firstpass.dll
    1> Assembly-CSharp -> C:\Users\Tom\Documents\Unity Projects\BlockBall Folder\BrickBreakerRev10WinStore\UWP\Assembly-CSharp\bin\x86\Master\Assembly-CSharp.dll
    3>------ Build started: Project: Block Ball, Configuration: Master x86 ------
    3> UnityInstallationDir "C:\Program Files\Unity\Editor".
    3> UnityWSAPlayerDir "C:\Program Files\Unity\Editor\Data\PlaybackEngines\MetroSupport".
    3> UnityProjectDir "C:\Users\Tom\Documents\Unity Projects\BlockBall Folder\BrickBreakerRev10WinStore".
    3> Copying unprocessed assemblies...
    3> Running AssemblyConverter...
    3> AssemblyConverter done.
    3> Block Ball -> C:\Users\Tom\Documents\Unity Projects\BlockBall Folder\BrickBreakerRev10WinStore\WinBuildUni10_5.3.2p1_Feb2R3_C#\Block Ball\bin\x86\Master\Block Ball.exe
    3> Starting .NET Native compilation
    3> Processing application code
    3>C:\Users\Tom\Documents\Unity Projects\BlockBall Folder\BrickBreakerRev10WinStore\WinBuildUni10_5.3.2p1_Feb2R3_C#\Block Ball\Resources.System.Linq.Expressions.rd.xml(35): warning : Method 'CreateLambda' within 'System.Linq.Expressions.Expression' could not be found.
    3>C:\Users\Tom\Documents\Unity Projects\BlockBall Folder\BrickBreakerRev10WinStore\WinBuildUni10_5.3.2p1_Feb2R3_C#\Block Ball\Resources.System.Linq.Expressions.rd.xml(91): warning : Method 'ParameterIsAssignable' within 'System.Linq.Expressions.Expression' could not be found.
    3> Computing application closure and generating interop code
    3> Generating serialization code
    3> Compiling interop code
    3>C:\Program Files (x86)\MSBuild\Microsoft\.NetNative\x86\ilc\IlcInternals.targets(887,5): error : Internal compiler error: Failed to parse 'CameraRotate+<WaitForTime>d__12, Assembly-CSharp, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null'
    ========== Build: 2 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========
    ========== Package: 0 succeeded, 3 failed ===========


    I see a compile error - failed to parse "CameraRotate+<WaitForTime>d_12
    I have looked at my code script for my CameraRotate script and fail to see anything wrong. The cameraRotate script rotates the camera by 180 degrees once only when the bool "oneShotRotate = false". Perhaps another set of eyes will see something. Thank you.

    Code (CSharp):
    1. using UnityEngine;
    2. using System.Collections;
    3.  
    4. public class CameraRotate : MonoBehaviour {
    5.  
    6.     public bool pointAtA = false;
    7.     public float speed = 6f;
    8.  
    9.     public float angleA = 0f;
    10.     public float angleB = 180f;
    11.  
    12.     Quaternion a;
    13.     Quaternion b;
    14.     Quaternion target;
    15.  
    16.     private bool oneShotRotate = false;        //used to run the coRoutine ONCE
    17.     private bool waitIsFinished = false;    //used to start the camera rotation after the wait is finished
    18.     private bool rotateIsDone = false;        //used to prevent camera rotation happening more than once
    19.  
    20.     void Awake()
    21.     {
    22.         a = Quaternion.AngleAxis (angleA, Vector3.forward);
    23.         b = Quaternion.AngleAxis (angleB, Vector3.forward);
    24.         target = a;
    25.         //print ("A = " + angleA  + ", B = " + angleB);
    26.         //print ("a = " + a  + ", b = " + b);
    27.  
    28.     }
    29.  
    30.     void Update()
    31.     {
    32.         //use "oneShotRotate" to only run this CoRoutine once
    33.         if (GameManagerR2.instance.isFlyInCompleted && oneShotRotate == false)
    34.         {          
    35.             oneShotRotate = true;
    36.             //Wait and then begin camera rotation
    37.             StartCoroutine(WaitForTime());
    38.         }
    39.  
    40.  
    41.         if (waitIsFinished == true && rotateIsDone == false)    
    42.         {
    43.             rotateIsDone = true;
    44.             target = pointAtA ? a : b;
    45.             pointAtA = !pointAtA;
    46.  
    47.             GameManagerR2.instance.cameraRotateIsFinished = true;          
    48.         }
    49.  
    50.         transform.rotation = Quaternion.Slerp (transform.rotation, target, Time.deltaTime * speed);      
    51.     }
    52.  
    53.  
    54.     //used to wait for xx seconds
    55.     IEnumerator WaitForTime()
    56.     {
    57.         yield return new WaitForSeconds(0.5f);
    58.      
    59.         waitIsFinished = true;
    60.     }
    61. }
    62.  
     
  25. Tautvydas-Zilys

    Tautvydas-Zilys

    Unity Technologies

    Joined:
    Jul 25, 2013
    Posts:
    10,478
    Uncheck "C# projects" checkbox before building from Unity when making an app package.
     
  26. Aurimas-Cernius

    Aurimas-Cernius

    Unity Technologies

    Joined:
    Jul 31, 2013
    Posts:
    3,624
    If what @Tautvydas Zilys suggested doesn't help, can you try to go to project settings in VS and disable .NET Native, then build. This won't solve your problem, but at least we'll know if that's the reason and could continue from there.
     
  27. TGKG

    TGKG

    Joined:
    Dec 31, 2014
    Posts:
    180
    Ok, have unchecked C# in Unity and I am working thru the build and create app package in VS
     
  28. TGKG

    TGKG

    Joined:
    Dec 31, 2014
    Posts:
    180
    Well done Tautvydas and Aurimas. It all worked and is uploaded to the Windows store for certification. Hopefully all goes well with this final step in the process.
    The only code that I changed along the way was a SceneManager code as follows:

    changed from
    Code (CSharp):
    1. SceneManager.GetSceneAt(0).buildIndex == 1
    to
    Code (CSharp):
    1. SceneManager.GetActiveScene().buildIndex==1
    Thanks again for all your help.
     
  29. Maisey

    Maisey

    Joined:
    Feb 17, 2014
    Posts:
    300
    I get this error also for some reason, can't locate why. But it is solved if I do one of the following:
    1. Clean the whole C# VS Solution and then rebuild it and then deploy (Local Machine in my case).
    2. If I delete a folder or file (any folder or file) in the "Assembly-CSharp"-project and deploy (Local Machine in my case). (Not sure if a rebuild will occur when doing this or why it works, but it works in my case)
     
  30. TGKG

    TGKG

    Joined:
    Dec 31, 2014
    Posts:
    180
    Very strange. I have found debugging a Unity build in VS very tricky. Sometimes a Clean Build and then Build or Rebuild will work and other times not. I have not found the correct steps that work consistently. Clever idea about deleting a folder, I will try that.
     
  31. Maisey

    Maisey

    Joined:
    Feb 17, 2014
    Posts:
    300
    Not really a clever idea! I was trying to investigate if it was some file that caused the error, but in the end it seems like whichever folder/file I removed it made it work. :S

    Did it work for you to remove a file or folder? @TGKG