我有两个场景:菜单和主菜单。我在SceneManager.LoadScene("Main")
上有一个很大的滞后。
以下是分析器的数据: https://gyazo.com/da116d1f8e9b429e9170bc3769d23ac4
据我所知,1s延迟与初始化Zenject上下文有关。
这是我的安装人员:
using LevelGenerators;
using Signals;
using States;
using UnityEngine;
using Zenject;
public class MainMonoInstaller : MonoInstaller<MainMonoInstaller>
{
[Inject] public BrickController.Settings BrickSettings;
public override void InstallBindings()
{
Container.BindInterfacesAndSelfTo<GameController>().AsSingle().NonLazy();
Container.BindInterfacesAndSelfTo<ScoreboardDataController>().AsSingle();
Container.BindInterfacesAndSelfTo<InputController>().AsSingle();
// signals
Container.DeclareSignal<LaunchBallSignal>();
Container.DeclareSignal<GameStateChangedSignal>();
Container.DeclareSignal<MovePlayerSignal>();
Container.DeclareSignal<MovePlayerToPositionSignal>();
Container.DeclareSignal<FloorTouchedSignal>();
Container.DeclareSignal<GiveScorepointsSignal>();
Container.DeclareSignal<AttachToPlayerSignal>();
Container.DeclareSignal<LevelCompletedSignal>();
Container.DeclareSignal<ResetPlayerStateSignal>();
Container.DeclareSignal<GameEndedSignal>();
// factories
Container.Bind<StateFactory>().AsSingle();
Container.BindFactory<StartingGameState, StartingGameState.Factory>();
Container.BindFactory<PlayingState, PlayingState.Factory>();
Container.BindFactory<GameOverState, GameOverState.Factory>();
Container.BindFactory<ClassicLevelGenerator, ClassicLevelGenerator.Factory>();
Container.BindFactory<StarLevelGenerator, StarLevelGenerator.Factory>();
//
Container.BindFactory<BrickController, BrickController.Factory>()
.FromComponentInNewPrefab(BrickSettings.BrickPrefab)
.WithGameObjectName("Brick");
Container.BindInterfacesAndSelfTo<LevelManager>().AsSingle();
Container.Bind<LevelGeneratorFactory>().AsSingle();
}
}
该场景在运行时有大约40个游戏对象。
我正在使用Unity 2017.2.1f1,.NET 4.6和Zenject 5.5.1。
有没有办法加快场景之间的切换?