Search Unity

Porting - compiler directives supported?

Discussion in 'PSM' started by Reizla, Oct 17, 2014.

  1. Reizla

    Reizla

    Joined:
    Nov 5, 2013
    Posts:
    136
    I have just downloaded Unity PSM and have given it a 1st run. It automatically loaded the current Unity project (uses Android, Web and Editor compiler directives), and for the Web directive I had quite some errors.

    Now I'm wondering if Unity PSM supports all the regular Unity compiler directives (#if UNITY_ANDROID to name one) and if I it also has it's own compiler directives, what those are and if they are compatilbe with the normal Unity engine.
     
  2. eriQue

    eriQue

    Unity Technologies

    Joined:
    May 25, 2010
    Posts:
    595
    Do not use the special Unity PSM editor for anything but targeting PSM - it does not support any other platform.

    UNITY_PSM is set when targeting PSM (if that's what you are asking?).
     
  3. jesusluvsyooh

    jesusluvsyooh

    Joined:
    Jan 10, 2012
    Posts:
    377
    Yep sounds like you need to switch the build platform settings to PSM, keep PSM unity and normal Unity separate :)
     
  4. Reizla

    Reizla

    Joined:
    Nov 5, 2013
    Posts:
    136
    Thanks both of you. Sad I have to keep PSM separate from the other editor. Means I have to build my games for Android/Win first and then actually make the port for PSM and make sure that I edit out all Android/PSM specific things. Looks like I need to use some management in coding to optimize the port ability somehow...
     
  5. jesusluvsyooh

    jesusluvsyooh

    Joined:
    Jan 10, 2012
    Posts:
    377
    As eriQue said above, use the hashtags unity_ to separate code bits, no need to rip things out, if your continuing using Unity and multiple platforms you'l need to use the #UNITY_ a lot, get them in place for your current project now and remember to add them whilst your making new ones so theres less hassle when switching platform builds :)
    Ported 4 of my iOS/Android games to PSM recently, also had to add the #UNITY_PSM /ANDROID/IPHONE to a lot of things, i've learnt for my next game to add them straight in, and if I've missed any the console will let me know when platforms are switched. Good luck!

    #ifUNITY_ANDROID
    //show android stuff
    #endif

    #ifUNITY_PSM
    //PSM specific stuff
    #endif
     
  6. Reizla

    Reizla

    Joined:
    Nov 5, 2013
    Posts:
    136
    Ah good. Then I must have misunderstood eriQue with the remark to keep Unity and Unity PSM seperate. Glad I can just use the regular Unity, use a lot of #if's there and compile (and test) the VIta with only the PSM client.
     
  7. jesusluvsyooh

    jesusluvsyooh

    Joined:
    Jan 10, 2012
    Posts:
    377
    Well continue to make your android game in normal Unity, and when the time comes for PSM, just open the project up in Unity PSM (make sure you then switch it to PSM build in settings in Unity PSM as opening current projects puts it to web player instead of PSM).
    So basically you have two Unitys installed, Normal Unity, Unity PSM, but for PSM you have to open your project in Unity PSM, not normal Unity.
    Hope this helps explain it a little more, reading everything back it seems easy to get mixed up haha
     
  8. eriQue

    eriQue

    Unity Technologies

    Joined:
    May 25, 2010
    Posts:
    595
    PSM currently uses it's own version of the editor. This editor cannot be used to target any other platform but PSM.
    Your project can of course be loaded in the regular Unity 4.3 editor, where you can export Android content.

    But you cannot (currently) export both Android and PSM content from within the same editor.
    You will have to have the regular Unity editor installed side-by-side with the Unity PSM editor, and load your project in the correct editor depending on what platform you want to export to.