Advertisement
Wyvern67

Untitled

Jun 29th, 2014
328
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.26 KB | None | 0 0
  1. //MenuGUI.css
  2. using UnityEngine;
  3. using System.Collections;
  4.  
  5. public class MenuGUI : MonoBehaviour {
  6.  
  7.     // Use this for initialization
  8.     void Start () {
  9.    
  10.     }
  11.    
  12.     // Update is called once per frame
  13.     void Update () {
  14.  
  15.     }
  16.  
  17.     void OnGUI() {
  18.         GUI.Box (new Rect (10, 10, 100, 200), "Weapons");
  19.         //GUI.Box (new Rect (Screen.width - 200, Screen.height - 200, 400, 400), "Inventory");
  20.  
  21.         if (GUI.Button (new Rect (15, 35, 90, 20), "Sniper")) {
  22.             WieldWeapon.PickUpWeapon("sniper");
  23.             Debug.Log("Sniper retrieved");
  24.         }
  25.     }
  26. }
  27.  
  28.  
  29.  
  30.  
  31. //WieldWeapon.css
  32. using UnityEngine;
  33. using System.Collections;
  34.  
  35. public class MenuGUI : MonoBehaviour {
  36.  
  37.     // Use this for initialization
  38.     void Start () {
  39.    
  40.     }
  41.    
  42.     // Update is called once per frame
  43.     void Update () {
  44.  
  45.     }
  46.  
  47.     void OnGUI() {
  48.         GUI.Box (new Rect (10, 10, 100, 200), "Weapons");
  49.         //GUI.Box (new Rect (Screen.width - 200, Screen.height - 200, 400, 400), "Inventory");
  50.  
  51.         if (GUI.Button (new Rect (15, 35, 90, 20), "Sniper")) {
  52.             WieldWeapon.PickUpWeapon("sniper");  //  <---------------------- Error here
  53.             Debug.Log("Sniper retrieved");
  54.         }
  55.     }
  56. }
  57.  
  58.  
  59. //Erreur: Assets/Scripts/MenuGUI.cs(21,37): error CS0120: An object reference is required to access non-static member `WieldWeapon.PickUpWeapon(string)'
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement