When navigating from menu to a Scene that contains 8, 1-minutes MP4 videos, that are played using new VideoPlayer script on RawImage component. I am using Unity 5.6.0b11 beta version.
In the scene that I am trying to navigate has prefabs that loads videos in list thumbnails, previously I was loading Images instead of Videos and it was working fine, now when trying to load video it freezes for than 38 seconds on Axon 7 (4GB RAM) and 32 seconds on One Plus 3 (6 GB RAM) but does not lags at all when playing on Unity Player itself.
Script I used for VideoPlayer is from this StackOverflow Question.
button.onClick.AddListener(new UnityEngine.Events.UnityAction(() =>
{
SceneManager.LoadSceneAsync("SceneSponsors");
StartCoroutine(CloseMenu());
}));
Is there a way, I can work around with the Slow Loading Scenes or pre-load them in Background when mainScene
is loaded on the App start and navigate in need.
I saw somewhere Resources.Load()
also makes it slow on Android Devices, but I've tested by removing all Resources.Load() which I was using to load image sprites but the problem was still there.
Edit:
Here's my CloseMenu()
functions it is only used to swipe and move the menu panel. P.S the App freezes only on loading that particular Scene, and works smoothly for other.
IEnumerator CloseMenu()
{
if (IsOpen)
{
Vector3 pos = MainMenuWindow.transform.position;
iTween.ColorUpdate(CloseArea, new Color(0, 0, 0, 0f), .6f);
iTween.MoveTo(MainMenuWindow.gameObject, new Vector3(Screen.width, pos.y, pos.z), .6f);
IsOpen = false;
yield return new WaitForSeconds(.3f);
CloseArea.transform.position = new Vector3(-240 * ScaleFact, CloseArea.transform.position.y, CloseArea.transform.position.z);
}
}
Edit 2 I am loading VideoPlayer on RawImage using Script. Here's what RawImage looks like in Play mode along with VideoPlayer, and in inactive mode.
CloseMenu
function look like? – ProgrammerCloseMenu
function. 38 seconds is too much. Please check codes that you run in the OnEnable, Awake or Start functions. Disable them all then re-enable them one by one. You will find which one causing the problem. Please, post that one. – Programmer