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

Windows Phone GUI strange bug

Discussion in 'Windows' started by Athomield3D, Jun 14, 2014.

  1. Athomield3D

    Athomield3D

    Joined:
    Aug 29, 2012
    Posts:
    193
    Hi, i've made a scene that is all about GUI
    there are multiple pages in this scene and controlled by boolean variables.
    It works fine on the editor but on the WP emulator it displays all the pages then goes to the first button and trigger it true to go to the next pages.



    Code (CSharp):
    1. using UnityEngine;
    2. using System.Collections;
    3.  
    4. public class MainMenu : MonoBehaviour {
    5.  
    6.     float width, height;
    7.  
    8.     public GUIStyle sett = new GUIStyle(), styl = new GUIStyle(), play1 = new GUIStyle(), logo = new GUIStyle(), logo2 = new GUIStyle(), textNor = new GUIStyle(), headTi = new GUIStyle() , blank = new GUIStyle();
    9.  
    10.     public bool mainMenu, twoPSelect, onePSelect, settings;
    11.  
    12.     int[] timeChoice = new int[5];
    13.     float[] bouncChoice = new float[4];
    14.  
    15.     int stadInd, timeLimInd, goalLimitInd, bounInd, aiInd;
    16.     float bounciness;
    17.  
    18.     string bouncStat, stadStat, aiStat;
    19.  
    20.     public PhysicsMaterial2D bounce;
    21.  
    22.     void Start()
    23.     {
    24.         width = Screen.width;
    25.         height = Screen.height;
    26.  
    27.         mainMenu = true;
    28.         settings = false;
    29.         onePSelect = false;
    30.         twoPSelect = false;
    31.  
    32.         aiInd = 1;
    33.         goalLimitInd = 3;
    34.         timeChoice = new int[5] { 0, 60, 120, 300, 600 };
    35.         bouncChoice = new float[4] { 0.4f, 0.6f, 0.8f, 1f };
    36.     }
    37.  
    38.     void Update()
    39.     {
    40.         play1.fontSize = (int)(width * 0.08f);
    41.         logo.fontSize = (int)(width * 0.15f);
    42.         logo2.fontSize = (int)(width * 0.15f);
    43.         textNor.fontSize = (int)(width * 0.0725f);
    44.  
    45.         if (bouncChoice[bounInd] == 0.4f)
    46.         {
    47.             bouncStat = "Low";
    48.         }
    49.         if (bouncChoice[bounInd] == 0.6f)
    50.         {
    51.             bouncStat = "Normal";
    52.         }
    53.         if (bouncChoice[bounInd] == 0.8f)
    54.         {
    55.             bouncStat = "High";
    56.         }
    57.         if (bouncChoice[bounInd] == 1f)
    58.         {
    59.             bouncStat = "Insane";
    60.         }
    61.  
    62.         switch(aiInd)
    63.         {
    64.             case 0 :
    65.                 aiStat = "Easy";
    66.                 break;
    67.             case 1 :
    68.                 aiStat = "Medium";
    69.                 break;
    70.             case 2 :
    71.                 aiStat = "Hard";
    72.                 break;
    73.         }
    74.     }
    75.  
    76.     void OnGUI()
    77.     {
    78.         /***********************/
    79.         /*** Main Menu ***/
    80.         if(mainMenu)
    81.         {
    82.             GUI.Box(new Rect(width - width * 0.88f, height - height * 0.97f, height * 0.3f, height * 0.3f), "Air \n Hockey", logo2);
    83.             GUI.Box(new Rect(width - width * 0.88f + 3, height - height * 0.97f + 3, height * 0.25f, height * 0.3f), "Air \n Hockey", logo);
    84.  
    85.             if (GUI.Button(new Rect(width - width * 0.8f, height - height * 0.65f, width * 0.6f, height * 0.11f), "1 Player", play1))
    86.             {
    87.                 mainMenu = false;
    88.                 onePSelect = true;
    89.             }
    90.             if (GUI.Button(new Rect(width - width * 0.8f, height - height * 0.65f + height * 0.11f + height * 0.05f, width * 0.6f, height * 0.11f), "2 Players", play1))
    91.             {
    92.                 mainMenu = false;
    93.                 twoPSelect = true;
    94.             }
    95.             if (GUI.Button(new Rect(width - width * 0.8f - width * 0.05f, height - height * 0.6f + 2 * height * 0.11f + 2 * (height * 0.05f), height * 0.175f, height * 0.175f), "", sett))
    96.             {
    97.  
    98.             }
    99.             if (GUI.Button(new Rect(width - width * 0.8f + width * 0.35f, height - height * 0.6f + 2 * height * 0.11f + 2 * (height * 0.05f), height * 0.175f, height * 0.175f), "", styl))
    100.             {
    101.  
    102.             }
    103.         }
    104.  
    105.         /***********************/
    106.         /*** 2 Players Menu ***/
    107.         if(twoPSelect)
    108.         {
    109.             GUI.Box(new Rect(width - width * 0.73f, height - height * 0.83f, height * 0.3f, height * 0.3f), "2 Players", headTi);
    110.  
    111.             //Stadium
    112.             GUI.Label(new Rect(width - width * 0.87f, height - height * 0.7f, height * 0.3f, height * 0.3f), "Statium: " + "Classic", textNor);
    113.  
    114.             if (GUI.Button(new Rect(width - width * 0.96f, height - height * 0.7f, width * 0.3f, height * 0.07f), "◄", blank))
    115.             {
    116.                 if(stadInd != 0)
    117.                 {
    118.                     stadInd--;
    119.                 }
    120.                 else
    121.                 {
    122.                     stadInd = 3;
    123.                 }
    124.             }
    125.             if (GUI.Button(new Rect(width - width * 0.9f + width * 0.3f + height * 0.3f, height - height * 0.7f, width * 0.3f, height * 0.07f), "►", blank))
    126.             {
    127.                 if(stadInd != 3)
    128.                 {
    129.                     stadInd++;
    130.                 }
    131.                 else
    132.                 {
    133.                     stadInd = 0;
    134.                 }
    135.             }
    136.  
    137.             //Time limit
    138.             GUI.Label(new Rect(width - width * 0.87f, height - height * 0.6f, height * 0.3f, height * 0.3f), "Time Limit: " + timeChoice[timeLimInd].ToString() + " sec", textNor);
    139.  
    140.             if (GUI.Button(new Rect(width - width * 0.96f, height - height * 0.6f, width * 0.3f, height * 0.07f), "◄", blank))
    141.             {
    142.                 if (timeLimInd != 0)
    143.                 {
    144.                     timeLimInd--;
    145.                 }
    146.                 else
    147.                 {
    148.                     timeLimInd = 4;
    149.                 }
    150.             }
    151.  
    152.             if (GUI.Button(new Rect(width - width * 0.9f + width * 0.3f + height * 0.3f, height - height * 0.6f, width * 0.3f, height * 0.07f), "►", blank))
    153.             {
    154.                 if (timeLimInd != 4)
    155.                 {
    156.                     timeLimInd++;
    157.                 }
    158.                 else
    159.                 {
    160.                     timeLimInd = 0;
    161.                 }
    162.             }
    163.  
    164.             //Number of goals limit
    165.             GUI.Label(new Rect(width - width * 0.87f, height - height * 0.5f, height * 0.3f, height * 0.3f), "Goal Limit: " + goalLimitInd.ToString(), textNor);
    166.  
    167.             if (GUI.Button(new Rect(width - width * 0.96f, height - height * 0.5f, width * 0.3f, height * 0.07f), "◄", blank))
    168.             {
    169.                 if (goalLimitInd != 3)
    170.                 {
    171.                     goalLimitInd--;
    172.                 }
    173.                 else
    174.                 {
    175.                     goalLimitInd = 15;
    176.                 }
    177.             }
    178.  
    179.             if (GUI.Button(new Rect(width - width * 0.9f + width * 0.3f + height * 0.3f, height - height * 0.5f, width * 0.3f, height * 0.07f), "►", blank))
    180.             {
    181.                 if (goalLimitInd != 15)
    182.                 {
    183.                     goalLimitInd++;
    184.                 }
    185.                 else
    186.                 {
    187.                     goalLimitInd = 3;
    188.                 }
    189.             }
    190.  
    191.             //Ball Bounciness
    192.             GUI.Label(new Rect(width - width * 0.87f, height - height * 0.4f, height * 0.3f, height * 0.3f), "Ball Bounciness:\n     " + bouncStat, textNor);
    193.  
    194.             if (GUI.Button(new Rect(width - width * 0.96f, height - height * 0.4f, width * 0.3f, height * 0.07f), "◄", blank))
    195.             {
    196.                 if (bounInd != 0)
    197.                 {
    198.                     bounInd--;
    199.                 }
    200.                 else
    201.                 {
    202.                     bounInd = 3;
    203.                 }
    204.             }
    205.  
    206.             if (GUI.Button(new Rect(width - width * 0.9f + width * 0.3f + height * 0.3f, height - height * 0.4f, width * 0.3f, height * 0.07f), "►", blank))
    207.             {
    208.                 if (bounInd != 3)
    209.                 {
    210.                     bounInd++;
    211.                 }
    212.                 else
    213.                 {
    214.                     bounInd = 0;
    215.                 }
    216.             }
    217.  
    218.             //Start
    219.             if (GUI.Button(new Rect(width - width * 0.8f, height - height * 0.26f, width * 0.6f, height * 0.11f), "Start", play1))
    220.             {
    221.                 GameManager.scoreLimit = goalLimitInd;
    222.                 GameManager.timeLimit = timeChoice[timeLimInd];
    223.                 GameManager.gameOver = false;
    224.                 bounce.bounciness = bouncChoice[bounInd];
    225.                 Application.LoadLevel(1);
    226.             }
    227.  
    228.             //Back
    229.             if (GUI.Button(new Rect(width - width * 0.8f, height - height * 0.13f, width * 0.6f, height * 0.11f), "Back", play1))
    230.             {
    231.                 mainMenu = true;
    232.                 twoPSelect = false;
    233.             }
    234.         }
    235.  
    236.         /***********************/
    237.         /*** 1 Player Menu ***/
    238.  
    239.         if (onePSelect)
    240.         {
    241.             GUI.Box(new Rect(width - width * 0.73f, height - height * 0.93f, height * 0.3f, height * 0.3f), "1 Player", headTi);
    242.  
    243.             //AI Select
    244.             GUI.Label(new Rect(width - width * 0.87f, height - height * 0.8f, height * 0.3f, height * 0.3f), "AI Level: " + aiStat, textNor);
    245.  
    246.             if (GUI.Button(new Rect(width - width * 0.96f, height - height * 0.8f, width * 0.3f, height * 0.07f), "◄", blank))
    247.             {
    248.                 if (aiInd != 0)
    249.                 {
    250.                     aiInd--;
    251.                 }
    252.                 else
    253.                 {
    254.                     aiInd = 2;
    255.                 }
    256.             }
    257.             if (GUI.Button(new Rect(width - width * 0.9f + width * 0.3f + height * 0.3f, height - height * 0.8f, width * 0.3f, height * 0.07f), "►", blank))
    258.             {
    259.                 if (aiInd != 2)
    260.                 {
    261.                     aiInd++;
    262.                 }
    263.                 else
    264.                 {
    265.                     aiInd = 0;
    266.                 }
    267.             }
    268.  
    269.             //Stadium
    270.             GUI.Label(new Rect(width - width * 0.87f, height - height * 0.7f, height * 0.3f, height * 0.3f), "Statium: " + "Classic", textNor);
    271.  
    272.             if (GUI.Button(new Rect(width - width * 0.96f, height - height * 0.7f, width * 0.3f, height * 0.07f), "◄", blank))
    273.             {
    274.                 if (stadInd != 0)
    275.                 {
    276.                     stadInd--;
    277.                 }
    278.                 else
    279.                 {
    280.                     stadInd = 3;
    281.                 }
    282.             }
    283.             if (GUI.Button(new Rect(width - width * 0.9f + width * 0.3f + height * 0.3f, height - height * 0.7f, width * 0.3f, height * 0.07f), "►", blank))
    284.             {
    285.                 if (stadInd != 3)
    286.                 {
    287.                     stadInd++;
    288.                 }
    289.                 else
    290.                 {
    291.                     stadInd = 3;
    292.                 }
    293.             }
    294.  
    295.             //Time limit
    296.             GUI.Label(new Rect(width - width * 0.87f, height - height * 0.6f, height * 0.3f, height * 0.3f), "Time Limit: " + timeChoice[timeLimInd].ToString() + " sec", textNor);
    297.  
    298.             if (GUI.Button(new Rect(width - width * 0.96f, height - height * 0.6f, width * 0.3f, height * 0.07f), "◄", blank))
    299.             {
    300.                 if (timeLimInd != 0)
    301.                 {
    302.                     timeLimInd--;
    303.                 }
    304.                 else
    305.                 {
    306.                     timeLimInd = 4;
    307.                 }
    308.             }
    309.  
    310.             if (GUI.Button(new Rect(width - width * 0.9f + width * 0.3f + height * 0.3f, height - height * 0.6f, width * 0.3f, height * 0.07f), "►", blank))
    311.             {
    312.                 if (timeLimInd != 4)
    313.                 {
    314.                     timeLimInd++;
    315.                 }
    316.                 else
    317.                 {
    318.                     timeLimInd = 0;
    319.                 }
    320.             }
    321.  
    322.             //Number of goals limit
    323.             GUI.Label(new Rect(width - width * 0.87f, height - height * 0.5f, height * 0.3f, height * 0.3f), "Goal Limit: " + goalLimitInd.ToString(), textNor);
    324.  
    325.             if (GUI.Button(new Rect(width - width * 0.96f, height - height * 0.5f, width * 0.3f, height * 0.07f), "◄", blank))
    326.             {
    327.                 if (goalLimitInd != 3)
    328.                 {
    329.                     goalLimitInd--;
    330.                 }
    331.                 else
    332.                 {
    333.                     goalLimitInd = 15;
    334.                 }
    335.             }
    336.  
    337.             if (GUI.Button(new Rect(width - width * 0.9f + width * 0.3f + height * 0.3f, height - height * 0.5f, width * 0.3f, height * 0.07f), "►", blank))
    338.             {
    339.                 if (goalLimitInd != 15)
    340.                 {
    341.                     goalLimitInd++;
    342.                 }
    343.                 else
    344.                 {
    345.                     goalLimitInd = 3;
    346.                 }
    347.             }
    348.  
    349.             //Ball Bounciness
    350.             GUI.Label(new Rect(width - width * 0.87f, height - height * 0.4f, height * 0.3f, height * 0.3f), "Ball Bounciness:\n     " + bouncStat, textNor);
    351.  
    352.             if (GUI.Button(new Rect(width - width * 0.96f, height - height * 0.4f, width * 0.3f, height * 0.07f), "◄", blank))
    353.             {
    354.                 if (bounInd != 0)
    355.                 {
    356.                     bounInd--;
    357.                 }
    358.                 else
    359.                 {
    360.                     bounInd = 3;
    361.                 }
    362.             }
    363.  
    364.             if (GUI.Button(new Rect(width - width * 0.9f + width * 0.3f + height * 0.3f, height - height * 0.4f, width * 0.3f, height * 0.07f), "►", blank))
    365.             {
    366.                 if (bounInd != 3)
    367.                 {
    368.                     bounInd++;
    369.                 }
    370.                 else
    371.                 {
    372.                     bounInd = 0;
    373.                 }
    374.             }
    375.  
    376.             //Start
    377.             if (GUI.Button(new Rect(width - width * 0.8f, height - height * 0.26f, width * 0.6f, height * 0.11f), "Start", play1))
    378.             {
    379.                 GameManager.scoreLimit = goalLimitInd;
    380.                 GameManager.timeLimit = timeChoice[timeLimInd];
    381.                 GameManager.gameOver = false;
    382.                 bounce.bounciness = bouncChoice[bounInd];
    383.                 Application.LoadLevel(1);
    384.             }
    385.  
    386.             //Back
    387.             if (GUI.Button(new Rect(width - width * 0.8f, height - height * 0.13f, width * 0.6f, height * 0.11f), "Back", play1))
    388.             {
    389.                 mainMenu = true;
    390.                 onePSelect = false;
    391.             }
    392.         }
    393.     }
    394. }
     
  2. Athomield3D

    Athomield3D

    Joined:
    Aug 29, 2012
    Posts:
    193
  3. Tautvydas-Zilys

    Tautvydas-Zilys

    Unity Technologies

    Joined:
    Jul 25, 2013
    Posts:
    10,491
    Hi, could you post the player log?
     
  4. Athomield3D

    Athomield3D

    Joined:
    Aug 29, 2012
    Posts:
    193
    Player log ? You mean the player prefs in unity ?
     
  5. Tautvydas-Zilys

    Tautvydas-Zilys

    Unity Technologies

    Joined:
    Jul 25, 2013
    Posts:
    10,491
  6. Athomield3D

    Athomield3D

    Joined:
    Aug 29, 2012
    Posts:
    193
    Hi, I've ran into an error when i try to get the player log
     
  7. Tautvydas-Zilys

    Tautvydas-Zilys

    Unity Technologies

    Joined:
    Jul 25, 2013
    Posts:
    10,491
    Exit the game before reading the file :).
     
  8. Athomield3D

    Athomield3D

    Joined:
    Aug 29, 2012
    Posts:
    193
    Ah there we go,I got them


    Build from 'release/4.5/release' branch, version is '4.5.0f6 (fd4616464986)' (Release build).
    Physical memory: 511 MB, commited memory limit: 180 MB.
    PlayerConnection initialized from C:/Data/Programs/{DF881454-6BD1-4FA2-8EFA-09A1DB18EDA1}/Install/Data (debug = 0)
    PlayerConnection initialized network socket : 0.0.0.0 55321
    Multi-casting "[IP] 192.168.1.65 [Port] 55321 [Flags] 2 [Guid] 2730930861 [EditorId] 2817653644 [Version] 1048832 [Id] WP8Player(169.254.206.162) [Debug] 0" to [225.0.0.222:54997]...
    Direct3D:
    Version: Direct3D 11.0 [level 9.3]
    Renderer: Microsoft Basic Render Driver (ID=0x8c)
    Vendor: Microsoft
    VRAM: 128 MB
    Initialize engine version: 4.5.0f6 (fd4616464986)
    UnloadTime: 6.038200 ms
    Unloading 3 Unused Serialized files (Serialized files now loaded: 0 / Dirty serialized files: 0)

    Unloading 7 unused Assets to reduce memory usage. Loaded Objects now: 199. Operation took 20.225000 ms.
    System memory in use: 1.5 MB.
    UnloadTime: 1.296900 ms
    Unloading 1 Unused Serialized files (Serialized files now loaded: 0 / Dirty serialized files: 0)

    Unloading 2 unused Assets to reduce memory usage. Loaded Objects now: 189. Operation took 5.173800 ms.
    System memory in use: 1.5 MB.
    UnloadTime: 1.388100 ms
    Unloading 1 Unused Serialized files (Serialized files now loaded: 0 / Dirty serialized files: 0)

    Unloading 2 unused Assets to reduce memory usage. Loaded Objects now: 189. Operation took 10.165400 ms.
    System memory in use: 1.5 MB.
    UnloadTime: 2.629000 ms
    Unloading 1 Unused Serialized files (Serialized files now loaded: 0 / Dirty serialized files: 0)

    Unloading 2 unused Assets to reduce memory usage. Loaded Objects now: 189. Operation took 8.015200 ms.
    System memory in use: 1.5 MB.
     
  9. Tautvydas-Zilys

    Tautvydas-Zilys

    Unity Technologies

    Joined:
    Jul 25, 2013
    Posts:
    10,491
    Are you sure you're running the same application as the log is from? There are no errors in it, yet the screenshot you gave in your first post is full of them.
     
  10. Athomield3D

    Athomield3D

    Joined:
    Aug 29, 2012
    Posts:
    193
    Ah, those errors are because of the buttons are automatically triggered to true (as if i click them) and it's trying to go to the next level witch I removed.
    I just wanted to show you how it triggers all the bool variable to true and shows all of the menus meanwhile in the editor there is no such problem.
     
  11. Tautvydas-Zilys

    Tautvydas-Zilys

    Unity Technologies

    Joined:
    Jul 25, 2013
    Posts:
    10,491
    I believe we already have this bug filled.
     
  12. Athomield3D

    Athomield3D

    Joined:
    Aug 29, 2012
    Posts:
    193
    I didn't get what you mean by "filled", does that mean the team is working on fixing the bug ?
     
  13. Tautvydas-Zilys

    Tautvydas-Zilys

    Unity Technologies

    Joined:
    Jul 25, 2013
    Posts:
    10,491
  14. brentstrandy

    brentstrandy

    Joined:
    Aug 16, 2012
    Posts:
    5
    Is this bug only in the WP8 Simulator? Or does this happen on the device as well?
     
  15. Tautvydas-Zilys

    Tautvydas-Zilys

    Unity Technologies

    Joined:
    Jul 25, 2013
    Posts:
    10,491
    It only happens on the emulator.
     
    brentstrandy likes this.