public ResourceSystem(IResourceLoader loader, IResourceHolder holder, IResourceDecoder decoder, IDependencyManifest dependencyManifest) { m_Loader = loader; m_Loader.OnLoadAssetBundleBytesComplete = OnResourceLoaderLoadAssetBundleBytesComplete; m_Loader.OnLoadAssetComplete = OnResourceLoaderLoadAssetComplete; m_Holder = holder; m_Decoder = decoder; m_DependencyManifest = dependencyManifest; }
private void Awake() { Instance = this; DontDestroyOnLoad(gameObject); FrameRate = m_FrameRate; TimeScale = m_TimeScale; RunInBackground = m_RunInBackground; SleepTimeout = m_SleepTimeout; if (!string.IsNullOrEmpty(m_LoggerTypeName)) { Type loggerType = Type.GetType(m_LoggerTypeName); ILogger logger = (ILogger)Activator.CreateInstance(loggerType); LogSystem = SystemManager.RegisterSystem(new LogSystem(logger)); LogSystem.LogLevel = m_LogLevel; LogSystem.TraceColor = ColorUtility.ToHtmlStringRGBA(m_TraceLogColor); LogSystem.DebugColor = ColorUtility.ToHtmlStringRGBA(m_DebugLogColor); LogSystem.InfoColor = ColorUtility.ToHtmlStringRGBA(m_InfoLogColor); LogSystem.WarnColor = ColorUtility.ToHtmlStringRGBA(m_WarnLogColor); LogSystem.ErrorColor = ColorUtility.ToHtmlStringRGBA(m_ErrorLogColor); LogSystem.FatalColor = ColorUtility.ToHtmlStringRGBA(m_FatalLogColor); } if (m_LuaPackagePaths != null) { for (int i = 0; i < m_LuaPackagePaths.Length; ++i) { m_LuaPackagePaths[i] = GetPath(m_LuaPackagePaths[i]); } } if (!string.IsNullOrEmpty(m_ResourceHolderTypeName) && !string.IsNullOrEmpty(m_ResourceDecoderTypeName)) { Type holderType = Type.GetType(m_ResourceHolderTypeName); IResourceHolder holder = (IResourceHolder)Activator.CreateInstance(holderType); Type decoderType = Type.GetType(m_ResourceDecoderTypeName); IResourceDecoder decoder = (IResourceDecoder)Activator.CreateInstance(decoderType); Type dependencyType = Type.GetType(m_ResourceDependencyManifestTypeName); IDependencyManifest dependencyManifest = (IDependencyManifest)Activator.CreateInstance(dependencyType); ResourceSystem = SystemManager.RegisterSystem(new ResourceSystem(m_ResourceLoaderComponent, holder, decoder, dependencyManifest)); ResourceSystem.EditorPath = GetPath(m_EditorPath); ResourceSystem.InternalPath = GetPath(m_InternalPath); ResourceSystem.ReadOnlyPath = GetPath(m_ReadOnlyPath); ResourceSystem.PersistentPath = GetPath(m_PersistentPath); } LuaSystem = SystemManager.RegisterSystem(new LuaSystem(m_LuaPackagePaths)); FsmSystem = SystemManager.RegisterSystem(new FsmSystem()); TimerSystem = SystemManager.RegisterSystem(new TimerSystem()); if (!string.IsNullOrEmpty(m_EventKeyTypeName)) { Type eventSystemType = typeof(EventSystem <>); Type eventKeyType = Type.GetType(m_EventKeyTypeName); eventSystemType = eventSystemType.MakeGenericType(eventKeyType); ISystem eventSystem = (ISystem)Activator.CreateInstance(eventSystemType); EventSystem = SystemManager.RegisterSystem(eventSystem); } if (!string.IsNullOrEmpty(m_UICreaterTypeName)) { Type type = Type.GetType(m_UICreaterTypeName); IUICreater creater = (IUICreater)Activator.CreateInstance(type); UISystem = SystemManager.RegisterSystem(new UISystem(creater, m_UIRoot)); if (m_UIDefaultGroups != null) { for (int i = 0; i < m_UIDefaultGroups.Length; ++i) { UISystem.AddGroup(m_UIDefaultGroups[i].Name, m_UIDefaultGroups[i].Depth); } } } if (m_DownloaderComponent != null) { DownloadSystem = SystemManager.RegisterSystem(new DownloadSystem(m_DownloaderComponent)); DownloadSystem.DownloadTimeout = m_DownloadTimeout; } NetworkSystem = SystemManager.RegisterSystem(new NetworkSystem()); HttpSystem = SystemManager.RegisterSystem(new HttpSystem(m_WebRequesterComponent)); if (!string.IsNullOrEmpty(m_DataTableParserTypeName)) { Type parserType = Type.GetType(m_DataTableParserTypeName); IDataTableParser parser = (IDataTableParser)Activator.CreateInstance(parserType); DataTableSystem = SystemManager.RegisterSystem(new DataTableSystem(parser)); } if (!string.IsNullOrEmpty(m_SettingHandlerTypeName)) { Type handlerType = Type.GetType(m_SettingHandlerTypeName); ISettingHandler handler = (ISettingHandler)Activator.CreateInstance(handlerType); SettingSystem = SystemManager.RegisterSystem(new SettingSystem(handler)); } if (!string.IsNullOrEmpty(m_LocalizationParserTypeName)) { Type parserType = Type.GetType(m_LocalizationParserTypeName); ILocalizationParser parser = (ILocalizationParser)Activator.CreateInstance(parserType); LocalizationSystem = SystemManager.RegisterSystem(new LocalizationSystem(parser)); LocalizationSystem.Language = m_LocalizationLanguage; } if (m_EnabledProcedureTypeNames != null && m_EnabledProcedureTypeNames.Length > 0 && !string.IsNullOrEmpty(m_StartProcedureTypeName)) { IProcedure[] procedures = new IProcedure[m_EnabledProcedureTypeNames.Length]; for (int i = 0; i < m_EnabledProcedureTypeNames.Length; ++i) { IProcedure procedure = null; Type type = Type.GetType(m_EnabledProcedureTypeNames[i]); if (type == null) { procedure = new LuaProcedure(m_EnabledProcedureTypeNames[i]); } else { procedure = (IProcedure)Activator.CreateInstance(type); } procedures[i] = procedure; } ProcedureSystem = SystemManager.RegisterSystem(new ProcedureSystem(procedures)); ProcedureSystem.Start(m_StartProcedureTypeName); } if (m_DebugFormTypeNames != null && m_DebugFormTypeNames.Length > 0) { DebugSystem = SystemManager.RegisterSystem(new DebugSystem()); for (int i = 0; i < m_DebugFormTypeNames.Length; ++i) { if (string.IsNullOrEmpty(m_DebugFormTypeNames[i])) { throw new ArgumentNullException("invalid debug form"); } Type debugFormType = Type.GetType(m_DebugFormTypeNames[i]); IDebugForm debugForm = (IDebugForm)Activator.CreateInstance(debugFormType); DebugSystem.RegisterDebugForm(debugForm); } } if (!string.IsNullOrEmpty(m_AudioCreaterTypeName)) { Type createrType = Type.GetType(m_AudioCreaterTypeName); ISounderCreater creater = (ISounderCreater)Activator.CreateInstance(createrType); AudioSystem = SystemManager.RegisterSystem(new AudioSystem(creater)); AudioSystem.MaxSameAudioCount = m_MaxSameAudioCount; AudioSystem.SounderRoot = m_SounderRoot; } EntitySystem = SystemManager.RegisterSystem(new EntitySystem()); if (!string.IsNullOrEmpty(m_SceneLoaderTypeName)) { Type loaderType = Type.GetType(m_SceneLoaderTypeName); ISceneLoader loader = (ISceneLoader)Activator.CreateInstance(loaderType); SceneSystem = SystemManager.RegisterSystem(new SceneSystem(loader)); } }