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

Unity doesn't support the syntax => ?

Discussion in 'Windows' started by TongMing, Nov 4, 2014.

  1. TongMing

    TongMing

    Joined:
    Oct 21, 2014
    Posts:
    31
    I am doing porting, and write some code like below:

    #if UNITY_WP_8_1
    Task task = Task.Factory.StartNew(async () =>
    ...
    ...
    #endif

    After I clicked the "Build" button in Unity, it reported error "unexpected symbol =>", I really don't want to write extra function for the callback, cause it will makes things complicated.
    Any workaround?

    And, the code should be compiled by MS compiler, why does Unity check the syntax?
     
  2. Aurimas-Cernius

    Aurimas-Cernius

    Unity Technologies

    Joined:
    Jul 31, 2013
    Posts:
    3,627
    The code is being build for both Editor and player. Editor is always using mono.
    For this reason UNITY_WP_8_1 is not sufficient to exclude code, that compiles only using MS compiler, it should be used to exclude platform specific code only.
    To exclude code compiled using MS compiler, use NETFX_CORE define.
     
  3. TongMing

    TongMing

    Joined:
    Oct 21, 2014
    Posts:
    31
    So if I want to distinguish the WP8.1 from WP8/WP8.1/Win8/Win8.1, I need to write like this:
    #if UNITY_WP_8_1 && NETFX_CORE

    Am I correct?
     
  4. Aurimas-Cernius

    Aurimas-Cernius

    Unity Technologies

    Joined:
    Jul 31, 2013
    Posts:
    3,627
    Those and the editor too, then yes.