Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 13 Next capture
2021 2022 2023
1 capture
13 Jun 22 - 13 Jun 22
sparklines
Close Help
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
  • Asset Store
  • Get Unity

UNITY ACCOUNT

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account
  • Blog
  • Forums
  • Answers
  • Evangelists
  • User Groups
  • Beta Program
  • Advisory Panel

Navigation

  • Home
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
    • Blog
    • Forums
    • Answers
    • Evangelists
    • User Groups
    • Beta Program
    • Advisory Panel

Unity account

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account

Language

  • Chinese
  • Spanish
  • Japanese
  • Korean
  • Portuguese
  • Ask a question
  • Spaces
    • Default
    • Help Room
    • META
    • Moderators
    • Topics
    • Questions
    • Users
    • Badges
  • Home /
avatar image
0
Question by jeijei · Sep 23, 2014 at 05:37 PM · guibugspawnmenudisappear

Character spawn menu bug

i have an empty object in the scene with a script that on start shows 2 buttons, each spawns a different character, however when they are pressed, they should disappear but for some reason they don't . i can't see where my mistake is, anyone see any problems with this? using UnityEngine; using System.Collections;

 public class playerspawner : MonoBehaviour {
     public float selectedPlayer ;
     public bool isselecting;
     public GameObject playerPrefab1;
     public GameObject playerPrefab2;
     public GameObject spawnObject;
     public GameObject spawnObject2;
     private bool disconnect=false;
 void Start()
     {
         isselecting = true;
         Screen.showCursor = true;
     }
     void Update () {
 
                 if (Input.GetKeyDown (KeyCode.Escape)) {
                         disconnect = !disconnect;
              
                     Screen.lockCursor = false;
             Screen.showCursor = true;
             }
         if(isselecting!=true&&disconnect!=true)
             Screen.lockCursor = true;
         }
     public void SpawnPlayer()
     {    
             
         if (selectedPlayer == 1) {
 
                         PhotonNetwork.Instantiate (playerPrefab1.name, spawnObject.transform.position, Quaternion.identity, 0);
             isselecting = false;
             disconnect=false;
                 }
         else
             if (selectedPlayer == 2) {
                         PhotonNetwork.Instantiate (playerPrefab2.name, spawnObject2.transform.position, Quaternion.identity, 0);
             isselecting =false;
             disconnect=false;
             }
             
     }
     void OnGUI()
     {
         if (isselecting != false ) {
             if (GUI.Button (new Rect ( Screen.width/5, Screen.height/3,Screen.width/5, Screen.height/5), "earthbender")) {
                                 selectedPlayer = 1;
 
             
                                 SpawnPlayer ();
                 Screen.showCursor = false;
 
                         }
 
 
             if (GUI.Button (new Rect ( Screen.width/5+Screen.width*2/5, Screen.height/3,Screen.width/5, Screen.height/5), "firebender")) {
                                 selectedPlayer = 2;
     
                                 SpawnPlayer ();
                 Screen.showCursor = false;
 
                         }
                 }
         if(disconnect==true)
             if(GUI.Button (new Rect (Screen.width/5, Screen.height/5,Screen.width/6, Screen.height/5), "Disconnect"))
         {Network.Disconnect();
             MasterServer.UnregisterHost();
             disconnect=false;
             Application.LoadLevel ("DemoWorker-Scene");
             Screen.showCursor = true;
 
         }
 
 
     }
     private void OnPlayerDisconnected(NetworkPlayer player) {
                 Debug.Log ("Clean up after player " + player);
                 Network.RemoveRPCs (player);
                 Network.DestroyPlayerObjects (player);
         }
 
 
 
 }
 
Comment
Add comment
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users

0 Replies

· Add your reply
  • Sort: 

Your answer

Hint: You can notify a user about this post by typing @username

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Follow this Question

Answers Answers and Comments

2 People are following this question.

avatar image avatar image

Related Questions

How do I create a Gmod item spawn menu in unity? 0 Answers

an UP-TO-DATE menu tutorial 1 Answer

Why does the font selected for my GUI Skin not display correctly? 1 Answer

v4.6 UI Element's Positioning Incorrect 1 Answer

Accessing the Asset's setting from code using Wizards/Editor classes? 0 Answers


Enterprise
Social Q&A

Social
Subscribe on YouTube social-youtube Follow on LinkedIn social-linkedin Follow on Twitter social-twitter Follow on Facebook social-facebook Follow on Instagram social-instagram

Footer

  • Purchase
    • Products
    • Subscription
    • Asset Store
    • Unity Gear
    • Resellers
  • Education
    • Students
    • Educators
    • Certification
    • Learn
    • Center of Excellence
  • Download
    • Unity
    • Beta Program
  • Unity Labs
    • Labs
    • Publications
  • Resources
    • Learn platform
    • Community
    • Documentation
    • Unity QA
    • FAQ
    • Services Status
    • Connect
  • About Unity
    • About Us
    • Blog
    • Events
    • Careers
    • Contact
    • Press
    • Partners
    • Affiliates
    • Security
Copyright © 2020 Unity Technologies
  • Legal
  • Privacy Policy
  • Cookies
  • Do Not Sell My Personal Information
  • Cookies Settings
"Unity", Unity logos, and other Unity trademarks are trademarks or registered trademarks of Unity Technologies or its affiliates in the U.S. and elsewhere (more info here). Other names or brands are trademarks of their respective owners.
  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Spaces
  • Default
  • Help Room
  • META
  • Moderators
  • Explore
  • Topics
  • Questions
  • Users
  • Badges