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 ErhMuhGurd · Dec 14, 2014 at 08:59 AM · screenguitext

Screen utilization

So I am trying to create a simple quiz program. When I test play it within Unity it looks just fine, but when I install it on my phone, it is so small I can hardly see it. Please refer to the picture below. I have tried to use larger text in hopes it would fill in the unused area of the screen but of course that didn't work. How do I tell Unity to use the entire screen? Please see my script below. All I did was to create the scene was drag the Questionnaire2.cs script onto the Main Camera. Any help would be greatly appreciated. Thanks in advance.

alt text

====================================

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

public class Questionnaire2 : MonoBehaviour {

 public int questionTextSize;
 public int buttonTextSize;
 public int buttonWidth;
 public int buttonHeight;
 public int index;
 
 class Question
 {
     public string QuestionText;
     public List<string> Answers = new List<string>();
     public int CorrectAnswer;
 }

 List<Question> list = new List<Question>();

 Question GetQuestion()
 {
     int rand = Random.Range(0, list.Count);
     index = rand;
     return list[rand];  
 }

 void OnGUI()
 {
     //--------------------------For Debug Purposes--------------------------------
     //GUI.Label(new Rect(10, 10, 100, 20), "Questions: " + list.Count);
     //GUI.Label(new Rect(10, 30, 200, 20), "Current Question: " + index.ToString());
     //GUI.Label(new Rect(10, 60, 200, 20), "Current Answers: " + list[index].Answers);
     //-----------------------------------------------------------------------------

     //Custom setings...
     GUI.skin.label.fontSize = questionTextSize;
     GUI.skin.button.fontSize = buttonTextSize;
     GUI.skin.label.alignment = TextAnchor.UpperCenter;
     GUI.skin.label.alignment = TextAnchor.UpperCenter;

     //Display question...                                   
     GUI.Label(new Rect((Screen.width / 2) - (200 / 2), (Screen.height / 2) - (25 / 2) - 75, 200,200),list[index].QuestionText);
     
     //Display the answers.
     for (int i = 0; i <= 3; i++ )
     {
         if (GUI.Button(new Rect((Screen.width / 2) - (buttonWidth / 2), (Screen.height / 2) - (25 / 2) + i*30, buttonWidth,buttonHeight),list[index].Answers[i]))
         {
             //If correct answer...
             if (i == list[index].CorrectAnswer)
             {
                 Debug.Log("Correct");

                 if (index < list.Count)
                 {
                     list.Remove(list[index]);
                     GetQuestion();
                 }    //Here we would add the Ending...
                 else { Debug.LogError("Out Of Questions To Display"); }
             }
             else //if incorrect....
             {
                 Debug.Log("Incorrect");
                 GetQuestion();
             }
         }
     }

 }
 
 void Awake()
 {
     //Questions and answers are listed here. Index beginning at 0.
     //The CorrectAnswer property should set to the correct
     //Index of the correct answer in this first one you can see
     //Correct answer is index "3". 0, 1, 2, and 3("Four Text").
     list.Add(new Question());
     list[0].QuestionText = "What is 2 + 2?";
     list[0].Answers.Add("1");
     list[0].Answers.Add("2");
     list[0].Answers.Add("22");
     list[0].Answers.Add("4");
     list[0].CorrectAnswer = 3;
     
     list.Add(new Question());
     list[1].QuestionText = "What is 4 + 4?";
     list[1].Answers.Add("4");
     list[1].Answers.Add("44");
     list[1].Answers.Add("8");
     list[1].Answers.Add("100");
     list[1].CorrectAnswer = 2;
     
     list.Add(new Question());
     list[2].QuestionText = "What is 6 + 6?";
     list[2].Answers.Add("16");
     list[2].Answers.Add("9");
     list[2].Answers.Add("12");
     list[2].Answers.Add("6,000,000");
     list[2].CorrectAnswer = 2;
     
     list.Add(new Question());
     list[3].QuestionText = "What is 8 + 8?";
     list[3].Answers.Add("2");
     list[3].Answers.Add("88");
     list[3].Answers.Add("5");
     list[3].Answers.Add("16");
     list[3].CorrectAnswer = 3;

     //So to add a new question. Copy a block 
     //Like this one and paste it below. Then
     // Change the text in between ".."
     //And increment the number list[4] to list[5] 
     //and so on... The "3" on Correct answer 
     //is the index. 0,1,2,3  (or in human 1,2,3,4) 
     //So the 3 index is where it says 
     //list[4].Answers.Add("16");
     //the "4" is the question's index.
     list.Add(new Question());
     list[4].QuestionText = "What is 8 + 8?";
     list[4].Answers.Add("2");
     list[4].Answers.Add("88");
     list[4].Answers.Add("5");
     list[4].Answers.Add("16");
     list[4].CorrectAnswer = 3;

     //Get a question at runtime.
     GetQuestion();
 }

}

====================================

screenshot_2014-12-13-07-46-04.png (28.0 kB)
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

Gizmo-like GUi text? 2 Answers

Fit GUIText in every resolution 3 Answers

GUIText shows only in one camera (not the others) 1 Answer

How to set the position of a guitext using transform? 1 Answer

Print Anything to Screen 4 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