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 fir3st0rm9 · Jan 27, 2013 at 11:58 PM · variableintapplicationapplication.loadedlevel

Storing Application.LoadedLevel As a variable not working.

Hi, I have this code where I want lvll to equal the current scene's index number

     if (steps == stepsneeded) {
     //pkmn = Random.Range(1,4
         Debug.Log("BATTLE");
         lvll = Application.loadedLevel();
         SendMessage("ReturnLVL",lvll);
         
         Application.LoadLevel(8);
     }

The problem is that when I run my project, the console says: It is not possible to invoke an expression of type 'int'

Shouldn't this work being that Application.LoadedLevel returns an int?

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

1 Reply

· Add your reply
  • Sort: 
avatar image
1

Answer by Gizmoi · Jan 28, 2013 at 12:53 AM

Application.loadedLevel is a property, not a function. Remove the brackets and you'll be fine :)

Comment
Add comment · Show 4 · 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 fir3st0rm9 · Jan 28, 2013 at 01:26 AM 0
Share

Thanks for the help but I am having one other problem..

 function Update () {
 if (Application.loadedLevel == 8){
     Send$$anonymous$$essage("RunAway", ReturnLVL.lvl, ReturnLVL.positionx, ReturnLVL.positiony,ReturnLVL.positionz);
 }
 }
 
 function ReturnLVL (lvl : int,positionx : int, positiony : int, positionz : int){
     Debug.Log(lvl);
     Debug.Log(positionx);
     Debug.Log(positiony);
     Debug.Log(positionz);
 }



When I use this it says No appropriate version of UnityEngine.Component.Send$$anonymous$$essage for the argument list (String, system.object,system.object,system.object,system.object) was found.

How can I fix this error?

avatar image Gizmoi · Jan 28, 2013 at 01:31 AM 0
Share

It's saying that the function Send$$anonymous$$essage does not accept the parameters you have provided. Send$$anonymous$$essage takes the function name you wish to call - "RunAway" - and one optional argument to pass to that function.
You have tried to pass multiple objects, you can only pass in one, or none. You should modify the receiving function to accept ReturnLVL ins$$anonymous$$d.

avatar image fir3st0rm9 · Jan 28, 2013 at 01:33 AM 0
Share

Okay, how would I allow the function to recieve another function?

would it just be

 function RunAway (ReturnLVL : function) {
 
 }


?

avatar image Gizmoi · Jan 28, 2013 at 01:40 AM 0
Share

Ah, I misunderstood, I thought ReturnLVL was a class. Whatever you are trying to pass into the RunAway function, you should collect into a class and pass an instance of that.
Or, ideally, call the RunAway function directly using an instance of whatever script it belongs to.

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

10 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

Related Questions

Variable data type for two ints (x and y) in inspector 3 Answers

Problem with variables,Problem with identifying a variable 2 Answers

How can i save a int for multiple texture. Please Read. 0 Answers

controlling the increment in the variable 1 Answer

I can't print a int.ToString() variable in a guiText.text 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