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 Extrude Studios · Jan 05, 2015 at 10:36 AM · c#game

Random does not contain a defintion for Range

Unity says that if i save my script can you help me?

Here is the Script: using UnityEngine; using System.Collections;

public class t1 : MonoBehaviour {

     int message = 0;    
     
         public void Start()
         {
             message = UnityEngine.Range(1,29);
         }
     
         public void OnGUI()
         {
             if(message == 1)
                 guiText.text = "42";
             if(message == 2)
                 guiText.text = "1 byte + 0.5 byte = Monochrome";
             if(message == 3)
                 guiText.text = "This is a random Text";
             if(message == 4)
                 guiText.text = "Play it in less than one second!";
             if(message == 5)
                 guiText.text = "Runs under 2000 fps";
             if(message == 6)
                 guiText.text = "Hello Computer :)";
             if(message == 7)
                 guiText.text = "Is your slave!";
             if(message == 8)
                 guiText.text = "XB-70 Valkyrie!";
             if(message == 9)
                 guiText.text = "I want a A-380.";
             if(message == 10)
                 guiText.text = "Not for under 0.01$";
             if(message == 11)
                 guiText.text = "Hasn't any value.";
             if(message == 12)
                 guiText.text = "I've an E-Mail acount.";
             if(message == 13)
                 guiText.text = "Yellow!!!";
             if(message == 14)
                 guiText.text = "Colder than a Pentium(r) 4.";
             if(message == 15)
                 guiText.text = "Runs maybe on your Computer.";
             if(message == 16)
                 guiText.text = "Needs 5TB of RAM.";
             if(message == 17)
                 guiText.text = "Annoying!";
             if(message == 18)
                 guiText.text = "Short play!";
             if(message == 19)
                 guiText.text = "I hope you like it!";
             if(message == 20)
                 guiText.text = "It's made during Apollo 13!";
             if(message == 21)
                 guiText.text = "26 Different Text's.";
             if(message == 22)
                 guiText.text = "64bit rocks!";
             if(message == 23)
                 guiText.text = "Can speak English.";
             if(message == 24)
                 guiText.text = "Give it all your money!";
             if(message == 25)
                 guiText.text = "Is pointless!";
             if(message == 26)
                 guiText.text = "Has an idea!!!";
             if(message == 27)
                 guiText.text = "Yeah, Bluescreen.";
             if(message == 28)
                 guiText.text = "Hi Mr. Trevor Phillips.";
             if(message == 29)
                 guiText.text = "Runs with oxygen";
         }
 }
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 pako · Jan 05, 2015 at 10:45 AM 0
Share

Also, if you don't have a special reason for declaring Start() and OnGUI public, leave them private (just remove the public keyword).

And one more thing: Consider using the "switch" statement rather than all the if statements, see:

http://msdn.microsoft.com/en-us/library/06tc147t.aspx

But if you prefer the "if" statements anyway, all statements after the first "if" should be "else if":

http://msdn.microsoft.com/en-us/library/5011f09h.aspx

avatar image Umresh · Jan 05, 2015 at 11:54 AM 0
Share

Try

 Random.Range($$anonymous$$,max);

1 Reply

· Add your reply
  • Sort: 
avatar image
0

Answer by Mehul-Rughani · Jan 06, 2015 at 06:22 AM

Try this..

Random.Range(minvalue,maxvalue)

minvalue : include maxvalue : exclude

Comment
Add comment · 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

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

5 People are following this question.

avatar image avatar image avatar image avatar image avatar image

Related Questions

Intensifying rate over time... 1 Answer

How do you make image links in the Main Menu light up/glow when hovering? 1 Answer

Distribute terrain in zones 3 Answers

About to start a new project, need help... 1 Answer

Changing gravity direction... 5 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