Пример #1
0
    public static void UnloadAllAudioClip()
    {
        foreach (var item in audioClipBuffer)
        {
            AssetCacheMgr.ReleaseResource(item.Value);
        }

        audioClipBuffer.Clear();
    }
Пример #2
0
        /// <summary>
        /// 释放场景资源。
        /// </summary>
        public void UnloadScene(Action callBack)
        {
            if (m_currentMap != null)
            {
                try
                {
                    BillboardViewManager.Instance.Clear();
                    MogoFXManager.Instance.RemoveAllShadow();
                }
                catch (Exception ex)
                {
                    Debug.LogException(ex);
                }
                foreach (var item in m_sceneObjects)
                {
                    //AssetCacheMgr.UnloadAsset(item);
                    AssetCacheMgr.ReleaseInstance(item);
                }
                m_sceneObjects.Clear();
                AssetCacheMgr.ReleaseResource(m_lightmap);
                m_lightmap = null;
                AssetCacheMgr.ReleaseResource(m_lightProbes);
                m_lightProbes = null;
                StoryManager.Instance.ClearPreload();
                SubAssetCacheMgr.ReleaseCharacterResources();
                SubAssetCacheMgr.ReleaseGearResources();
                SfxHandler.UnloadAllFXs();
                if (!String.IsNullOrEmpty(m_lastSceneResourceName))
                {
                    AssetCacheMgr.ReleaseResource(m_lastSceneResourceName);
                }
                //ResourceManager.UnloadUnusedAssets();
                //GC.Collect();
                if (callBack != null)
                {
                    callBack();
                }

                //Debug.LogError("StartCoroutine UnloadUnusedAssets");
                //Driver.Instance.StartCoroutine(UnloadUnusedAssets(() =>
                //{
                //    //Debug.LogError("UnloadUnusedAssets finish");
                //    GC.Collect();
                //    if (callBack != null)
                //        callBack();
                //}));
            }
            else
            {
                if (callBack != null)
                {
                    callBack();
                }
            }
        }
Пример #3
0
    /// <summary>
    /// 设置副本评价
    /// </summary>
    /// <param name="num"></param>
    public void ShowPassStar(int num)
    {
        Mogo.Util.LoggerHelper.Debug("ShowPassStar: " + num);
        string texName = "";

        switch ((InstanceStar)num)
        {
        case InstanceStar.InstanceStarS:
        {
            texName = "fb-ds.png";
        }
        break;

        case InstanceStar.InstanceStarA:
        {
            texName = "fb-da.png";
        }
        break;

        case InstanceStar.InstanceStarB:
        {
            texName = "fb-db.png";
        }
        break;

        case InstanceStar.InstanceStarC:
        {
            texName = "fb-dc.png";
        }
        break;

        default:
        {
            texName = "";
        }
        break;
        }

        if (m_texInstancePassUIStarType != null)
        {
            if (m_texInstancePassUIStarType.mainTexture != null)
            {
                AssetCacheMgr.ReleaseResource(m_texInstancePassUIStarType.mainTexture);
            }

            if (!string.IsNullOrEmpty(texName))
            {
                AssetCacheMgr.GetUIResource(texName, (obj) =>
                {
                    if (obj != null)
                    {
                        m_texInstancePassUIStarType.mainTexture = obj as Texture;
                    }
                });
                m_texInstancePassUIStarType.gameObject.SetActive(true);
                m_bShowStar = true;
            }
            else
            {
                m_texInstancePassUIStarType.gameObject.SetActive(false);
                m_bShowStar = false;
            }
        }
    }
Пример #4
0
        public void Equip(int _equipId)
        {
            if (Transform == null)
            {
                return;
            }
            System.Diagnostics.Stopwatch stopWatch = new System.Diagnostics.Stopwatch();
            stopWatch.Start();

            if (!ItemEquipmentData.dataMap.ContainsKey(_equipId))
            {
                LoggerHelper.Error("can not find equip:" + _equipId);
                return;
            }
            ItemEquipmentData equip = ItemEquipmentData.dataMap[_equipId];

            if (equip.mode > 0)
            {
                if (Actor == null)
                {
                    return;
                }
                Actor.m_isChangingWeapon = true;
                Actor.Equip(equip.mode);
                if (equip.type == (int)EquipType.Weapon)
                {
                    ControllerOfWeaponData    controllerData = ControllerOfWeaponData.dataMap[equip.subtype];
                    RuntimeAnimatorController controller;
                    if (animator == null)
                    {
                        return;
                    }
                    string controllerName = (MogoWorld.inCity ? controllerData.controllerInCity : controllerData.controller);
                    if (animator.runtimeAnimatorController != null)
                    {
                        if (animator.runtimeAnimatorController.name == controllerName)
                        {
                            return;
                        }
                        AssetCacheMgr.ReleaseResource(animator.runtimeAnimatorController);
                    }

                    AssetCacheMgr.GetResource(controllerName,
                                              (obj) =>
                    {
                        controller = obj as RuntimeAnimatorController;
                        if (animator == null)
                        {
                            return;
                        }
                        animator.runtimeAnimatorController = controller;
                        if (this is EntityMyself)
                        {
                            (this as EntityMyself).UpdateSkillToManager();
                            EventDispatcher.TriggerEvent <int, int>(InventoryEvent.OnChangeEquip, equip.type, equip.subtype);
                        }
                        if (this is EntityPlayer)
                        {
                            if (MogoWorld.inCity)
                            {
                                animator.SetInteger("Action", -1);
                            }
                            else
                            {
                                animator.SetInteger("Action", 0);
                            }
                            if (MogoWorld.isReConnect)
                            {
                                ulong s   = stateFlag;
                                stateFlag = 0;
                                stateFlag = s;
                            }
                        }
                    });
                }

                stopWatch.Stop();

                //if (!isCreatingModel)
                //{
                //    SetPosition();
                //    stopWatch.Start();
                //    //AssetCacheMgr.ReleaseInstance(GameObject);
                //    CreateActualModel();
                //    stopWatch.Stop();
                //    Mogo.Util.LoggerHelper.Debug("CreateModel:" + stopWatch.Elapsed.Milliseconds);

                //}
            }
        }