Search Unity

Hello help me please I am a beginner:

Discussion in 'Scripting' started by branek42, Dec 22, 2014.

  1. branek42

    branek42

    Joined:
    Oct 10, 2013
    Posts:
    76
    Hello help me please I am a beginner:

    I need a script to GUI Box with 20 images but that the scroll box for android

    Next: I need if click on images image is enlarged on full Screen.

    And when moving your finger to left on the picture skip to picture 2

    Very much thanks for help
     
  2. Fluzing

    Fluzing

    Joined:
    Apr 5, 2013
    Posts:
    815
    This is not how the forums work. If you need code, you have to Google it. If you can't code, you need to learn it. There are plenty of tutorials on GUI and coding.
     
  3. branek42

    branek42

    Joined:
    Oct 10, 2013
    Posts:
    76
    I wrote this script
    But I want to scrolling work when you move finger on box not on slider help me pls
    Code (JavaScript):
    1. var scrollViewVector : Vector2 = Vector2.zero;
    2.  
    3. var texture :  Texture2D ;
    4. var texture1 :  Texture2D ;
    5. var texture2 :  Texture2D ;
    6. var texture3 :  Texture2D ;
    7. var texture4 :  Texture2D ;
    8. var texture5 :  Texture2D ;
    9. var texture6 :  Texture2D ;
    10. var texture7 :  Texture2D ;
    11. var texture8 :  Texture2D ;
    12. var texture9 :  Texture2D ;
    13. var texture10:  Texture2D ;
    14. var texture11 :  Texture2D ;
    15. var texture12 :  Texture2D ;
    16. var texture13 :  Texture2D ;
    17. var texture14 :  Texture2D ;
    18. var texture15 :  Texture2D ;
    19. var texture16 :  Texture2D ;
    20. var texture17 :  Texture2D ;
    21. var texture18 :  Texture2D ;
    22. var texture19 :  Texture2D ;
    23. var texture20 :  Texture2D ;
    24. var texture21 :  Texture2D ;
    25. var texture22:  Texture2D ;
    26. var texture23 :  Texture2D ;
    27.  
    28.  
    29. function OnGUI () {
    30.     // Begin the ScrollView
    31.     scrollViewVector = GUI.BeginScrollView (Rect (0, 0, 600, 600), scrollViewVector, Rect (0, 0, 0,2000));
    32.  
    33.     // Put something inside the ScrollView
    34.           GUI.skin.button = new GUIStyle();
    35.      if (GUI.Button (Rect (0,0,200,200), texture )) {
    36.        
    37.  
    38.     }
    39.  
    40.     if (GUI.Button (Rect (200,0,200,200), texture1  )) {
    41.        
    42.     }
    43.  
    44.     if (GUI.Button (Rect (400,0,200,200), texture2  )) {
    45.        
    46.     }
    47.  
    48.     if (GUI.Button (Rect (0,200,200,200), texture3 )) {
    49.        
    50.     }
    51.  
    52.     if (GUI.Button (Rect (200,200,200,200), texture4  )) {
    53.        
    54.     }
    55.  
    56.     if (GUI.Button (Rect (400,200,200,200), texture5  )) {
    57.        
    58.     }
    59.  
    60.     if (GUI.Button (Rect (0,400,200,200), texture6)) {
    61.        
    62.     }
    63.  
    64.     if (GUI.Button (Rect (200,400,200,200), texture7  )) {
    65.        
    66.     }
    67.  
    68.     if (GUI.Button (Rect (400,400,200,200), texture8  )) {
    69.      
    70.     }
    71.      
    72.     if (GUI.Button (Rect (0,600,200,200), texture9)) {
    73.        
    74.     }
    75.  
    76.     if (GUI.Button (Rect (200,600,200,200), texture10  )) {
    77.        
    78.     }
    79.  
    80.     if (GUI.Button (Rect (400,600,200,200), texture11 )) {
    81.        
    82.     }
    83.        
    84.     if (GUI.Button (Rect (0,800,200,200), texture12 )) {
    85.        
    86.     }
    87.  
    88.     if (GUI.Button (Rect (200,800,200,200), texture13  )) {
    89.        
    90.     }
    91.  
    92.     if (GUI.Button (Rect (400,800,200,200), texture14  )) {
    93.      
    94.     }
    95.  
    96.     if (GUI.Button (Rect (0,1000,200,200), texture15 )) {
    97.      
    98.     }
    99.  
    100.     if (GUI.Button (Rect (200,1000,200,200), texture16 )) {
    101.        
    102.     }
    103.  
    104.     if (GUI.Button (Rect (400,1000,200,200), texture17  )) {
    105.        
    106.     }
    107.  
    108.     if (GUI.Button (Rect (0,1200,200,200), texture18)) {
    109.        
    110.     }
    111.  
    112.     if (GUI.Button (Rect (200,1200,200,200), texture19  )) {
    113.      
    114.     }
    115.  
    116.     if (GUI.Button (Rect (400,1200,200,200), texture20  )) {
    117.        
    118.     }
    119.      
    120.     if (GUI.Button (Rect (0,1400,200,200), texture21)) {
    121.        
    122.     }
    123.  
    124.     if (GUI.Button (Rect (200,1400,200,200), texture22  )) {
    125.        
    126.     }
    127.  
    128.     if (GUI.Button (Rect (400,1400,200,200), texture23 )) {
    129.        
    130.     }
    131.        
    132.  
    133.  
    134.  
    135.     // End the ScrollView
    136.     GUI.EndScrollView();
    137.  
    138. }
     
  4. Atmey

    Atmey

    Joined:
    Nov 3, 2012
    Posts:
    88
    While this might not exactly solve your issue, but you might consider automating the process a bit, instead of creating 20 textures you couldn't created an array, also a loop for the rects inside the onGUI with dynamic parameters.

    I am not quite familiar with the new UI yet (doesn't use onGUI), I did a simple google search and found this video (I didn't watch it yet, but the title looks on the subject).
     
  5. branek42

    branek42

    Joined:
    Oct 10, 2013
    Posts:
    76
    Hello Can you help me as I will do loop for the rects inside the onGUI with dynamic parameters.?
     
  6. Kiwasi

    Kiwasi

    Joined:
    Dec 5, 2013
    Posts:
    16,860
    Do yourself a favour and watch the loops tutorial on the learn section. There is also a video on arrays. Will reduce the code you posted down to half a dozen lines