• 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 juniperspark · Aug 29, 2015 at 04:29 PM · loopcycle

Error: type could not be resolved because of a cycle.

Hi everyone,

I hope you can help me. I am having a problem with "type could not be resolved because of a cycle".


Specifically it says:

"Definition of 'LevelUpCheck(AvatarData, int)' depends on 'EndBattlePanel()' whose type could not be resolved because of a cycle. Explicitly declare the type of either one to break the cycle."


Explaination:

My thought process was that EndBattlePanel would be the master function and would act like a switch. So it should :

  • start off on avatar[0]

  • then run the Experience(0) function

  • then run the LevelUpCheck function

  • if avatar did level up, then it would show a popup with a 'continue' button.

  • When this is pressed, it will play the LevelUpCheck function again until avatar doesn't gain any more levels and will then do the else statement.

  • When the else statement is run, the Avatar[0] should have a false value and so it would be become false in EndBattlePanel function and continue on with Avatar[1] and run all of the functions again until both Avatar[0] & Avatar[1] are false.


Code:

     function EndBattlePanel ()
     {                
         if(avatar[0].hasBattled == true)
         {                            
             yield Experience(0);
         }        
         else if(avatar[1].hasBattled == true)
         {
             yield Experience(1);
         }
         else
         {
             scrollbar.SetActive(true);
             continueButton.SetActive(true);
         }        
     }
     
     function Experience (number : int)
     {
         var avatarSelected : AvatarData;
         avatarSelected         = avatar[number];        
 
         ExperienceFormula();
         yield SlideExperienceBar();
         LevelUpCheck(avatarSelected, number);    
     }
     
     function LevelUpCheck (avatarSelected : AvatarData, number : int)
     {
         levelUpPopup.SetActive(false);
         
         if (avatarSelected.curExperience > avatarSelected.experienceMax)
         {
             LevelUpAvatar(avatarSelected);
             levelUpPopup.SetActive(true);            
         }
         else
         {
             avatar[number].hasBattled = false; 
             yield WaitForSeconds(0.5);    
             EndBattlePanel();            
         }    
     }
 

   


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 hulahoolgames · Aug 29, 2015 at 05:36 PM

This has been answered here. Explicitly mention the return type of either one of the functions since they both depend on each other.

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.

Welcome to Unity Answers

If you’re new to Unity Answers, please check our User Guide to help you navigate through our website and refer to our FAQ for more information.

Before posting, make sure to check out our Knowledge Base for commonly asked Unity questions.

Check our Moderator Guidelines if you’re a new moderator and want to work together in an effort to improve Unity Answers and support our users.

Follow this Question

Answers Answers and Comments

27 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

Related Questions

Cycle Through All GameObjects in the Scene 2 Answers

Cycle Through Array of Enemies 1 Answer

Make a Button For Every String in an Array of Level Names 1 Answer

Definition of Script.function() depends on Script.function()... 3 Answers

How can i loop my path instead of it ending on the lasat point 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