Beispiel #1
0
    //场景资源预加载
    public void PreloadSceneAsset(string sceneName, ref PreloadResult preloadResult)
    {
        this.preloadSceneResult = preloadResult;

        //获取预加载的场景数据(现在木有,先不处理)
        List <string> preLoadGOList = null;

        if (preLoadGOList != null && preLoadGOList.Count > 0)
        {
            this.preloadSceneResult.TotalCount += preLoadGOList.Count;
        }

        if (this.preloadSceneResult.TotalCount > 0)
        {
            //资源加载并生成相应预设
            if (preLoadGOList != null)
            {
                IResourceMgr resMgr = GameKernel.Get <IResourceMgr>();
                foreach (string item in preLoadGOList)
                {
                    AssetBundleParams abp = new AssetBundleParams(item, typeof(GameObject));
                    resMgr.LoadNormalObjAsync(abp);
                }
            }
        }
        else
        {
            this.preloadSceneResult = null;
        }
    }
Beispiel #2
0
        /// <summary>
        /// 从Resources中读取数据
        /// </summary>
        private static byte[] ReadFromResources(string fileName)
        {
            IResourceMgr resourceMgr = Framework.GameKernel.GetResourceMgr();

            byte[] streamBytes = resourceMgr.LoadConfigFile("ProtobufDataConfig/" + fileName, "bytes");

            //byte[] streamBytes = null;
            //string filePath = "ProtobufDataConfig/" + fileName;
            //string fileUrl = string.Format("{0}{1}.bytes", BundleConfig.Instance.BundlesPathForPersist, filePath);
            //if (!File.Exists(fileUrl))
            //{
            //    TextAsset asset = Resources.Load<TextAsset>(filePath);
            //    if (asset != null)
            //    {
            //        streamBytes = asset.bytes;
            //    }
            //}
            //else
            //{
            //    using (FileStream fs = new FileStream(fileUrl, FileMode.Open))
            //    {
            //        BinaryReader br = new BinaryReader(fs);
            //        streamBytes = br.ReadBytes((int)fs.Length);
            //    }
            //}

            return(streamBytes);
        }
Beispiel #3
0
 private void Awake()
 {
     this.UpdateMgr   = new UpdateMgr();
     this.resourceMgr = new AssetBundleMgr();
     this.resourceMgr.Init();
     this.UpdateResource();
 }
Beispiel #4
0
        public void Init()
        {
#if UNITY_EDITOR
            mMgr = NativeResourceMgr.Instance;
#else
            mMgr = ABResourceMgr.Instance;
#endif
        }
 public ARMsgListenerThread(ILegacyLogger i_Logger, IResourceMgr i_RM, int i_iThreadIndex, AMSockConns.AMSockConn i_SockConn, MsgQueue[] i_aqAudioIn, AudioOutMsgQueue[] i_aqAudioOut)
 {
     m_Logger       = i_Logger;
     m_iThreadIndex = i_iThreadIndex;
     m_SockConn     = i_SockConn;
     m_RM           = i_RM;
     m_aqAudioIn    = i_aqAudioIn;
     m_aqAudioOut   = i_aqAudioOut;
     m_asSessionIds = new StringCollection();
 }
Beispiel #6
0
        public AudioEngine_srv(ILegacyLogger i_Logger)
        {
            m_Logger   = i_Logger;
            m_SockMsgs = new AMSockData[0];
            m_RM       = new ResourceMgr_local(m_Logger);
            m_aASRs    = new ArrayList();

            m_NumAudioStreams = m_RM.GetMaxSessions();

            CreateAudioRouterSockets();
        }
Beispiel #7
0
    private void InitResourceMgr()
    {
#if UNITY_EDITOR
        this.ResourceMgr = new EditorResourceMgr();
        this.ResourceMgr.Init();
#else
        this.ResourceMgr = new AssetBundleMgr();
        this.ResourceMgr.Init();
#endif

        this.LevelMgr = new LevelMgr(new LevelLoader());
        this.LevelMgr.LoadLevel(LevelMgr.kLevelMapFile);

        this.GameNode.SetActiveEx(true);
    }
Beispiel #8
0
    static void CreateInstance()
    {
        ReleaseObject();

        IResourceMgr resourceMgr = GameKernel.Get <IResourceMgr>();
        Object       resObj      = resourceMgr.LoadNormalObjSync(new AssetBundleParams(mResPath, typeof(GameObject)));

        if (resObj != null)
        {
            GameObject obj = Object.Instantiate(resObj) as GameObject;

            if (Parent != null)
            {
                obj.transform.parent        = Parent.transform;
                obj.transform.localPosition = new Vector3(0f, 0f, 0f);
                obj.transform.localRotation = Quaternion.identity;
                obj.transform.localScale    = Vector3.one;
                RefreshPanelDepth(obj);
            }

            UIAnchor[] m_Anchors = obj.GetComponentsInChildren <UIAnchor>();
            obj.SetActive(false);

            foreach (UIAnchor a in m_Anchors)
            {
                a.uiCamera = UICamera;
                a.gameObject.SetActive(true);
            }

            T component = obj.GetComponent <T>();
            mInstance.Target             = component;
            mInstance.Target.ReleaseType = mCurReleaseType;
            IUIComponentContainer container = Container;
            if (container != null)
            {
                container.SetUIComponent <T>(component);
            }
        }
    }
Beispiel #9
0
    //预加载普通资源
    public void PreloadAsyncAssets(uint sceneId, ref PreloadResult preloadResult)
    {
        //初始化系统
        preloadAsyncAssetsResult = preloadResult;

        IResBinData iResBinData = GameKernel.GetDataCenter().GetResBinData();

        //预加载及预热资源
        List <string> preLoadObjList          = null;
        List <string> PreloadAndPrehotObjList = null;

        if (preLoadObjList != null && preLoadObjList.Count > 0)
        {
            preloadAsyncAssetsResult.TotalCount += preLoadObjList.Count;
        }
        if (PreloadAndPrehotObjList != null && PreloadAndPrehotObjList.Count > 0)
        {
            preloadAsyncAssetsResult.TotalCount += PreloadAndPrehotObjList.Count;
        }

        if (preloadAsyncAssetsResult.TotalCount > 0)
        {
            IResourceMgr resMgr = GameKernel.Get <IResourceMgr>();

            /*if (preLoadObjList != null)
             * {
             *  foreach (string item in preLoadObjList)
             *  {
             *      AssetBundleParams abp =
             *          AssetBundleParamFactory.Create(item);
             *      resMgr.LoadSceneResidentMemoryObjAsync(abp, preloadObjCallBack);
             *  }
             * }
             * if (PreloadAndPrehotObjList != null)
             * {
             *  foreach (string item in PreloadAndPrehotObjList)
             *  {
             *      AssetBundleParams abp = AssetBundleParamFactory.Create(item);
             *      abp.IsPreloadMainAsset = true;
             *
             *      ResLogger.Log("Prelaod " + abp.path + " " + abp.type);
             *
             *      resMgr.LoadSceneResidentMemoryObjAsync(abp, preloadObjCallBack);
             *  }
             * }
             *
             * for (int i = 0; i < diffPreloads.Count; i++)
             * {
             *  if (!string.IsNullOrEmpty(diffPreloads[i]))
             *  {
             *      AssetBundleParams abp = AssetBundleParamFactory.Create(diffPreloads[i]);
             *      abp.IsPreloadMainAsset = true;
             *
             *      ResLogger.Log("Diff Prelaod " + abp.path + " " + abp.type);
             *
             *      resMgr.LoadResidentMemoryObjAsync(abp, preloadObjCallBack);
             *  }
             * }*/
        }
        else
        {
            preloadAsyncAssetsResult = null;
        }
    }
Beispiel #10
0
 public static void Init(IResourceMgr instance)
 {
     impl = instance;
 }
        void initAsset()
        {
            preloadResult = null;
            preloadResult = new PreloadResult();

            GameKernel.CreateForInitData();
            IResourceMgr resourceMgr = GameKernel.Get <IResourceMgr>();
            ResBinData   iResBinData = NewResBinDataForPreLoad();

            //预加载资源,不需要提前获取mainAsset
            List <string> residentGoList        = iResBinData.GetImmortalAssetList(1);
            List <string> residentACList        = iResBinData.GetImmortalAssetList(3);
            List <string> residentTexture2DList = iResBinData.GetImmortalAssetList(5);
            List <string> residentAudioClipList = iResBinData.GetImmortalAssetList(7);
            List <string> residentAnimClipList  = iResBinData.GetImmortalAssetList(9);

            //预加载资源,需要提前获取mainAsset
            List <string> residentPreloadGoList        = iResBinData.GetImmortalAssetList(2);
            List <string> residentPreloadACList        = iResBinData.GetImmortalAssetList(4);
            List <string> residentPreloadTexture2DList = iResBinData.GetImmortalAssetList(6);
            List <string> residentPreloadAudioClipList = iResBinData.GetImmortalAssetList(8);
            List <string> residentPreloadAnimClipList  = iResBinData.GetImmortalAssetList(10);


            if (residentGoList != null && residentGoList.Count > 0)
            {
                this.preloadResult.TotalCount += residentGoList.Count;
            }
            if (residentPreloadGoList != null && residentPreloadGoList.Count > 0)
            {
                this.preloadResult.TotalCount += residentPreloadGoList.Count;
            }
            if (residentACList != null && residentACList.Count > 0)
            {
                this.preloadResult.TotalCount += residentACList.Count;
            }
            if (residentPreloadACList != null && residentPreloadACList.Count > 0)
            {
                this.preloadResult.TotalCount += residentPreloadACList.Count;
            }
            if (residentTexture2DList != null && residentTexture2DList.Count > 0)
            {
                this.preloadResult.TotalCount += residentTexture2DList.Count;
            }
            if (residentPreloadTexture2DList != null && residentPreloadTexture2DList.Count > 0)
            {
                this.preloadResult.TotalCount += residentPreloadTexture2DList.Count;
            }
            if (residentAudioClipList != null && residentAudioClipList.Count > 0)
            {
                this.preloadResult.TotalCount += residentAudioClipList.Count;
            }
            if (residentPreloadAudioClipList != null && residentPreloadAudioClipList.Count > 0)
            {
                this.preloadResult.TotalCount += residentPreloadAudioClipList.Count;
            }
            if (residentAnimClipList != null && residentAnimClipList.Count > 0)
            {
                this.preloadResult.TotalCount += residentAnimClipList.Count;
            }
            if (residentPreloadAnimClipList != null && residentPreloadAnimClipList.Count > 0)
            {
                this.preloadResult.TotalCount += residentPreloadAnimClipList.Count;
            }

            if (residentGoList != null)
            {
                for (int i = 0; i < residentGoList.Count; i++)
                {
                    abp = new AssetBundleParams(residentGoList[i], typeof(GameObject));
                    resourceMgr.LoadResidentMemoryObjAsync(abp);
                }
            }
            if (residentPreloadGoList != null)
            {
                for (int i = 0; i < residentPreloadGoList.Count; i++)
                {
                    abp = new AssetBundleParams(residentPreloadGoList[i], typeof(GameObject));
                    abp.IsPreloadMainAsset = true;
                    resourceMgr.LoadResidentMemoryObjAsync(abp);
                }
            }
            if (residentACList != null)
            {
                for (int i = 0; i < residentACList.Count; i++)
                {
                    abp = new AssetBundleParams(residentACList[i], typeof(RuntimeAnimatorController));
                    resourceMgr.LoadResidentMemoryObjAsync(abp);
                }
            }
            if (residentPreloadACList != null)
            {
                for (int i = 0; i < residentPreloadACList.Count; i++)
                {
                    abp = new AssetBundleParams(residentPreloadACList[i], typeof(RuntimeAnimatorController));
                    abp.IsPreloadMainAsset = true;
                    resourceMgr.LoadResidentMemoryObjAsync(abp);
                }
            }
            if (residentTexture2DList != null)
            {
                for (int i = 0; i < residentTexture2DList.Count; i++)
                {
                    abp = new AssetBundleParams(residentTexture2DList[i], typeof(Texture2D));
                    resourceMgr.LoadResidentMemoryObjAsync(abp);
                }
            }
            if (residentPreloadTexture2DList != null)
            {
                for (int i = 0; i < residentPreloadTexture2DList.Count; i++)
                {
                    abp = new AssetBundleParams(residentPreloadTexture2DList[i], typeof(Texture2D));
                    abp.IsPreloadMainAsset = true;
                    resourceMgr.LoadResidentMemoryObjAsync(abp);
                }
            }
            if (residentAudioClipList != null)
            {
                for (int i = 0; i < residentAudioClipList.Count; i++)
                {
                    abp = new AssetBundleParams(residentAudioClipList[i], typeof(AudioClip));
                    resourceMgr.LoadResidentMemoryObjAsync(abp);
                }
            }
            if (residentPreloadAudioClipList != null)
            {
                for (int i = 0; i < residentPreloadAudioClipList.Count; i++)
                {
                    abp = new AssetBundleParams(residentPreloadAudioClipList[i], typeof(AudioClip));
                    abp.IsPreloadMainAsset = true;
                    resourceMgr.LoadResidentMemoryObjAsync(abp);
                }
            }
            if (residentAnimClipList != null)
            {
                for (int i = 0; i < residentAnimClipList.Count; i++)
                {
                    abp = new AssetBundleParams(residentAnimClipList[i], typeof(AnimationClip));
                    resourceMgr.LoadResidentMemoryObjAsync(abp);
                }
            }
            if (residentPreloadAnimClipList != null)
            {
                for (int i = 0; i < residentPreloadAnimClipList.Count; i++)
                {
                    abp = new AssetBundleParams(residentPreloadAnimClipList[i], typeof(AnimationClip));
                    abp.IsPreloadMainAsset = true;
                    resourceMgr.LoadResidentMemoryObjAsync(abp);
                }
            }

            ReleaseNewResBinData();
        }
 public DialogMgr_srv(ILegacyLogger i_Logger)
 {
     m_Logger     = i_Logger;
     m_RM         = new ResourceMgr_local(m_Logger);
     m_NumDialogs = m_RM.GetMaxSessions();
 }
Beispiel #13
0
 //设置动画播放器关联
 public void SetExtPlayer(IResourceMgr extplayer)
 {
     iextplayer = extplayer;
 }
Beispiel #14
0
 public void Destroy()
 {
     mMgr = null;
 }