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 S_Byrnes · Mar 28, 2014 at 12:28 AM · c#guileaderboardskin

Leaderboard GUISkin?

Hey guys, I need some help getting my leaderboard to match with the theme of my game, at the moment I have the leaderboard working correctly, and appearing, but not with my GUI skin, it's only the default, here's what I have so far:

 using UnityEngine;
 using System.Collections.Generic;
  
 public class LeaderBoardSample : MonoBehaviour {
     float startTime = 10.0f;
     float timeLeft = 0.0f;
  
     public GUISkin guiSkin;
  
     Rect windowRect = new Rect (0, 0, 620, 520);
  
     string playerName = "";
     string code = "";
  
     enum gameState {
        waiting,
        running,
        enterscore,
        leaderboard
     };
  
     gameState gs;
  
  
     // Reference to the dreamloLeaderboard prefab in the scene
  
     dreamloLeaderBoard dl;
     dreamloPromoCode pc;
  
     void Start () 
     {
        // get the reference here...
        this.dl = dreamloLeaderBoard.GetSceneDreamloLeaderboard();
  
        // get the other reference here
        this.pc = dreamloPromoCode.GetSceneDreamloPromoCode();
  
        this.timeLeft = startTime;
        this.gs = gameState.waiting;
     }
  
     void Update () 
     {
        if (this.gs == gameState.running)
          {
           this.gs = gameState.enterscore;
        }
     }
  
     void OnGUI()
     {
  
        GUI.skin = guiSkin;
  
        GUILayoutOption[] width200 = new GUILayoutOption[] {GUILayout.Width(200)};
  
        float width = 400;  // Make this wider to add more columns
        float height = 200;
  
        Rect r = new Rect((Screen.width / 2) - (width / 2), (Screen.height / 2) - (height), width, height);
        GUILayout.BeginArea(r, new GUIStyle("box"));
  
        GUILayout.BeginVertical();
        if (this.gs == gameState.waiting || this.gs == gameState.running)
        {
           this.gs = gameState.running;
  
          GUILayout.Label("Total Score: " + GameLogicScript.score);
        }
  
  
  
        if (this.gs == gameState.enterscore)
        {
          GUILayout.Label("Total Score: " + GameLogicScript.score);
          GUILayout.BeginHorizontal();
          GUILayout.Label("Your Name: ");
          this.playerName = GUILayout.TextField(this.playerName, width200);
  
          if (GUILayout.Button("Save Score"))
          {
           // add the score...
           if (dl.publicCode == "") Debug.LogError("You forgot to set the publicCode variable");
           if (dl.privateCode == "") Debug.LogError("You forgot to set the privateCode variable");
  
           dl.AddScore(this.playerName, GameLogicScript.score);
  
           this.gs = gameState.leaderboard;
          }
          GUILayout.EndHorizontal();
        }
  
        if (this.gs == gameState.leaderboard)
        {
          GUILayout.Label("High Scores:");
          List<dreamloLeaderBoard.Score> scoreList = dl.ToListHighToLow();
  
          if (scoreList == null) 
          {
           GUILayout.Label("(loading...)");
          } 
          else 
          {
           int maxToDisplay = 20;
           int count = 0;
           foreach (dreamloLeaderBoard.Score currentScore in scoreList)
           {
               count++;
               GUILayout.BeginHorizontal();
               GUILayout.Label(currentScore.playerName, width200);
               GUILayout.Label(currentScore.score.ToString(), width200);
               GUILayout.EndHorizontal();
  
               if (count >= maxToDisplay) break;
           }
          }
        }
        GUILayout.EndVertical();
        GUILayout.EndArea();
     }
  
  
 }

I essentially need to present these kind of like the code bellow, where the code above replaces my buttons bellow:

 using UnityEngine; 
 using System.Collections;
 
 public class GameOver : MonoBehaviour {
 
 public GUISkin guiSkin;
  
 Rect windowRect = new Rect (0, 0, 620, 520);
 private bool toggleTxt = false;
 string stringToEdit = "Text Label";
 float hSliderValue = 0.0f;
 float vSliderValue = 0.0f;
 private float hSbarValuet;
 private float vSbarValue;
 private Vector2 scrollPosition = Vector2.zero;
  
  
 void  Start (){
  
     Time.timeScale = 1.0f;
     Screen.sleepTimeout = SleepTimeout.NeverSleep;
     windowRect.x = (Screen.width - windowRect.width)/2;
     windowRect.y = (Screen.height - windowRect.height)/2;
 }
  
  
 void  OnGUI (){
     GUI.skin = guiSkin;
  
     windowRect = GUI.Window (0, windowRect, DoMyWindow, "Game Over");
  
  
 }
  
  
  
 void  DoMyWindow ( int windowID  ){
  
     GUI.Button (new Rect (140, 50, 340, 50), "Score: " + GameLogicScript.score);
     if (GUI.Button (new Rect (140, 120, 340, 50), "Post Score"))
        Application.LoadLevel ("Post Score");
     if (GUI.Button ( new Rect(140,190,340,50), "Restart"))
         Application.LoadLevel ("TestScene1");
     if (GUI.Button ( new Rect(140,260,340,50), "Main Menu"))
        Application.LoadLevel ("Menu");
     if (GUI.Button ( new Rect(140,330,340,50), "Quit"))
        Application.Quit ();
 }
 }

I hope I made that clear, thanks in advanced!

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 S_Byrnes · Mar 28, 2014 at 11:05 PM 0
Share

Please help?

avatar image ashwanidv100 · Dec 28, 2016 at 09:37 AM 0
Share

Have you solve this problem.

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

21 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 avatar image avatar image avatar image avatar image

Related Questions

Multiple Cars not working 1 Answer

Working With GUI 1 Answer

Is There A Way To Make Sprites Clickable? 1 Answer

In-Game GUI buttons don't work 2 Answers

Making my GUI Button Movable in Play mode 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