コード例 #1
0
        private void AddLoadResourceAgentHelper(int index)
        {
            LoadResourceAgentHelperBase loadResourceAgentHelper = Helper.CreateHelper(m_LoadResourceAgentHelperTypeName, m_CustomResourceHelper, index);

            if (loadResourceAgentHelper == null)
            {
                return;
            }

            loadResourceAgentHelper.name = string.Format("Load resource Agent Helper - {0}", index.ToString());
            Transform transform = loadResourceAgentHelper.transform;

            transform.SetParent(m_InstanceRoot);
            transform.loacalScale = Vector3.one;

            m_ResourceManager.AddLoadResourceAgentHelper(laodResourceAgentHelper);
        }
コード例 #2
0
        /// <summary>
        /// 增加加载资源代理辅助器。
        /// </summary>
        /// <param name="index">加载资源代理辅助器索引。</param>
        private void AddLoadResourceAgentHelper(int index)
        {
            LoadResourceAgentHelperBase loadResourceAgentHelper = Helper.CreateHelper(m_LoadResourceAgentHelperTypeName, m_CustomLoadResourceAgentHelper, index);

            if (loadResourceAgentHelper == null)
            {
                Log.Error("Can not create load resource agent helper.");
                return;
            }

            loadResourceAgentHelper.name = Utility.Text.Format("Load Resource Agent Helper - {0}", index.ToString());
            Transform transform = loadResourceAgentHelper.transform;

            transform.SetParent(m_InstanceRoot);
            transform.localScale = Vector3.one;

            m_ResourceManager.AddLoadResourceAgentHelper(loadResourceAgentHelper);
        }
コード例 #3
0
        private void Start()
        {
            BaseComponent baseComponent = GameEntry.GetComponent <BaseComponent>();

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

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

            bool useEditorResources = baseComponent.EditorResourceMode;

            m_ResourceManager = useEditorResources ? baseComponent.EditorResourceHelper : GameFrameworkEntry.GetModule <IResourceManager>();
            if (m_ResourceManager == null)
            {
                Log.Fatal("Resource manager is invalid.");
                return;
            }

            m_ResourceManager.ResourceInitComplete      += OnResourceInitComplete;
            m_ResourceManager.VersionListUpdateSuccess  += OnVersionListUpdateSuccess;
            m_ResourceManager.VersionListUpdateFailure  += OnVersionListUpdateFailure;
            m_ResourceManager.ResourceCheckComplete     += OnResourceCheckComplete;
            m_ResourceManager.ResourceUpdateStart       += OnResourceUpdateStart;
            m_ResourceManager.ResourceUpdateChanged     += OnResourceUpdateChanged;
            m_ResourceManager.ResourceUpdateSuccess     += OnResourceUpdateSuccess;
            m_ResourceManager.ResourceUpdateFailure     += OnResourceUpdateFailure;
            m_ResourceManager.ResourceUpdateAllComplete += OnResourceUpdateAllComplete;

            m_ResourceManager.SetReadOnlyPath(Application.streamingAssetsPath);
            m_ResourceManager.SetReadWritePath(Application.temporaryCachePath);

            if (!useEditorResources)
            {
                SetResourceMode(m_ResourceMode);
                m_ResourceManager.SetDownloadManager(GameFrameworkEntry.GetModule <IDownloadManager>());
                m_ResourceManager.SetObjectPoolManager(GameFrameworkEntry.GetModule <IObjectPoolManager>());
                m_ResourceManager.ResourceCapacity = m_ResourceCapacity;
                if (m_ResourceMode == ResourceMode.Updatable)
                {
                    m_ResourceManager.UpdateRetryCount = m_UpdateRetryCount;
                }

                if (m_ResourceHelper == null)
                {
                    m_ResourceHelper      = (new GameObject()).AddComponent <DefaultResourceHelper>();
                    m_ResourceHelper.name = string.Format("Resource Helper");
                    Transform transform = m_ResourceHelper.transform;
                    transform.SetParent(this.transform);
                    transform.localScale = Vector3.one;
                }

                m_ResourceManager.SetResourceHelper(m_ResourceHelper);

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

                for (int i = 0; i < m_LoadResourceAgentHelperCount; i++)
                {
                    LoadResourceAgentHelperBase helper = null;
                    if (m_LoadResourceAgentHelperTemplate != null)
                    {
                        helper = Instantiate(m_LoadResourceAgentHelperTemplate);
                    }
                    else
                    {
                        helper = (new GameObject()).AddComponent <DefaultLoadResourceAgentHelper>();
                    }

                    helper.name = string.Format("Load Resource Agent Helper - {0}", i.ToString());
                    Transform transform = helper.transform;
                    transform.SetParent(m_InstanceRoot);
                    transform.localScale = Vector3.one;
                    m_ResourceManager.AddLoadResourceAgentHelper(helper);
                }
            }
        }