Ejemplo n.º 1
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;
            }

            if (baseComponent.EditorResourceMode)
            {
                m_LocalizationManager.SetResourceManager(baseComponent.EditorResourceHelper);
            }
            else
            {
                m_LocalizationManager.SetResourceManager(GameFrameworkEntry.GetModule <IResourceManager>());
            }

            LocalizationHelperBase localizationHelper = Helper.CreateHelper(m_LocalizationHelperTypeName, m_CustomLocalizationHelper);

            if (localizationHelper == null)
            {
                Log.Error("Can not create localization helper.");
                return;
            }

            localizationHelper.name = string.Format("Localization Helper");
            Transform transform = localizationHelper.transform;

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

            m_LocalizationManager.SetLocalizationHelper(localizationHelper);
            m_LocalizationManager.Language = (baseComponent.EditorResourceMode && baseComponent.EditorLanguage != Language.Unspecified ? baseComponent.EditorLanguage : m_LocalizationManager.SystemLanguage);
        }
Ejemplo n.º 2
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;
            }

            if (baseComponent.EditorResourceMode)
            {
                m_DataTableManager.SetResourceManager(baseComponent.EditorResourceHelper);
            }
            else
            {
                m_DataTableManager.SetResourceManager(GameFrameworkEntry.GetModule <IResourceManager>());
            }

            DataTableHelperBase dataTableHelper = Helper.CreateHelper(m_DataTableHelperTypeName, m_CustomDataTableHelper);

            if (dataTableHelper == null)
            {
                Log.Error("Can not create data table helper.");
                return;
            }

            dataTableHelper.name = string.Format("Data Table Helper");
            Transform transform = dataTableHelper.transform;

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

            m_DataTableManager.SetDataTableHelper(dataTableHelper);
        }
        /// <summary>
        /// GameEventArgs 事件注册
        /// </summary>
        /// <param name="self"></param>
        /// <param name="gameEventArgsType"></param>
        /// <param name="handle"></param>
        /// <exception cref="GameFrameworkException"></exception>
        public static void GameEventSubscribe(this EventComponent self, Type gameEventArgsType, EventHandler <GameEventArgs> handle)
        {
            if (!typeof(GameEventArgs).IsAssignableFrom(gameEventArgsType))
            {
                throw new GameFrameworkException($"gameEventArgsType 不是 {typeof(GameEventArgs)} 类型");
            }

            var args = (GameEventArgs)ReferencePool.Acquire(gameEventArgsType);

            if (!self.Check(args.Id, handle))
            {
                self.Subscribe(args.Id, handle);
            }
            else
            {
                GameFrameworkLog.Error($"事件ID:{args.Id},已存在相同的处理函数,无法继续注册.");
            }

            ReferencePool.Release(args);
        }
Ejemplo n.º 4
0
        private void Start()
        {
            _baseComponent = GameEntry.GetComponent <BaseComponent>();
            if (_baseComponent == null)
            {
                Log.Fatal("Base component is invalid.");
                return;
            }
            _eventComponent = GameEntry.GetComponent <EventComponent>();
            if (_eventComponent == null)
            {
                Log.Fatal("Event component is invalid.");
                return;
            }

            m_EditorResourceMode = _baseComponent.EditorResourceMode;
            m_ResourceManager    = m_EditorResourceMode ? _baseComponent.EditorResourceHelper : GameFrameworkEntry.GetModule <IResourceManager>();
            if (m_ResourceManager == null)
            {
                Log.Fatal("Resource manager is invalid.");
                return;
            }
            m_ResourceManager.ResourceInitComplete += OnResourceInitComplete;

            m_ResourceManager.SetReadOnlyPath(Application.streamingAssetsPath);
            if (m_ReadWritePathType == ReadWritePathType.TemporaryCache)
            {
                m_ResourceManager.SetReadWritePath(Application.temporaryCachePath);
            }
            else
            {
                if (m_ReadWritePathType == ReadWritePathType.Unspecified)
                {
                    m_ReadWritePathType = ReadWritePathType.PersistentData;
                }

                m_ResourceManager.SetReadWritePath(Application.persistentDataPath);
            }

            m_ResourceManager.LoadAssetsComplete += _loadAssetsComplete;

            if (m_EditorResourceMode)
            {
                return;
            }

            m_ResourceManager.SetObjectPoolManager(GameFrameworkEntry.GetModule <IObjectPoolManager>());
            m_ResourceManager.AssetAutoReleaseInterval    = m_AssetAutoReleaseInterval;
            m_ResourceManager.AssetCapacity               = m_AssetCapacity;
            m_ResourceManager.AssetExpireTime             = m_AssetExpireTime;
            m_ResourceManager.AssetPriority               = m_AssetPriority;
            m_ResourceManager.ResourceAutoReleaseInterval = m_ResourceAutoReleaseInterval;
            m_ResourceManager.ResourceCapacity            = m_ResourceCapacity;
            m_ResourceManager.ResourceExpireTime          = m_ResourceExpireTime;
            m_ResourceManager.ResourcePriority            = m_ResourcePriority;
            m_ResourceHelper = Helper.CreateHelper(m_ResourceHelperTypeName, m_CustomResourceHelper);
            if (m_ResourceHelper == null)
            {
                Log.Error("Can not create resource helper.");
                return;
            }

            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);
                m_InstanceRoot.localScale = Vector3.one;
            }

            for (int i = 0; i < m_LoadResourceAgentHelperCount; i++)
            {
                AddLoadResourceAgentHelper(i);
            }
        }
 /// <summary>
 /// GameEventArgs 事件释放
 /// </summary>
 /// <param name="self"></param>
 /// <param name="handle"></param>
 /// <typeparam name="T"></typeparam>
 public static void GameEventUnsubscribe <T>(this EventComponent self, EventHandler <GameEventArgs> handle) where T : GameEventArgs, new()
 {
     self.GameEventUnsubscribe(typeof(T), handle);
 }