예제 #1
0
        /// <summary>
        /// 有资源依赖的情况
        /// </summary>
        /// <returns></returns>
        public Object GetPrefabDepend(string assetPath, string extension = IcConfig.EXTENSION_PREFAB)
        {
            string      m_loaderPath = null;
            Object      obj          = null;
            AssetBundle ab           = null;

            if (string.IsNullOrEmpty(assetPath))
            {
                return(null);
            }


            string dir;
            string name;

            CUtil.SplitPath(assetPath, out dir, out name);
            stResourcePath resourcePath = AssetBundleManager.GetResources().GetResourcePath(dir, name, extension);

            if (!AssetBundleManager.Instance.m_isLocaAsset)
            {
                if (resourcePath.asset != null)
                {
                    //(assetbundle 已经异步load好了)
                    obj = resourcePath.asset;
                }
                else if (resourcePath.bAssetbundle)
                {
                    string path = resourcePath.path;
                    AssetBundleManager.GetAssetBundleManager().LoadAssetSynchronization(path, resourcePath.ver, name, typeof(Object), out obj, out ab);
                    if (!m_loadAb.Contains(resourcePath.path) && ab != null)
                    {
                        m_loadAb.Add(resourcePath.path);
                    }
                }
                else
                {
                    string path = resourcePath.AssetPath;
                    AssetBundleManager.GetAssetBundleManager().LoadAssetSynchronization(path, resourcePath.ver, name, typeof(Object), out obj, out ab);
                    if (!m_loadAb.Contains(resourcePath.path) && ab != null)
                    {
                        m_loadAb.Add(resourcePath.path);
                    }
                }
            }
            else
            {
                string path = IcResources.GetEditorAssetResourcePath(dir, name, extension);
                #if UNITY_EDITOR
                obj = AssetDatabase.LoadAssetAtPath(path, typeof(Object));
                #endif

                if (obj == null)
                {
                    //同步
                    path = IcResources.GetEditorResourcePath(dir, name, extension);
                    obj  = Resources.Load(path, typeof(Object));
                }
            }
            return(obj);
        }
예제 #2
0
        public override void DoStartLoad()//public override void StartLoad()
        {
            if (m_loadedCallback == null)
            {
                return;
            }

            /*
             * if (m_name == "fmz2jx_atk0")
             * {
             *   int iu = 0;
             *   iu++;
             * }*/
            string strNewFile = string.Empty;

            //if (MyTxtResources.GetTmpActorsFile(m_name, out strNewFile))//m_bTestRole)
            //{
            //    string pathOk = IcResources.GetPersistentDataPath_FileStream() + "actors/" + strNewFile;//IcResources.GetPersistentDataPath_WWW() + assetbundlePath;
            //    m_path = pathOk;
            //    LoadAssetbundleDirectly(pathOk, strNewFile, typeof(Object));

            //    return;
            //}
            //IcChangeFiles pChangeFile = MyTxtResources.GetChangeFile(m_name);
            //if (pChangeFile != null)
            //{
            //    m_name = pChangeFile.fileName;
            //    m_dir = pChangeFile.path;
            //}
            stResourcePath resourcePath = AssetBundleManager.GetResources().GetResourcePath(m_dir, m_name, m_extension);

            if (!AssetBundleManager.Instance.m_isLocaAsset)
            {
                if (resourcePath.asset != null)
                {
                    //(assetbundle 已经异步load好了)
                    Loaded(resourcePath.asset, resourcePath.path);
                }
                else if (resourcePath.bAssetbundle)
                {
                    StartCoroutine(LoadAssetBundle(resourcePath.path, resourcePath.ver, !loadLowPriority));
                }
                else
                {
                    if (loadLowPriority)
                    {
                        StartCoroutine(LoadResourceAssetAsync(resourcePath.path));
                    }
                    else
                    {
                        AssetBundleManifest m_AssetBundleManifest = AssetBundleManager.GetAssetBundleManager().m_AssetBundleManifest;
                        if (m_AssetBundleManifest == null)
                        {
                            Object asset = null;
                            string path  = resourcePath.path;
                            asset = Resources.Load(path, typeof(Object));
                            if (asset == null)
                            {
                                Debug.LogError("ResourceLoad Error:" + path);
                            }
                            Loaded(asset, path);
                        }
                        else
                        {
                            StartCoroutine(LoadAssetBundle(resourcePath.AssetPath, resourcePath.ver, !loadLowPriority));
                        }
                    }
                }
            }
            else
            {
                Object obj = null;

                string path = IcResources.GetEditorAssetResourcePath(m_dir, m_name, m_extension);
#if UNITY_EDITOR
                obj = AssetDatabase.LoadAssetAtPath(path, typeof(Object));
#endif

                if (obj == null)
                {
                    //同步
                    path = IcResources.GetEditorResourcePath(m_dir, m_name, m_extension);
                    obj  = Resources.Load(path, typeof(Object));
                }

                Loaded(obj, path);
            }
        }