Ejemplo n.º 1
0
 private void Start()
 {
     m_EventComponent = GameEntry.GetComponent <EventComponent>();
     if (m_EventComponent == null)
     {
         Log.Fatal("[WebRequestComponent.Start] Event component is invalid.");
         return;
     }
     //配置根对象
     if (m_InstanceRoot == null)
     {
         m_InstanceRoot = (new GameObject("Web Request Agent Instances")).transform;
         m_InstanceRoot.SetParent(gameObject.transform);
         m_InstanceRoot.localScale = Vector3.one;
     }
     //添加代理辅助器
     for (int i = 0; i < m_WebRequestAgentHelperCount; i++)
     {
         AddWebRequestAgentHelper(i);
     }
 }
        private void Start()
        {
            //基础组件
            BaseComponent baseComponent = GameEntry.GetComponent <BaseComponent>();

            if (baseComponent == null)
            {
                Log.Fatal("[SceneComponent.Start] Base component is invalid.");
                return;
            }

            //事件组件
            m_EventComponent = GameEntry.GetComponent <EventComponent>();
            if (m_EventComponent == null)
            {
                Log.Fatal("[SceneComponent.Start] Event component is invalid.");
                return;
            }
            //设置资源管理器
            m_SceneManager.SetResourceManager(baseComponent.ResourceManager);
        }
Ejemplo n.º 3
0
        private void Start()
        {
            //获取基础组件
            BaseComponent baseComponent = GameEntry.GetComponent <BaseComponent>();

            if (baseComponent == null)
            {
                Log.Fatal("[ConfigComponent.Start] Base component is invalid -> baseComponent == null.");
                return;
            }

            //获取事件组件
            m_EventComponent = GameEntry.GetComponent <EventComponent>();
            if (m_EventComponent == null)
            {
                Log.Fatal("[ConfigComponent.Start] Event component is invalid -> m_EventComponent == null.");
                return;
            }

            //设置资源管理器
            m_ConfigManager.SetResourceManager(baseComponent.ResourceManager);

            //设置配置辅助器
            ConfigHelperBase configHelper = Helper.CreateHelper <ConfigHelperBase>(m_ConfigHelperTypeName, m_CustomConfigHelper);

            if (configHelper == null)
            {
                Log.Error("[ConfigComponent.Start] Config helper is invalid -> configHelper == null.");
                return;
            }
            configHelper.name = "Config Helper";
            Transform trans = configHelper.transform;

            trans.SetParent(transform);
            trans.localScale = Vector3.one;
            m_ConfigManager.SetConfigHelper(configHelper);
        }
        private void Start()
        {
            BaseComponent baseComponent = GameEntry.GetComponent <BaseComponent>();

            if (baseComponent == null)
            {
                Log.Fatal("[LocalizationComponent.Start] Base component is invalid.");
                return;
            }

            m_EventComponent = GameEntry.GetComponent <EventComponent>();
            if (m_EventComponent == null)
            {
                Log.Fatal("[LocalizationComponent.Start] Event component is invalid.");
                return;
            }

            m_LocalizationManager.SetResourceManager(baseComponent.ResourceManager);    //设置资源加载管理器
            LocalizationHelperBase localizationHelper = Helper.CreateHelper(m_LocalizationHelperTypeName, m_CustomLocalizationHelper);

            if (localizationHelper == null)
            {
                Log.Error("[LocalizationComponent.Start] Can not create localization helper.");
                return;
            }
            localizationHelper.name = "Localization Helper";
            Transform trans = localizationHelper.transform;

            trans.SetParent(this.transform);
            trans.localScale = Vector3.one;

            //设置辅助器
            m_LocalizationManager.SetLocalizationHelper(localizationHelper);
            //设置语言
            m_LocalizationManager.Language = baseComponent.IsEditorResourceMode && baseComponent.EditorLanguage != Language.Unspecified ? baseComponent.EditorLanguage : m_LocalizationManager.SystemLanguage;
        }
        private void Start()
        {
            //事件组件
            m_EventComponent = GameEntry.GetComponent <EventComponent>();
            if (m_EventComponent == null)
            {
                Log.Fatal("[DownloadComponent.Start] Event component is invalid.");
                return;
            }

            //辅助器根对象
            if (m_InstanceRoot == null)
            {
                m_InstanceRoot = new GameObject("Download Agent Instances").transform;
                m_InstanceRoot.SetParent(transform);
                m_InstanceRoot.localScale = Vector3.one;
            }

            //添加配置数量的下载代理辅助器
            for (int i = 0; i < m_DownloadAgentHelperCount; i++)
            {
                AddDownloadAgentHelper(i);
            }
        }
Ejemplo n.º 6
0
        private void Start()
        {
            //基础组件
            BaseComponent baseComponent = GameEntry.GetComponent <BaseComponent>();

            if (baseComponent == null)
            {
                Log.Fatal("[UIComponent.Start] Base component is invalid.");
                return;
            }
            m_UIManager.SetResourceManager(baseComponent.ResourceManager);  //设置资源管理器

            //事件
            m_EventComponent = GameEntry.GetComponent <EventComponent>();
            if (m_EventComponent == null)
            {
                Log.Fatal("[UIComponent.Start] Event component is invalid.");
                return;
            }

            //设置对象池
            m_UIManager.SetObjectPoolManager(GameFrameworkEntry.GetModule <IObjectPoolManager>());
            m_UIManager.InstanceAutoReleaseInterval = m_InstanceAutoReleaseInterval;
            m_UIManager.InstanceCapacity            = m_InstanceCapacity;
            m_UIManager.InstanceExpireTime          = m_InstanceExpireTime;
            m_UIManager.InstancePriority            = m_InstancePriority;

            //界面辅助器
            UIFormHelperBase uiFormHelper = Helper.CreateHelper(m_UIFormHelperTypeName, m_CustomUIFormHelper);

            if (uiFormHelper == null)
            {
                Log.Error("[UIComponent.Start] Can not create UI form helper.");
                return;
            }
            uiFormHelper.name = "UI Form Helper";
            Transform trans = uiFormHelper.transform;

            trans.SetParent(this.transform);
            trans.localScale = Vector3.one;
            m_UIManager.SetUIFormHelper(uiFormHelper);  //设置界面辅助器

            //根对象
            if (m_InstanceRoot == null)
            {
                m_InstanceRoot = (new GameObject("UI Form Instances")).transform;
                m_InstanceRoot.SetParent(gameObject.transform);
                m_InstanceRoot.localScale = Vector3.one;
            }

            m_InstanceRoot.gameObject.layer = LayerMask.NameToLayer("UI");  //设置层

            //添加配置的界面组
            for (int i = 0; i < m_UIGroups.Length; i++)
            {
                if (!AddUIGroup(m_UIGroups[i].Name, m_UIGroups[i].Depth))
                {
                    Log.Warning("[UIComponent.Start] Add UI group '{0}' failure.", m_UIGroups[i].Name);
                    continue;
                }
            }

            UICamera = GetComponentInChildren <Camera>();    //获取UI相机
        }
        private void Start()
        {
            //基础组件
            BaseComponent baseComponent = GameEntry.GetComponent <BaseComponent>();

            if (baseComponent == null)
            {
                Log.Fatal("[ResourceComponent.Start] Base component is invalid -> baseComponent == null.");
                return;
            }
            //事件组件
            m_EventComponent = GameEntry.GetComponent <EventComponent>();
            if (m_EventComponent == null)
            {
                Log.Fatal("[ResourceComponent.Start] Event component is invalid -> m_EventComponent == null.");
                return;
            }
            //资源管理器

            ResourceManager = baseComponent.ResourceManager;
            if (ResourceManager == null)
            {
                Log.Fatal("[ResourceComponent.Start] Resource manager is invalid -> m_ResourceManager == null.");
                return;
            }

            //绑定事件
            ResourceManager.ResourceUpdateStart   += OnResourceUpdateStart;
            ResourceManager.ResourceUpdateChanged += OnResourceUpdateChanged;
            ResourceManager.ResourceUpdateSuccess += OnResourceUpdateSuccess;
            ResourceManager.ResourceUpdateFailure += OnResourceUpdateFailure;

            ResourceManager.SetReadOnlyPath(Application.streamingAssetsPath); //设置只读路径
            if (m_ReadWritePathType == ReadWritePathType.TemporaryCache)
            {
                ResourceManager.SetReadWritePath(Application.temporaryCachePath);
            }
            else
            {
                if (m_ReadWritePathType == ReadWritePathType.Unspecified)
                {
                    m_ReadWritePathType = ReadWritePathType.PersistentData;
                }
                ResourceManager.SetReadWritePath(Application.persistentDataPath);
            }

#if UNITY_EDITOR
            m_IsEditorResourceMode = baseComponent.IsEditorResourceMode;
            if (m_IsEditorResourceMode) //编辑器模式直接返回即可
            {
                return;
            }
#endif

            SetResourceMode(m_ResourceMode);
            ResourceManager.SetDownloadManager(GameFrameworkEntry.GetModule <IDownloadManager>());     //设置下载管理器
            ResourceManager.SetObjectPoolManager(GameFrameworkEntry.GetModule <IObjectPoolManager>()); //设置对象池管理器
            ResourceManager.AssetAutoReleaseInterval    = m_AssetAutoReleaseInterval;
            ResourceManager.AssetCapacity               = m_AssetCapacity;
            ResourceManager.AssetExpireTime             = m_AssetExpireTime;
            ResourceManager.AssetPriority               = m_AssetPriority;
            ResourceManager.ResourceAutoReleaseInterval = m_ResourceAutoReleaseInterval;
            ResourceManager.ResourceCapacity            = m_ResourceCapacity;
            ResourceManager.ResourceExpireTime          = m_ResourceExpireTime;
            ResourceManager.ResourcePriority            = m_ResourcePriority;

            if (m_ResourceMode == ResourceMode.Updatable)
            {
                ResourceManager.UpdatePrefixUri             = m_UpdatePrefixUri;
                ResourceManager.UpdateFileCacheLength       = m_UpdateFileCacheLength;
                ResourceManager.GenerateReadWriteListLength = m_GenerateReadWriteListLength;
                ResourceManager.UpdateRetryCount            = m_UpdateRetryCount;
            }

            //资源辅助器
            m_ResourceHelper = Helper.CreateHelper(m_ResourceHelperTypeName, m_CustomResourceHelper);
            if (m_ResourceHelper == null)
            {
                Log.Error("[ResourceComponent.Start] Can not create resource helper -> m_ResourceHelper == null.");
                return;
            }
            m_ResourceHelper.name = "Resource Helper";
            Transform trans = m_ResourceHelper.transform;
            trans.SetParent(transform);
            transform.localScale = Vector3.one;
            ResourceManager.SetResourceHelper(m_ResourceHelper);

            if (m_InstanceRoot == null)
            {
                m_InstanceRoot = new GameObject("Load Resource Agent Instances").transform;
                m_InstanceRoot.SetParent(transform);
                m_InstanceRoot.localScale = Vector3.one;
            }

            for (int i = 0; i < m_LoadResourceAgentHelperCount; i++)
            {
                AddLoadResourceAgentHelper(i);
            }
        }