Advertisement
Guest User

Untitled

a guest
Jul 20th, 2017
45
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 2.44 KB | None | 0 0
  1. #WTF is this for?
  2. using UnityEngine;
  3. using System.Collections;
  4. static class ButtonHelper
  5. {
  6.  
  7.     public static Rect CreateBUttonRow (float x, float y)
  8.     {
  9.        
  10.         float width = (((float)Screen.width) / 5.0f) - 15;
  11.        
  12.         float height = (((float)Screen.height) / 2.0f) - 15;
  13.        
  14.         return new Rect (x + 15, y + 15, width, height);
  15.        
  16.     }
  17.    
  18.    
  19. }
  20.  
  21. public class ButtonHelperBottom
  22. {
  23.     public static Rect CreateBUttonRow2 (float x)
  24.     {
  25.        
  26.         float width = (((float)Screen.width) / 5.0f) - 15;
  27.        
  28.         float height = (((float)Screen.height) / 2.0f) - 15;
  29.        
  30.         float y = (height);
  31.        
  32.         return new Rect (x + 15, y + 15, width, height);
  33.        
  34.     }
  35. }
  36.  
  37.  
  38. public class WeaponsModeMenu : MonoBehaviour
  39. {
  40.  
  41.     bool AnotherButton (ref Rect rect, string text)
  42.     {
  43.         bool buttonValue = GUI.Button (rect, text);
  44.         rect.x += rect.width;
  45.         return buttonValue;
  46.     }
  47.  
  48.     void OnGUI ()
  49.     {
  50.        
  51.         //top row reference rect
  52.         Rect topRowrect = ButtonHelper.CreateBUttonRow (0, 0);
  53.        
  54.         bool wasPressedC = AnotherButton (ref topRowrect, "Campaign");
  55.         if (wasPressedC) {
  56.             Application.LoadLevel ("Testmap Scene");
  57.         }
  58.        
  59.         bool wasPressedM = AnotherButton (ref topRowrect, "Multiplayer");
  60.         if (wasPressedM) {
  61.             Application.LoadLevel ("MultiPlayer Menu");
  62.         }
  63.        
  64.         bool wasPressedO = AnotherButton (ref topRowrect, "Options");
  65.         if (wasPressedO) {
  66.             Application.LoadLevel ("Options Menu");
  67.         }
  68.        
  69.         bool wasPressedQ = AnotherButton (ref topRowrect, "Quit");
  70.         if (wasPressedQ) {
  71.             Application.Quit ();
  72.         }
  73.        
  74.         bool wasPressedC1 = AnotherButton (ref topRowrect, "Campaign");
  75.         if (wasPressedC1) {
  76.             Application.LoadLevel ("Testmap Scene");
  77.         }
  78.        
  79.        
  80.         //bottom row reference rect
  81.         Rect bottomRowrect = ButtonHelperBottom.CreateBUttonRow2 (0);
  82.        
  83.         bool wasPressedx = AnotherButton (ref bottomRowrect, "Campaign");
  84.         if (wasPressedx) {
  85.             Application.LoadLevel ("Testmap Scene");
  86.         }
  87.        
  88.         bool wasPressedy = AnotherButton (ref bottomRowrect, "Campaign");
  89.         if (wasPressedy) {
  90.             Application.LoadLevel ("Testmap Scene");
  91.         }
  92.        
  93.         bool wasPressedz = AnotherButton (ref bottomRowrect, "Campaign");
  94.         if (wasPressedz) {
  95.             Application.LoadLevel ("Testmap Scene");
  96.         }
  97.        
  98.         bool wasPressed1 = AnotherButton (ref bottomRowrect, "Campaign");
  99.         if (wasPressed1) {
  100.             Application.LoadLevel ("Testmap Scene");
  101.         }
  102.        
  103.         bool wasPressed2 = AnotherButton (ref bottomRowrect, "Campaign");
  104.         if (wasPressed2) {
  105.             Application.LoadLevel ("Testmap Scene");
  106.         }
  107.     }
  108. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement