Home > other >  After upgrade Unity5.6.5, IOS packages, set TimeScale, problems while loop
After upgrade Unity5.6.5, IOS packages, set TimeScale, problems while loop

Time:09-18

I will Unity5.5.5 p1 upgrade to version Unity5.6.5 p3,
Game combat part there is change the TimeScale,

The export of IOS package, after entering the game, there is no place to TimeScale changes cause the scaling of time, makes the character animation to jump to the next animation, separated after a long time will jump and normal (UI), see the log can't find an error,

After further screening, find coroutines did not immediately after the while loop exit execution down , the code is as follows:
IEnumerator STATE ()
{
//signal code
While (_instate)
{
The Debug Log (" 1 ");
Yield return null;
}
The Debug Log (" 2 ");
}
Found the problem is when, after changed the timeScale will _instate set to false, the Debug. The Log (" 2 "); After the card for a long time to execute, inquired what reason is this,

Unity5.5.5 version did not appear this kind of problem, 5.6.5 export Android package is normal also, only 5.6.5 export IOS has the problem ,

Inquired, what is the cause, how should solve?

CodePudding user response:

The reason:
(1) the Debug. The Log itself is time-consuming;
(2) to Update the other parts of the affected coroutines execution;
Provide some Suggestions:
(1) delete empty Update
. (2) in the Debug Log output before and after the time to look at, how long specific impact;

CodePudding user response:

Hello, thank you for your answer ~
This is found in our project to upgrade the Unity, the previous version do not have this problem (Unity5.5.5),
(1) log is a schematic, itself is not in engineering, and
(2) he had written a very simple demo, there is no content in the Update, but still found the problem,
The hair under the specific question is:
Unity5.6.5 export IOS package, set timeScale can lead to the while loop in coroutines gets stuck, stuck hours are not fixed,
Unity2017 export IOS package, set timeScale is not effective, but will not be stuck,
Current problem occurs only in IOS, Android and Unity in all could not see the phenomenon,
Demo is very simple, there should be no problems involving performance, felt like IOS timeScale mechanism has a problem, whether this kind of direct assignment is a problem with the way,
The Demo is as follows:
1, CubeMoveAgent. Cs:
 
Private bool _instate=false;
Private float _timer=0 f;
[SerializeField] float speed=1.5 f;

Public void StartMove ()
{
_timer=0 f;
StartCoroutine (MOVEINCOROUTINE ());
}

Public void StopMove ()
{
_instate=false;
}

IEnumerator MOVEINCOROUTINE ()
{
_instate=true;
While (_instate)
{
This. The transform. The position=new Vector3 (- 10 f + _timer * speed, 1 f, 10 f);
_timer +=Time. DeltaTime;
Yield return null;
}
This. The transform. LocalPosition=new Vector3 (0 f, 5 f, 10 f);
}

2, ButtonMessage. Cs:
 
[SerializeField] CubeMoveAgent _cube;
Void OnGUI ()
{
If (GUILayout. Button (" TimeScale=4 ", GUILayout Width (150.0 f), GUILayout. The Height (75.0 f)))
{
Time. The timeScale=4 f;
}
If (GUI. The Button (new the Rect (Screen width 150.0 f, 10 f, 150 f and 75 f), "Start Move"))//, GUILayout. The width (150.0 f), GUILayout. Height (75.0 f)))
{
_cube. StartMove ();
}
If (GUI. The Button (new the Rect (Screen width 150.0 f, 90 f and 150 f and 75 f), "Stop Move"))
{
_cube. StopMove ();
}
}

CodePudding user response:

In a unity3d version package to production is solved
  • Related