Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 12 Next capture
2021 2022 2023
1 capture
12 Jun 22 - 12 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 /
  • Help Room /
avatar image
0
Question by AlexTheGame · Mar 20, 2016 at 08:24 AM · levelsstringstycoon

Load a certain level depending on where objects are placed.

Hi. I'm making a sort of tycoon game, I have got the basic drag and drop feature. When a button is pressed, I want it to load a level depending on how many of each object there is. For instance I have ads, talk shows and music, if there is a right balance of them load a certain level, if there is too many ads then load another etc... I have the basic code for loading A level but a specific one.

 #pragma strict
  public var Level = "2";
  
  function LoadLevel(){
  Application.LoadLevel(Level);
  }

so yeah I just need it to choose a level depending on strings

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 Ali-hatem · Mar 20, 2016 at 11:27 AM 0
Share

explain more you asked :

depending on where objects are placed.

& explained :

depending on how many of each object there is.

so positions or quantity ?

avatar image AlexTheGame Ali-hatem · Mar 20, 2016 at 11:30 AM 0
Share

Hey, sorry I wasn't clear. I mean the game is UI. The player drags ui objects on the screen. I want when a button is pressed to load a level depending the the type of UI object which is music, ads or talk shows.

1 Reply

· Add your reply
  • Sort: 
avatar image
0

Answer by Ali-hatem · Mar 20, 2016 at 12:20 PM

c# so now tag the UI elements in inspector & make sure tags are same as you test in script :

 public GameObject [] Music;
     public GameObject [] Ads;
     public GameObject [] Shows;
 
     void Update(){
         Music = GameObject.FindGameObjectsWithTag ("music");
         Ads = GameObject.FindGameObjectsWithTag ("ads");
         Shows = GameObject.FindGameObjectsWithTag ("shows");
     }
 
     public void ChoesLevel(){
        //this test which object have the larger amount than others if you want certain NUMBER test only the array length like that if(Music.Length == 5) .

         if (Music.Length > Ads.Length && Music.Length > Shows.Length) {
             print ("music :" + Music.Length);
         } else if (Ads.Length > Music.Length && Ads.Length > Shows.Length) {
             print ("ads :" + Ads.Length);
         } else if (Shows.Length > Music.Length && Shows.Length > Ads.Length) {
             print ("show :" + Shows.Length);        
         } else {
             print ("there is no one type is biger than others");
         }
     }
Comment
Add comment · Show 3 · 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 AlexTheGame · Mar 20, 2016 at 02:35 PM 0
Share

Hey. Thanks so much for the code - but I don't think you understand, probably due to my descriptive skills ;p

The idea is when there is a certain NU$$anonymous$$BER of ads, music or talk shows then load the scene depending on that number.

Sorry for confusion ;[

avatar image Ali-hatem AlexTheGame · Mar 20, 2016 at 07:31 PM 0
Share

i was thinking you might mean this but i want to make sure now my brain is freezing i been answering & commenting all the day & i will tray something tomorrow even it looks tricky if now i understand you you want to calculate which type is grater than others then open that type scene.

avatar image Ali-hatem AlexTheGame · Mar 21, 2016 at 04:42 PM 0
Share

now i have edited the code it will test which object have the larger amount than others just in case you want that if you want certain NU$$anonymous$$BER easy just test the array length like that if($$anonymous$$usic.Length == YournNmber) .

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

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

Related Questions

Could someone help me with scripting a Trigger that when the player enters and then presses the E Key a new level is loaded. My script is JS at the moment. 1 Answer

PlayerPrefs Not Consistently Saving Stats 0 Answers

String array out of index C# 1 Answer

Any way to update a string array mid game?,Update the strings in a string array mid game? 1 Answer

Help with Non-Linear Levels 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