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

Command for Windows Phone 8.1

Discussion in 'Windows' started by dudedude123, Jan 23, 2015.

  1. dudedude123

    dudedude123

    Joined:
    Aug 24, 2013
    Posts:
    128
    I was making controls for Windows 8 and I wanted to add moga controls but I want controls for Windows Phone 8.1

    Is there a header like the following for Windows Phone 8.1?
    #if UNITY_WP8
     
  2. Tomas1856

    Tomas1856

    Unity Technologies

    Joined:
    Sep 21, 2012
    Posts:
    3,658
    Try UNITY_METRO
     
  3. dudedude123

    dudedude123

    Joined:
    Aug 24, 2013
    Posts:
    128
    It doesn't work
     
  4. Tomas1856

    Tomas1856

    Unity Technologies

    Joined:
    Sep 21, 2012
    Posts:
    3,658
    Hmph, are you using the define inside script compiled by Unity? Could you copy-paste the code where you use it?
     
  5. dudedude123

    dudedude123

    Joined:
    Aug 24, 2013
    Posts:
    128
    I want this code to only work in Windows Phone 8 & 8.1




    Code (CSharp):
    1. #if UNITY_WP8
    2. // Extends Unitys inbuilt InputManager with our custom one (Moga_Input)
    3. using Input = Moga_Input;
    4. #endif
     
  6. Tomas1856

    Tomas1856

    Unity Technologies

    Joined:
    Sep 21, 2012
    Posts:
    3,658
    Windows Phone 8.1 and Windows Phone 8 are two different platforms. On other hand Windows Phone 8.1 is the same platform as Windows Store Apps.

    So in this case, you need to write
    #if UNITY_WP8 || UNITY_METRO
     
  7. dudedude123

    dudedude123

    Joined:
    Aug 24, 2013
    Posts:
    128
    It didn't work
     
  8. Tomas1856

    Tomas1856

    Unity Technologies

    Joined:
    Sep 21, 2012
    Posts:
    3,658
    What exactly didn't work, you can also see what defines are used when compiling scripts. Simply introduce an error to script, when Unity will fail to compile it, open the Editor.log, it should contain a list of defines used for compiling scripts
     
  9. Aurimas-Cernius

    Aurimas-Cernius

    Unity Technologies

    Joined:
    Jul 31, 2013
    Posts:
    3,627
    Is that plugin WSA/WP8 only, that is no Editor version?
    In that case it would be

    #if (UNITY_WP8 || UNITY_METRO) && !UNITY_EDITOR
     
  10. dudedude123

    dudedude123

    Joined:
    Aug 24, 2013
    Posts:
    128
    Would this work?


    UNITY_WP8 || UNITY_WP_8_1
     
  11. Tomas1856

    Tomas1856

    Unity Technologies

    Joined:
    Sep 21, 2012
    Posts:
    3,658
    Please provide more information, what exactly are you compiling, because you're saying it's not working, but you don't clarify the matter.
     
  12. dudedude123

    dudedude123

    Joined:
    Aug 24, 2013
    Posts:
    128
    Code (CSharp):
    1. using System.Collections;
    2. using System.Collections.Generic;
    3.  
    4. #if UNITY_WP8 || UNITY_WP_8_1
    5. // Extends Unitys inbuilt InputManager with our custom one (Moga_Input)
    6. using Input = Moga_Input;
    7. #endif
    8.  
    9.  
    10. public class Fight : MonoBehaviour {
    11.  
    12.  
    13.  
    14.     #if UNITY_WP8 || UNITY_WP_8_1
    15.     private KeyCode                        aButtonKeyCode,
    16.     bButtonKeyCode,
    17.     xButtonKeyCode,
    18.     yButtonKeyCode;
    19.     private GameObject                     mogaManagerObject;
    20.     private Moga_ControllerManager         mogaManagerScript;
    21.     bool mogaFound = false;
    22. #endif
    23.  
    24.  
    25.  
    26.  
    27.     public CNAbstractController MovementJoystick;
    28.  
    29.     public CNAbstractController PunchJoystick;
    30.  
    31.     public float RotationSpeed = 10f;
    32.    
    33.     private Transform _transformCache;
    34.     private Transform _parentTransformCache;
    35.     public bool ApplyGravity = true;
    36.     public float Health = 1000;
    37.     public AudioClip hit;
    38.     public AudioClip swing;
    39.     public AudioClip faint;
    40.     GUIText HealthCounter;
    41.     float Distance;
    42.     float MaxDistance = 1.5f;
    43.     public bool YouWon;
    44.     internal Animator animator; //stores the animator component
    45.     float v; //vertical movements
    46.     float h; //horizontal movements
    47.     float straight;
    48.     float hook;
    49.     float block;
    50.     float body;
    51.     float jump;
    52.     float left;
    53.     float right;
    54.     float high;
    55.     float wide;
    56.     float ko;
    57.  
    58.  
    59.  
    60.    
    61.     void  Start (){
    62.         animator = GetComponent<Animator>(); //assigns Animator component when we start the game
    63.  
    64.  
    65.  
    66.         #if UNITY_WP8 || UNITY_WP_8_1
    67.         // Try Find our Moga Manager Game Object
    68.         mogaManagerObject = GameObject.Find("MogaControllerManager");
    69.        
    70.         // If it exists..
    71.         if (mogaManagerObject != null)
    72.         {
    73.             // Check the Moga Manager Script is correctly attached to the Moga  Manager Game Object
    74.             mogaManagerScript = mogaManagerObject.GetComponent<Moga_ControllerManager>();
    75.            
    76.             // If it is attached...
    77.             if (mogaManagerScript != null)
    78.             {
    79.                 // Register MOGA Controller
    80.                 Input.RegisterMogaController();
    81.                
    82.                 // Get our mapped KeyCode Values and assign them.
    83.                 aButtonKeyCode = mogaManagerScript.p1ButtonA;
    84.                 bButtonKeyCode = mogaManagerScript.p1ButtonB;
    85.                 xButtonKeyCode = mogaManagerScript.p1ButtonX;
    86.                 yButtonKeyCode = mogaManagerScript.p1ButtonY;
    87.                
    88.                 mogaFound = true;
    89.             }
    90.         }
    91. #endif
    92.  
    93.     }
    94.    
    95.     void  Update (){
    96.  
    97.         #if UNITY_WP8 || UNITY_WP_8_1
    98.         if (mogaFound)
    99.         {
    100.             this.transform.Rotate( 0, -Input.GetAxis("Horizontal"), 0, Space.World );
    101.             this.transform.Rotate( Input.GetAxis ("Vertical"), 0, 0, Space.World );
    102.            
    103.  
    104.         }
    105. #endif
    106.  
    107.         v = Input.GetAxis("Vertical");
    108.         h = Input.GetAxis("Horizontal");
    109.         straight = Input.GetAxis("Straight");
    110.         hook = Input.GetAxis("Hook");
    111.         block = Input.GetAxis("Block");
    112.         body = Input.GetAxis("Body");
    113.         left = Input.GetAxis("Turn Left");
    114.         right = Input.GetAxis("Turn Right");
    115.         high = Input.GetAxis("Guard Height");
    116.         wide = Input.GetAxis("Guard Width");
    117.         jump = Input.GetAxis("Jump");
    118.  
    119.  
    120.  
    121.  
    122.        
    123.        
    124.        
    125.        
    126.     }
    127.    
    128.    
    129.    
    130.    
    131.     void  FixedUpdate (){
    132.        
    133.         //set the "Walk" parameter to the v axis value
    134.         animator.SetFloat ("Walk", v);
    135.         animator.SetFloat ("Turn", h);
    136.         animator.SetFloat ("Straight", straight);
    137.         animator.SetFloat ("Hook", hook);
    138.         animator.SetFloat ("Block", block);
    139.         animator.SetFloat ("Body", body);
    140.         animator.SetFloat("Turn Left", left);
    141.         animator.SetFloat("Turn Right", right);
    142.         animator.SetFloat("Guard Height", high);
    143.         animator.SetFloat("Guard Width", wide);
    144.         animator.SetFloat("Jump", jump);
    145.         animator.SetFloat("KO", ko);
    146.     }
    147.  
    148.  
    149.     void  ApplyDamage (int Damage){
    150.         Health -= Damage;
    151.  
    152.        
    153.         if(Health <= 0)
    154.         {
    155.             KO();
    156.         }
    157.     }
    158.    
    159.     void  KO (){
    160.         Debug.Log("Player KO");
    161.        
    162.         ko = 2.0f;
    163.  
    164.        
    165.         gameObject.GetComponent<PostFightMenu>().playerKO = true;
    166.     }
    167.  
    168.  
    169.  
    170. }
     
  13. Aurimas-Cernius

    Aurimas-Cernius

    Unity Technologies

    Joined:
    Jul 31, 2013
    Posts:
    3,627
    Do you get compilation errors on Unity for Moga_* stuff?
    That would be the case if they don't provide Editor plugin (or it's not setup properly).
    Try editing you code like this:
    Code (CSharp):
    1. #if !UNITY_EDITOR && (UNITY_WP8 || UNITY_WP_8_1)
    2. // Extends Unitys inbuilt InputManager with our custom one (Moga_Input)
    3. using Input = Moga_Input;
    4. #endif
    Also, based on your questions, I think you should invest some time into learning C#. Unity forums isn't quite the place to ask questions about the language.
     
  14. dudedude123

    dudedude123

    Joined:
    Aug 24, 2013
    Posts:
    128


    When I was learning c#, I wrote separate code for each platform