- Home /
[Closed] Type Could not be Resolved - Cycle
I am very confused -_-
I read this question from some other people, and I understand what the error is trying to tell me, but all I did was eliminate a reference to one script that doesn't even show up in the rest of the other script, and I get a host of these things...
The script that I edited isn't even involved with these scripts!
Assets/Scripts/Rings/RingMaster.js(85,50): BCE0070: Definition of 'RingMaster.CheckRings()' depends on 'EnemyCounter.EndWave()' whose type could not be resolved because of a cycle. Explicitly declare the type of either one to break the cycle.
Assets/Scripts/Enemies/FlyThroughTimer.js(61,30): BCE0070: Definition of 'FlyThroughTimer.ExitScreenEnemies()' depends on 'EnemyCounter.EndWave()' whose type could not be resolved because of a cycle. Explicitly declare the type of either one to break the cycle.
The following 3 functions are from different scripts and correspond to the errors respectively:
function CheckRings(){
finalText = Instantiate( text, Vector3( 0.85, 0.5, 0 ), Quaternion.identity);
pickText( reportedRings );
finalText.fontSize = 90;
finalText.fontStyle = FontStyle.Italic;
StaticFunctions.FadeIn( finalText.gameObject, 0.0, 1.0, 1.0, false );
ship.AddEnergy( reportedRings*10 );
if( ringTotal == reportedRings ){
GameObject.Find("Master").GetComponent( PointTracker ).AddPoints( ( 500) );
}
ship.AddEnergy( reportedRings*2 );
Master.dodgingWave = false;
StartCoroutine( FadeAll( myText, myTotal, mySlash, finalText) );
camera.main.GetComponent( EnemyCounter ).EndWave();
}
divider
function ExitScreenEnemies(){
flyCount = 0;
spawner.ClearGrid();
var enemiesArray : Component[] = GetComponentsInChildren( Transform );
for( var u : Transform in enemiesArray ){
if( u.transform.Find("Gun")) u.transform.Find( "Gun" ).GetComponent( EnemyTargeting ).can_Shoot = false;
if( u.transform.GetComponent( EnemyMovement) ) u.GetComponent( EnemyMovement ).ExitScreen();
}
enemyCounter.EndWave();
enemyCounter.screenEmpty = true;
}
And the EndWave function:
function EndWave(){
GameObject.Find( "EnemyGrid" ).GetComponent( FlyThroughTimer ).countDown = false;
hud.Fade( 1.0, 0.0, 1.5, false );
Instantiate( endWaveDisplay, Vector3(0,0,0 ), Quaternion.identity );
yield WaitForSeconds( 2.0 );
endWaveUp = true;
}
What's up???
Thanks! - YA
Often times when your resolve one issue, it will allow the compiler to see more errors. It is not uncommon for this to happen, I had one project where I fixed 3 errors and 50 more popped up as soon as the compiler could get to them. In my experience the "type could not be resolved because of a cycle" is due to some kind of recursive call. I would need to see you code to tell you more.
You could always just do what it says and explicitly declare the type of the functions.
There were no errors before hand. I literally omitted a completely useless variable declaration ( I did a search for it in the code and it didn't pop up ) in an unattached script. Now there are these issues, and they won't go away even if I add the omitted code back in. -_- I will edit my answer to include the pertinent functions.
All scripts get compiled whether you use them or not. If you dont intend to use a script, remove it completely or rename it in explorer to no longer be 'code', for example .js_ so the script is still there but it's no longer compiled.
Answer by ensomniac · Jun 18, 2014 at 11:18 PM
I had this same error in my game (no recursion).
Everything was fine until today when the compiler decided that it cared about this and spit out this error:
Assets/scripts/continueController.js(422,36): BCE0070: Definition of 'continueController.setStoreText()' depends on 'localize.heartPack1Desc()' whose type could not be resolved because of a cycle. Explicitly declare the type of either one to break the cycle.
Given that I was not using recursion, or anything special for that matter, this error was confusing to me. The solution was to explicitly define the output type of one of my functions, which I've never done before:
Initially, my function looked like this:
function heartPack1Desc() {
return IAPController.lifePackTitles[0];
}
So my assumption was to do this:
static function heartPack1Desc() {
var content : String = IAPController.lifePackTitles[0];
return content;
}
But that's not what the compiler wanted me to do. The compiler wanted this:
static function heartPack1Desc() : String {
return IAPController.lifePackTitles[0];
}
Which makes total sense, if you know that declaring the type of a function is a thing at all, which I didn't.
I'm answering this for posterity, in case someone comes along in the future, like I did today.
You only need to declare a function type if you are returning a value.
For instance, in C#, That would be written as:
static String heartPack1Desc(){
return myString;
}
Thanks for posting this! I'm sure it will clear things up for people that look here in the future!
Answer by seth_slax · Sep 08, 2015 at 01:43 AM
For anyone else who runs into this error, this can also be due to the yield statement in the last script.
Your answer
Follow this Question
Related Questions
Audio Score Trigger Help 0 Answers
I can't get my script to work I get an error. [Please Help!] 0 Answers
Activating Bool Array in sequence. 2 Answers
Where can I find a list of variable types for use in Javascript? 3 Answers
Redim a variable 3 Answers