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 BrunoxGida · Oct 29, 2013 at 03:16 PM · errortext

The variable m_Font of 'GUISkin' doesn't exist anymore

Please help-me. script:

 GUILayout.BeginHorizontal();
                 GUILayout.Label("Player Name: ");
                 playerName = GUILayout.TextField (playerName, 15, GUILayout.Height(25));
             GUILayout.EndHorizontal();


EDIT:

ok, I'll go over the complete code please help me out.

 using UnityEngine;
 using System.Collections;
 using System.Collections.Generic;

 public class ConnectMenu : Photon.MonoBehaviour {

     public GUISkin guiSKin;
     //Use this for loading splash screen
     public Texture blackScreen;
     public Texture top;
     public Texture bottom;

     //Defne Round duration in seconds
     public int roundDuration = 600;

     //Room settings
     List<int> maxPlayersOptions = new List<int>();

     //Setup available maps
     [System.Serializable]
         public class AllMaps{
             public string mapName;
             public Texture2D mapPreview;
         }
     public List<AllMaps> allMaps;

     //Room/Player names
     string newRoomName;
     string playerName;
     int maxPlayers;
     int selectedMap;
     string gameMode;

     Vector2 scroll;
     Vector2 mapScroll;

     //Fade black screen
     float fadeValue = new float();
     int fadeDir;

     //Save info about all Photon Rooms
     RoomInfo[] allRooms;
     bool createRoom = false;
     bool connectingToRoom = false;

     // Use this for initialization
     void Start () {
         PhotonNetwork.isMessageQueueRunning = true;
         Screen.lockCursor = false;
         allRooms = PhotonNetwork.GetRoomList();
         newRoomName = "Room Name " + Random.Range(111, 999);
         playerName = "Player " + Random.Range(111, 999);

         //Here we setup possible numbers for max players in one room
         maxPlayersOptions.Add(4);
         maxPlayersOptions.Add(8);
         maxPlayersOptions.Add(12);
         maxPlayersOptions.Add(16);
         maxPlayers = maxPlayersOptions[2];
         selectedMap = 0;

         //Prevent roundDuration being less than 1
         if(roundDuration == 0){
             roundDuration = 600;
         }
         gameMode = "TDM";

         //Load player name if it was saved
         if(PlayerPrefs.HasKey("PlayerName")){
             playerName = PlayerPrefs.GetString("PlayerName");
         }
     }

     void Update(){
         //Try to reconnect every 3 seconds
         float updateRate = 3;
         float nextUpdateTime = 0;
         //Do not try connect every frame, but using small intervals (To avoid lag while failed to connect)
         if(!PhotonNetwork.connected){
             if (Time.time - updateRate > nextUpdateTime){
                 nextUpdateTime = Time.time - Time.deltaTime;
             }
             // Keep firing until we used up the fire time
             while(nextUpdateTime < Time.time){
                 PhotonNetwork.ConnectUsingSettings("v0.0.1");
                 nextUpdateTime += updateRate;
             }
         }

         //FInd all existing rooms automatically
         if(PhotonNetwork.connected && allRooms.Length != PhotonNetwork.GetRoomList().Length){
             allRooms = PhotonNetwork.GetRoomList();
         }
     }

     // Update is called once per frame
     void OnGUI () {
         GUI.skin = guiSKin;

         GUI.color = Color.white;
         GUI.depth = -2;
         //If we havnt connected to Photon Cloud do not allow player to join/create room
         if(!PhotonNetwork.connected){
             GUI.enabled = false;
         }else{
             GUI.enabled = true;
         }

         //Other GUI
         GUI.color = new Color(1,1,1, 0.9f);
         GUI.DrawTexture(new Rect(0 ,0, top.width, top.height), top, ScaleMode.ScaleToFit);
         GUI.DrawTexture(new Rect(Screen.width - bottom.width , Screen.height - bottom.height, bottom.width, bottom.height), bottom, ScaleMode.ScaleToFit);
         GUI.color = Color.white;

         //Main Menu
         GUILayout.BeginArea(new Rect (Screen.width/2 - 250, Screen.height/2 - 150, 500, 330), "Assalt Brasil - Salas", GUI.skin.GetStyle("window"));
         ShowConnectMenu();
         GUILayout.EndArea();

         if(!PhotonNetwork.connected){
             GUI.color = Color.white;
             GUI.Box (new Rect(Screen.width/2 - 75, Screen.height/2 - 15, 150, 30), "Connecting...");
         }

         //Fade black screen when connecting to Room
         FadeScreen();
     }

     void ShowConnectMenu(){
         GUILayout.Space (10);
         if(!createRoom){
             //DIsplay all available rooms and Join selected room
             scroll = GUILayout.BeginScrollView(scroll, GUILayout.Width(480), GUILayout.Height(225));{
                 foreach(RoomInfo room in allRooms){
                     if(allRooms.Length > 0){
                         GUILayout.BeginHorizontal("box");
                         //Room name
                         GUILayout.Label(room.name, GUILayout.Width(150));
                         //Map name
                         GUILayout.Label((string)room.customProperties["MapName"], GUILayout.Width(135));
                         //Player count
                         GUILayout.Label(room.playerCount + "/" + room.maxPlayers, GUILayout.Width(60));
                         GUILayout.FlexibleSpace();
                         if(GUILayout.Button("Join Room", GUILayout.Width(100))){
                             //Join a room
                             PhotonNetwork.JoinRoom(room.name);
                             PhotonNetwork.playerName = playerName;
                             connectingToRoom = true;

                             //Save player name
                             CheckPlayerNameAndRoom();
                             PlayerPrefs.SetString("PlayerName", playerName);
                         }
                         GUILayout.EndHorizontal();
                     }
                 }
                 if(allRooms.Length == 0){
                     GUILayout.Label("Nao a Salas Criadas.");
                 }
                 GUILayout.EndScrollView();}

                 GUILayout.Space(5);

                 //Choose player name
                 GUILayout.BeginHorizontal();
                 GUILayout.Label("Nome do Jogador: ");
                 playerName = GUILayout.TextField (playerName, 15, GUILayout.Height(25));
                 GUILayout.EndHorizontal();

                 //Go to room creation menu
                 GUILayout.FlexibleSpace();
                 GUILayout.BeginHorizontal();
                 GUILayout.FlexibleSpace();
                 if(GUILayout.Button("Create Room", GUILayout.Width(130), GUILayout.Height(25))){
                     createRoom = true;
                     //Save player name
                     CheckPlayerNameAndRoom();
                     PlayerPrefs.SetString("PlayerName", playerName);
                 }
                 GUILayout.EndHorizontal();
         }else{
             //Create new room***************************************************************************

             //Room name
             GUILayout.BeginHorizontal();
             GUILayout.Label("Room Name: ", GUILayout.Width(130));
             newRoomName = GUILayout.TextField (newRoomName, 15, GUILayout.Height(25));
             GUILayout.EndHorizontal();

             GUILayout.Space(5);

             GUILayout.BeginHorizontal();
             GUILayout.Label("Max Players: ", GUILayout.Width(130));
             for(int i = 0; i < maxPlayersOptions.Count; i++){
                 if(maxPlayers == maxPlayersOptions[i]){
                     //Selected number is green
                     GUI.color = Color.green;
                 }else{
                     GUI.color = Color.white;
                 }
                 if(GUILayout.Button(maxPlayersOptions[i].ToString(), GUILayout.Width(27), GUILayout.Height(25))){
                     maxPlayers = maxPlayersOptions[i];
                 }
             }
             GUI.color = Color.white;
             GUILayout.EndHorizontal();

             GUILayout.Space(5);

             //Select Game Mode *****************************************************************
             GUILayout.BeginHorizontal();
             GUILayout.Label("Game Mode: ", GUILayout.Width(130));

             if(gameMode == "TDM"){
                 GUI.color = Color.green;
             }
             if(GUILayout.Button("TeamDeathmatch", GUILayout.Width(140), GUILayout.Height(25))){
                 gameMode = "TDM";
             }

             GUI.color = Color.white;

             if(gameMode == "DM"){
                 GUI.color = Color.green;
             }
             if(GUILayout.Button("Deathmatch", GUILayout.Width(140), GUILayout.Height(25))){
                 gameMode = "DM";
             }
             GUILayout.EndHorizontal();
             //*******************************************************************************
             GUI.color = Color.white;

             GUILayout.Space(5);

             GUILayout.BeginHorizontal();
             mapScroll = GUILayout.BeginScrollView(mapScroll, false, true, GUILayout.Width(240), GUILayout.Height(160));
             for(int i = 0; i < allMaps.Count; i++){
                 if(selectedMap == i){
                     //Selected map is green
                     GUI.color = Color.green;
                 }else{
                     GUI.color = Color.white;
                 }
                 if(GUILayout.Button(allMaps[i].mapName, GUILayout.Height(25))){
                     selectedMap = i;
                 }
             }
             GUI.color = Color.white;
             GUILayout.EndScrollView();
             GUILayout.Space(10);

             //Show map preview image
             if(allMaps[selectedMap].mapPreview != null){
                 GUILayout.Label(allMaps[selectedMap].mapPreview, GUILayout.Width(230), GUILayout.Height(160));
             }
             GUILayout.EndHorizontal();

             GUILayout.FlexibleSpace();


             GUILayout.BeginHorizontal();
             //Return to Lobby
             if(GUILayout.Button("Main Menu", GUILayout.Width(130), GUILayout.Height(25))){
                 createRoom = false;
             }

             GUILayout.FlexibleSpace();

             //Create our room **********************************************************
             if(GUILayout.Button("Continue", GUILayout.Width(130), GUILayout.Height(25))){
                 CheckPlayerNameAndRoom();
                 PhotonNetwork.player.name = playerName;
                 Hashtable setMapName = new Hashtable();
                 setMapName["MapName"] = allMaps[selectedMap].mapName;
                 setMapName["RoundDuration"] = roundDuration;
                 setMapName["GameMode"] = gameMode;
                 string[] exposedProps = new string[3];
                 exposedProps[0] = "MapName";
                 exposedProps[1] = "RoundDuration";
                 exposedProps[2] = "GameMode";
                 //Create new Room
                 PhotonNetwork.CreateRoom(newRoomName, true, true, maxPlayers, setMapName, exposedProps);
             }
             GUILayout.EndHorizontal();
             //****************************************************************************************
         }
     }

     void FadeScreen(){
         if(connectingToRoom){
             //Show loadign screen while we connection to room and loading scene
             fadeDir = 1;
             fadeValue += fadeDir * 15 * Time.deltaTime;
             fadeValue = Mathf.Clamp01(fadeValue);

             GUI.color = new Color(1,1,1,fadeValue);
             GUI.DrawTexture(new Rect(0,0, Screen.width, Screen.height), blackScreen);

             GUI.color = Color.white;
             GUI.Label(new Rect(Screen.width/2 - 75, Screen.height/2 - 15, 150, 30), "Loading...");
         }
     }

     IEnumerator LoadMap(string sceneName){
         connectingToRoom = true;
         PhotonNetwork.isMessageQueueRunning = false;
         fadeDir = 1;
         yield return new WaitForSeconds(1);

         Application.backgroundLoadingPriority = ThreadPriority.High;
         AsyncOperation async = Application.LoadLevelAsync(sceneName);
         yield return async;
         Debug.Log("Loading complete");
     }

     void CheckPlayerNameAndRoom(){
         //Player Name can't be empty
         string tempName = playerName.Replace(" ", "");
         if(tempName == ""){
             playerName = "Player " + Random.Range(111, 999);
         }
         //Room Name can't be empty
         string tempRoomName = newRoomName.Replace(" ", "");
         if(tempRoomName == ""){
             newRoomName = "Room Name " + Random.Range(111, 999);
         }
     }

     //Functions that are called on certan Photon action (Connected, Disconencted etc.) ************************************************************
     void OnJoinedRoom(){
         print ("Joined room: " + newRoomName);
         connectingToRoom = true;
         //We joined room, load respective map
         StartCoroutine(LoadMap((string)PhotonNetwork.room.customProperties["MapName"]));
     }

     void OnJoinedLobby(){
         print ("Joined master server");
     }

     void OnLeftRoom(){
         connectingToRoom = false;
     }

     void OnPhotonJoinRoomFailed(){
         print ("Failed on connecting to room");
         connectingToRoom = false;
     }

     void OnPhotonCreateRoomFailed(){
         print ("Failed on creating room");
         connectingToRoom = false;
     }

     void OnPhotonPlayerConnected(){
         print ("Player connected");
     }

     void OnConnectedToPhoton(){
         print ("We connected to Photon Cloud");
         if(PhotonNetwork.room != null){
             PhotonNetwork.LeaveRoom();
         }
         connectingToRoom = false;

     }

     void OnDisconnectedFromPhoton(){
         print ("We disconencted from Photon Cloud");
     }
     //*********************************************************************************************************************
 }
Comment
Add comment · Show 2
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
avatar image Dave-Carlile · Oct 29, 2013 at 03:18 PM 0
Share

This code is not referencing m_Font or GUISkin. I think we'll need more details to help you with your problem.

avatar image ArkaneX · Oct 29, 2013 at 04:26 PM 0
Share

m_Font is a private field of GUISkin. There are a few questions related to this problem, but unfortunately without answers.

@BrunoxGida - do you use any custom GUISkin in your code? Or maybe you changed any font in the inspector?

1 Reply

· Add your reply
  • Sort: 
avatar image
0

Answer by ArkaneX · Oct 29, 2013 at 06:11 PM

Please select your GUI skin (the one you assign to guiSKin variable), and check the Font property in the Inspector (on the top). If it is set to None, select some font, e.g. Arial.

Comment
Add comment · Show 1 · Share
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
avatar image Stormy102 · Jun 14, 2014 at 05:28 PM 0
Share

Thanks! That really helped me out. I thought that my files were corrupted. If you are using default GUISkin, just use this code var LabelFont : Font; function OnGUI() { GUI.skin.font = LabelFont; }

Assign the default Arial font and this should fix any problems! Or use your own custom font.

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

17 People are following this question.

avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image

Related Questions

Script to load a text file gives error. 1 Answer

unity 5.3 InvalidOperationException 1 Answer

Pause script errror. 1 Answer

how do i fix this error 1 Answer

problem at adding script 1 Answer


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