Search Unity

  1. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

Unity crashing when using slider ???

Discussion in 'Immediate Mode GUI (IMGUI)' started by R.A.E., May 2, 2008.

  1. R.A.E.

    R.A.E.

    Joined:
    Apr 24, 2008
    Posts:
    44
    I wrote a little script based on the scripts from the manual.

    Code (csharp):
    1.  
    2. // GUI Elements
    3.  
    4.  
    5. private var hSliderValue : float;
    6.  
    7. var capImage : Texture2D ;
    8.  
    9.  
    10.  
    11. /* Screen.width  Screen.height example */
    12.  
    13. function OnGUI () {
    14.    
    15.     //Top Left
    16.     GUI.Box (Rect (0,0,200,50), "Top-left");
    17.    
    18.    
    19.    
    20.    
    21.     // Top Right
    22.     GUI.Box (Rect (Screen.width - 200,0,200,50), "Take a screenshot");
    23.    
    24.     // Make the first button. If it is pressed, Snapshot is taken
    25.         if (GUI.Button (Rect (Screen.width - 150,25,80,20), "Snapshot")) {
    26.             Debug.Log("Screenshot");
    27.         }
    28.    
    29.    
    30.    
    31.     // Bottom Left
    32.     GUI.Box (Rect (0,Screen.height - 50,200,50), "Skinny - Fat");
    33.         hSliderValue = GUI.HorizontalSlider (Rect (50,Screen.height - 25, 100, 30), hSliderValue, 1.0, 100.0);
    34.         Debug.Log(hSliderValue);
    35.        
    36.         // if I uncomment the following line  try to use the slider Unity crashes !!!!! what am I doing wrong??
    37.        
    38.         //GUI.Label (Rect (0,Screen.height - 75,100,50), capImage);
    39.  
    40.    
    41.    
    42.    
    43.     //Bottom Right
    44.     GUI.Box (Rect (Screen.width - 200,Screen.height - 50,200,50), "Color");
    45.    
    46. }
    47.  
    48. // Make the script also execute in edit mode
    49. @script ExecuteInEditMode()
    50.  
    51.  

    First everything worked fine. Since i tried to add an
    image to the lower left ( the line is outcommented now), Unity crashed when I try to use the slider.
    Also my Debug.Log from the top right are not working no more.

    Even if the line is outcommented now, Unity is still crashing if i try to use the slider.


    What am I doing wrong??


    Thanks

    Marc