LogError() public static method

public static LogError ( object message ) : void
message object
return void
Ejemplo n.º 1
0
    public T GetDuplicate(string name)
    {
        if (!foundTemplates)
        {
            FindTemplates();
        }

        if ((!ExistsTemplate(name)) || (templates[name] == null))
        {
            DebugConsole.LogError("Not found template with name '" + name + "'");
        }

        T duplicate;

        if ((cache.ContainsKey(name)))
        {
            duplicate = cache[name];
        }
        else
        {
            duplicate = UnityEngine.Object.Instantiate(templates[name]) as T;

            duplicate.TemplateName = name;
            duplicate.IsTemplate   = false;

            if (onCreateCallback != null)
            {
                onCreateCallback(duplicate);
            }
        }

        return(duplicate);
    }
Ejemplo n.º 2
0
    public static void Init()
    {
        VersionObj version = Resources.Load <VersionObj>("RawConfig/Version");

        if (version == null)
        {
            DebugConsole.LogError("Can't Load Version Object!");
            open = false;
            return;
        }

        open = version.Open_Version;

        if (open)
        {
            Main_Version_Number = version.Main_Version_Number;
            DebugConsole.Log("程序主版本号为:" + Main_Version_Number, DebugConsole.Color.blue);
            DebugConsole.Log("本地主版本号为:" + GetLocalMainVersionNum(), DebugConsole.Color.blue);
            Asset_Version_Number = version.Asset_Version_Number;
            DebugConsole.Log("程序资源版本号为:" + Asset_Version_Number, DebugConsole.Color.blue);
            DebugConsole.Log("本地资源版本号为:" + GetLocalAssetVersionNum(), DebugConsole.Color.blue);
        }
        else
        {
            DebugConsole.Log("未开启程序版本号控制");
        }
    }
Ejemplo n.º 3
0
    public void Spawn(string prefabName, UnityAction <PrefabPoolAgent> callback)
    {
        ObjectPool <PrefabPoolAgent> pool;

        if (!poolDict.ContainsKey(prefabName))
        {
            pool = new ObjectPool <PrefabPoolAgent>(prefabName, DefaultPoolSize);
            poolDict.Add(prefabName, pool);
        }
        else
        {
            pool = poolDict[prefabName];
        }

        if (pool == null)
        {
            DebugConsole.LogError("无法获取对象池:" + prefabName);
            return;
        }

        var agent = pool.Get(this);

        if (agent.IsExistEntity)
        {
            callback(agent);
        }
        else
        {
            agent.callback = callback;
        }
    }
Ejemplo n.º 4
0
    /// <summary>
    /// 下载依赖
    /// </summary>
    protected void LoadDependencies(string assetBundleName)
    {
        if (_assetBundleManifest == null)
        {
            DebugConsole.LogError("Please initialize AssetBundleManifest by calling AssetBundleManager.Initialize()");
            return;
        }

        string[] dependencies = _assetBundleManifest.GetAllDependencies(assetBundleName);
        if (dependencies.Length == 0)
        {
            return;
        }

        for (int i = 0; i < dependencies.Length; i++)
        {
            dependencies[i] = RemapVariantName(dependencies[i]);
        }

        _dependencies.Add(assetBundleName, dependencies);
        for (int i = 0; i < dependencies.Length; i++)
        {
            DownloadAssetBundleInternal(dependencies[i], false);
        }
    }
Ejemplo n.º 5
0
    static IEnumerator MoveFile(string url, string filePath, Action callback)
    {
        WWW www = new WWW(url);

        yield return(www);

        if (!string.IsNullOrEmpty(www.error))
        {
            DebugConsole.LogError("www error = " + www.error + "\r\n" + url);
            yield break;
        }

        if (File.Exists(filePath))
        {
            File.Delete(filePath);
        }

        FileStream fs    = File.Create(filePath);
        MoveState  state = new MoveState();

        state.fs       = fs;
        state.www      = www;
        state.callback = callback;
        fs.BeginWrite(www.bytes, 0, www.bytes.Length, new AsyncCallback(MoveCallBack), state);
        DebugConsole.Log("Begin Move Path To " + filePath);
    }
    void Start()
    {
        app = AppController.instance;

        if (moveCam == jumpToCam)
        {
            DebugConsole.LogError("You can't jump to and move a cam at the same time.");
        }

        box_X = (Screen.width / 2) - (width / 2);
        box_Y = (Screen.height / 2) - (height / 2);        //+ boxHeightOffset;

        button_X = (width / 2) - (buttonWidth / 2);
        //button_Y = box_Y - buttonHeight - 5;

        infoWindow = new Rect(box_X, box_Y, width, height);

        allInfos = GameObject.FindObjectsOfType <Information>();

        doorTrigger = gameObject.GetComponent <DoorTrigger> ();

        if (null != XRayMenuObject)
        {
            xRayMenu = XRayMenuObject.GetComponent <XRayMachineMenu> ();
        }
    }
Ejemplo n.º 7
0
        public void Update()
        {
            try {
                multiplayerManager.Update();
            } catch (System.Exception e) {
                DebugConsole.LogError(e.ToString());
            }

            if (LazySingletonBehavior <DebugConsole> .HasInstance)
            {
                if (!hasAdded)
                {
                    LazySingletonBehavior <DebugConsole> .Instance.enabled = true;
                    debugConsole = LazySingletonBehavior <DebugConsole> .Instance;
                    DebugConsole.CaptureUnityLogs = true;
                    debugConsole.gameObject.AddComponent <DebugConsoleHelper>();
                    hasAdded = true;
                }
            }
            else
            {
                hasAdded = false;
            }

            UpdateCurrentCell();
            // UpdateMods();
        }
Ejemplo n.º 8
0
	//from the client
	public void SendServerMess( NetworkClient.MessType_ToServer messType, string args )
	//public void SendServerMess( NetworkClient.MessType messType, string args )
	{
		DebugConsole.LogWarning( "Sending message to server: " + messType.ToString() );
		if( args != null && args.Length > 0 ) DebugConsole.Log( "args: " + args );
		
		if( Network.isClient ) 
		{
			
			//DebugConsole.LogWarning("network: " + Network.peerType);

			if( args != null && args.Length > 0 )
			{	
				//DebugConsole.Log( "  args - [" + string.Join(",",args) + "]" );
				//networkView.RPC("ToServerWString", RPCMode.Server, networkView.viewID, messType, string.Join(",",args) );
				networkView.RPC("ToServerWString", RPCMode.Server, networkView.viewID, (int)messType, args );
			}
			else
			{
				//DebugConsole.LogWarning( "null or zero length arguments to SendServerMess." );	
				networkView.RPC("ToServerNoArgs", RPCMode.Server, networkView.viewID, (int)messType );
			}
			//DebugConsole.LogWarning( "Done sending message to server." );			
		}
		else{
			DebugConsole.LogError( "Did not send server mess, because I AM THE SERVER." );
		}
	}
Ejemplo n.º 9
0
    void OnMasterServerEvent(MasterServerEvent mse)
    {
        switch (mse)
        {
        case MasterServerEvent.HostListReceived:
            DebugConsole.Log("NetworkServer.OnMasterServerEvent( mse ): HostListReceived");
            break;

        case MasterServerEvent.RegistrationFailedGameName:
            DebugConsole.LogError("NetworkServer.OnMasterServerEvent( mse ): RegistrationFailedGameName");
            break;

        case MasterServerEvent.RegistrationFailedGameType:
            DebugConsole.LogError("NetworkServer.OnMasterServerEvent( mse ): RegistrationFailedGameType");
            break;

        case MasterServerEvent.RegistrationFailedNoServer:
            DebugConsole.LogError("NetworkServer.OnMasterServerEvent( mse ): RegistrationFailedNoServer");
            break;

        case MasterServerEvent.RegistrationSucceeded:
            DebugConsole.Log("NetworkServer.OnMasterServerEvent( mse ): RegistrationSucceeded");
            //NetworkViewID viewID = Network.AllocateViewID();
            //DebugConsole.Log( "ViewID:" + networkView.viewID );
            //DebugConsole.Log( "group:" + networkView.group );
            //DebugConsole.Log("Sending spawnbox from server.");
            //networkView.RPC( "SpawnBox", RPCMode.AllBuffered, viewID, transform.position);
            break;

        default:
            break;
        }
    }
Ejemplo n.º 10
0
	//returns false if couldn't connect
	public bool ConnectToFirstAvailable()
	{
		bool successful = false;
		HostData[] data = MasterServer.PollHostList();
	    // Go through all the hosts in the host list
	    foreach (HostData element in data)
	    {
	       //string name = element.gameName + " " + element.connectedPlayers + " / " + element.playerLimit;
	       string hostInfo;
	       hostInfo = "[";
	       foreach (string host in element.ip)
	         hostInfo = hostInfo + host + ":" + element.port + " ";
	       hostInfo = hostInfo + "]";

	         // Connect to HostData struct, internally the correct method is used (GUID when using NAT).
	 
			DebugConsole.Log("Connecting..." + hostInfo);
			NetworkConnectionError error = Network.Connect(element);
			if (error != NetworkConnectionError.NoError)
			{
				DebugConsole.LogError("Failed to connect " + error);
				successful = false;
			}
			else
			{
				DebugConsole.Log("network: " + Network.peerType);
				successful = true;
			}
			DebugConsole.Log("Done attempting to connect");
			
	    }
		return successful;
	}
Ejemplo n.º 11
0
    IEnumerator OnLoadAsset <T>(string abname, string assetName, Action <T> func)
        where T : UnityEngine.Object
    {
        // Load asset
        string abName = abname.ToLower() + "." + Global.BundleExtName;
        AssetBundleOperation request = this.LoadAssetAsync(abName, assetName, typeof(T));

        if (request == null)
        {
            yield break;
        }
        yield return(StartCoroutine(request));

        // Get asset
        T prefab = request.GetAsset <T>();

        if (func != null)
        {
            func(prefab);
        }
        else
        {
            DebugConsole.LogError("assetbundle load failed:" + "bundle[" + abname + "]" + "  asset[" + assetName + "]");
        }
    }
Ejemplo n.º 12
0
    /// <summary>
        /// 更新资源
        /// </summary>
    private void UpdateAssets(string version)
    {
        if (!isConfigureUpadate ||
            NeedUpadteAsstesPathName == null)
        {
            downloadAssetsDone = true;
            DebugConsole.Log(string.Format("本地 version =({0})资源已是最新,不需要更新。", Version.GetLocalAssetVersionNum()), DebugConsole.Color.green);
            return;//不需要更新,返回
        }

        if (NeedUpadteAsstesPathName.Count == 0)
        {//下载任务完成,返回
            UpdateLocalConfigInfo(version);
            downloadAssetsDone = true;
            DebugConsole.Log(string.Format("本地 version =({0})资源更新完毕。", Version.GetLocalAssetVersionNum()), DebugConsole.Color.green);
            return;
        }

        string tempPath = NeedUpadteAsstesPathName.Pop();

        _mono.StartCoroutine(Download(ServerPath + tempPath, ServerDic[tempPath].length, delegate(WWW www)
        {
            ReplaceAssets(LocalPath + tempPath, www.bytes);
            UpdateAssets(version);
        }, 60000, () =>
        {       //单文件下载失败
                //todo 日后做断点续传
            DebugConsole.LogError("下载资源文件失败,请检查您的网络状况!");
            _mono.StopAllCoroutines();       //停止全部Coroutinues
            downloadAssetsDone = true;       //暂时进游戏
        }));
    }
Ejemplo n.º 13
0
    //受信スレッド
    private void ReceiveData()
    {
        //udpクライアント設定
        udpClient = new UdpClient(port);

        while (threadAvairable)
        {
            try
            {
                if (udpClient.Available > 0)
                {
                    IPEndPoint ipEndPoint = new IPEndPoint(IPAddress.Any, 0);
                    byte[]     data       = udpClient.Receive(ref ipEndPoint);

                    recievedDataStr = Encoding.UTF8.GetString(data);
                    isDataRecieved  = true;
                }
            }
            catch (Exception err)
            {
                Debug.LogError(err.Message);
                DebugConsole.LogError(err.Message);
                break;
            }
        }
    }
Ejemplo n.º 14
0
        /// <summary>
        /// 下载本地的资源的依赖信息
        /// </summary>
        /// <returns></returns>
        IEnumerator DownloadManifest(string loadManifest)
        {
            if (manifest != null)
            {
                yield break;
            }

            string url = loadManifest;

            if (!url.Contains("file://"))
            {
                url = "file://" + url;
            }

            WWW www = new WWW(url);

            yield return(www);

            if (string.IsNullOrEmpty(www.error))
            {
                AssetBundle bundle = www.assetBundle;
                //DebugConsole.Log("loaded manifest file name = " + bundle.ToString());
                //获取AssetBundle的依赖关系印象
                manifest = bundle.LoadAsset <AssetBundleManifest>("AssetBundleManifest");
            }
            else
            {
                DebugConsole.LogError("WWW Error = " + www.error);
            }
        }
Ejemplo n.º 15
0
    void Send(byte[] payload)
    {
        using (MemoryStream ms = new MemoryStream())
        {
            ms.Position = 0;

            var packetLen = (payload.Length + PACKET_BYTELENGTH);

            BinaryWriter bw = new BinaryWriter(ms);
            bw.Write((UInt16)packetLen);
            bw.Write(payload);
            bw.Flush();
            bw.Close();

            if (client != null && client.Connected)
            {
                byte[] packet = ms.ToArray();
                sendStream.BeginWrite(packet, 0, packet.Length, new AsyncCallback(OnWrite), null);
            }
            else
            {
                DebugConsole.LogError("client connect failed");
            }
        }
    }
Ejemplo n.º 16
0
 public object GetLShapObject()
 {
     if (lShapObject == null)
     {
         DebugConsole.LogError("Get LShapObject is null:" + name);
     }
     return(lShapObject);
 }
Ejemplo n.º 17
0
	void OnDisconnectedFromServer(NetworkDisconnection info)
	{
	    if (info == NetworkDisconnection.LostConnection)
	       DebugConsole.LogError("Lost connection to the server");
	    else
	       DebugConsole.Log("Successfully disconnected from the server");
        GameStateClient.Instance.isConnected = false; //Network.peerType == NetworkPeerType.Disconnected
	}
Ejemplo n.º 18
0
 public void SetLShapObject(object lObject)
 {
     if (lObject == null)
     {
         DebugConsole.LogError("Set LShapObject is null:" + name);
     }
     lShapObject = lObject;
 }
Ejemplo n.º 19
0
        /// <summary>
        /// 加载资源集合
        /// </summary>
        /// <returns></returns>
        IEnumerator RealLoad(string assetBundle, System.Action callback, bool loadCommon = false)
        {
            yield return(DownloadManifest(PUBLIC_PATH_DEFINE.AssetBundlesManifestPath));

            if (manifest == null)
            {
                DebugConsole.LogError("BundleAssetProvider Error : Can't Load AssetBundle Manifest\r\nFile Path = " + PUBLIC_PATH_DEFINE.AssetBundlesManifestPath);
                yield break;
            }
            string[] allToLoad = GetAllBundlesOrderByDependency(assetBundle);
            DebugConsole.Log("all to load length = " + allToLoad.Length, DebugConsole.Color.yellow);
            foreach (string toLoad in allToLoad)
            {
                if (CheckBundleLoaded(toLoad))      //不要重复加载同一AssetBundle
                {
                    continue;
                }

                DebugConsole.Log("bundleName = " + toLoad, DebugConsole.Color.green);
                string  url  = urlbase + toLoad;
                Hash128 hash = manifest.GetAssetBundleHash(toLoad);
                WWW     www  = WWW.LoadFromCacheOrDownload(url, hash);
                yield return(www);

                if (string.IsNullOrEmpty(www.error))
                {
                    AssetBundle bundle = www.assetBundle;

                    if (!loadCommon)
                    {
                        packageBundles.Add(toLoad, bundle);
                    }
                    else
                    {
                        commonBundles.Add(toLoad, bundle);
                    }
                }
                else
                {
                    DebugConsole.LogError("RealLoad AssetBundle => WWW Error = " + www.error);
                }
            }

            if (callback != null)
            {
                try
                {
                    DebugConsole.Log("Load All Bundles Done!");
                    callback.Invoke();
                }
                catch (System.Exception ex)
                {
                    DebugConsole.LogError("Load Bundles Invoke Error!");
                    DebugConsole.LogError(ex.Message);
                    DebugConsole.LogError(ex.StackTrace);
                }
            }
        }
Ejemplo n.º 20
0
    public T Get(string name)
    {
        if (!Exists(name))
        {
            DebugConsole.LogError("Not found template with name '" + name + "'");
        }

        return(templates[name]);
    }
Ejemplo n.º 21
0
    /// <summary>
    /// 取Model 不能使用再脚本程序中
    /// </summary>
    /// <param name="size"></param>
    /// <returns></returns>
    public static T GetModel <T>() where T : ModelBase
    {
        if (Global.ModelManager.GetModel <T>() == null)
        {
            //TODO: 错误信息输出
            DebugConsole.LogError("GetModelError:");
        }

        return(Global.ModelManager.GetModel <T>());
    }
Ejemplo n.º 22
0
        /// <summary>
        /// 检测资源更新
        /// </summary>
        public void CheckUpdate(Action callback)
    {
        downloadCallback = callback;
        _mono.StartCoroutine(Download("file://" + LocalPath + ConfigurePathName, -1, delegate(WWW LocalPathwww)
        {
            //解析本地Assets
            if (LocalPathwww != null)
            {
                SaveConfigure(LocalPathwww.text, LocalDic);
            }

            //下载远程Assets并比较
            _mono.StartCoroutine(Download(ServerPath + ConfigurePathName, -1, delegate(WWW ServerPathwww)
            {
                serverXML = new XmlDocument();
                serverXML.LoadXml(ServerPathwww.text);
                totalBundleLength = long.Parse(serverXML.DocumentElement.GetAttribute("TotalLength"));
                //DebugConsole.Log("server bundle total length = " + ((float)totalBundleLength / 1024).ToString("0.00") + "KB");
                string version = SaveConfigure(ServerPathwww.text, ServerDic);
                if (!Version.CheckAssetVersionNum(version))
                {
                    //计算需要下载的文件
                    CalculationUpdateInfo();

                    //开始下载更新资源
                    downloadFlag       = true;
                    downloadAssetsDone = false;
                    UpdateAssets(version);
                }
                else
                {         //不需要更新资源
                    InvokeDoneCallback();
                }
            },
                                          10000, () =>
            {         //error callback
                      //暂时先进游戏
                downloadFlag       = true;
                downloadAssetsDone = true;
                _mono.StopAllCoroutines();
                DebugConsole.LogError("更新文件下载失败,请检查您的网络状况。");
                //DebugConsole.LogError("error call back!");
            }));
        },
                                      10000, () =>
        {       //error callback
            //暂时先进游戏
            downloadFlag       = true;
            downloadAssetsDone = true;
            _mono.StopAllCoroutines();
            DebugConsole.LogError("本地文件加载失败");
            //DebugConsole.LogError("error call back!");
        }));
    }
Ejemplo n.º 23
0
 public void UpdateMods()
 {
     foreach (ATMod mod in ATModManager.loadedMods)
     {
         try {
             mod.Update();
         } catch (System.Exception e) {
             DebugConsole.LogError(e.ToString());
         }
     }
 }
Ejemplo n.º 24
0
 void OnWrite(IAsyncResult r)
 {
     try
     {
         sendStream.EndWrite(r);
     }
     catch (Exception ex)
     {
         DebugConsole.LogError("client write failed :>" + ex.Message);
     }
 }
Ejemplo n.º 25
0
    void Disconnected(DisconnectType dis, string msg)
    {
        Close();
        string protocal = dis == DisconnectType.System ?
                          SocketStatusCMD.Exception : SocketStatusCMD.Disconnect;

        NetByteBuffer buffer = new NetByteBuffer();

        buffer.WriteString(protocal);
        SocketClientManager.AddEvent(protocal, buffer);
        DebugConsole.LogError("Disconnected :>" + msg + " DisconnectType:>" + dis);
    }
Ejemplo n.º 26
0
    //添加数据
    static void AddData(string assetPath, Assets.Script.AssetType assetType, ref Dictionary <string, BundleAssetConfigTableData> assetsData)
    {
        BundleAssetConfigTableData data = new BundleAssetConfigTableData();

        string[] ps        = assetPath.Split('/');
        string   assetName = ps[ps.Length - 1];

        if (assetsData.ContainsKey(assetName))
        {
            DebugConsole.LogError(string.Format("Asset Menu Gen Error : \r\nasset(path = {0}) \r\nconflits with\r\nasset(path = {1})",
                                                assetPath, assetsData[assetName].AssetPath));

            return;
        }

        string assetBundleName    = string.Empty;
        string assetBundleVariant = string.Empty;

        if (assetType == AssetType.BundleAsset)
        {//获取bundle name
            AssetImporter ai = AssetImporter.GetAtPath(assetPath);
            if (ai != null)
            {
                assetBundleName    = ai.assetBundleName;
                assetBundleVariant = ai.assetBundleVariant;
                if (assetBundleVariant != string.Empty &&
                    assetBundleVariant != null)
                {
                    assetBundleName = assetBundleName + "." + assetBundleVariant;
                }

                assetPath = string.Empty;
            }
            else
            {
                DebugConsole.LogError(string.Format("Asset Menu Gen Error : can't import asset(path = {0})", assetPath));
            }
        }
        else if (assetType == AssetType.ResourcesAsset)
        {                                                    //Resoureces拼接相对路径
            assetPath = assetPath.Replace("Assets/", "");    //去掉Assets
            assetPath = assetPath.Replace("Resources/", ""); //Resoucress
            //去除扩展名
            string[] sp = assetPath.Split('.');
            assetPath = assetPath.Replace("." + sp[sp.Length - 1], "");
        }

        data.AssetName  = assetName;
        data.AssetPath  = assetPath;
        data.BundleName = assetBundleName;
        data.assetType  = (int)assetType;
        assetsData.Add(data.AssetName, data);
    }
Ejemplo n.º 27
0
 /// <summary>
 /// 隐藏弹窗
 /// </summary>
 public void HidePopups <T>(T popups, string popupsName)
 {
     if (popups == null)
     {
         DebugConsole.LogError("popups not find :" + popupsName);
         throw new NullReferenceException("Not find popups");
     }
     else
     {
         Util.CallScriptFunction(popups, popupsName, "Hide");
     }
 }
Ejemplo n.º 28
0
    /// <summary>
    /// 下载资源
    /// </summary>
    /// <param name="url">url</param>
    /// <param name="handle">下载完成回调</param>
    /// <param name="timeout">超时时间</param>
    /// <param name="errorCall">超时或错误回调</param>
    /// <returns></returns>
        private IEnumerator Download(string url, long length, HandleFinishDownload handle, int timeout = 10000, HandleDownloadError errorCall = null)
    {
        DebugConsole.Log("==>Download url = " + url);
        //创建download info
        curDownload.url           = url;
        curDownload.length        = length;
        curDownload.timeout       = timeout;
        curDownload.errorCallback = errorCall;
        curDownload.flag          = true;
        curDownload.www           = new WWW(url);         //打开下载路径

        //DebugConsole.Log("new www");
        yield return(curDownload.www);            //等待下载完成

        //下载完成后
        DebugConsole.Log("<==www return url = " + url);

        WWW doneWWW = curDownload.www;  //保存下载好的info

        curDownloadLength += curDownload.length;
        //重置curDownload参数
        curDownload.Reset();

        if (string.IsNullOrEmpty(doneWWW.error))
        {
            if (handle != null)              //回调不为空
            {
                handle(doneWWW);             //传递下载信息
            }
            doneWWW.Dispose();               //释放资源
            //doneInfo.Reset();
            doneWWW = null;
        }
        else
        {
            DebugConsole.LogError("WWW Error = " + doneWWW.error);

            try
            {
                if (errorCall != null)
                {
                    errorCall.Invoke();
                }
            }
            catch (System.Exception ex)
            {
                DebugConsole.LogError("Error Handle Callback Exception!");
                DebugConsole.LogError(ex.Message);
                DebugConsole.LogError(ex.StackTrace);
            }
        }
    }
Ejemplo n.º 29
0
        /// <summary>
        /// 异步加载资源
        /// </summary>
        /// <typeparam name="T"></typeparam>
        /// <param name="assetName"></param>
        /// <param name="callback"></param>
        public void LoadAssetAsync <T>(string assetName, System.Action <T> callback)
            where T : UnityEngine.Object
        {
            string bundleName = BundleAssetConfig.Instance.AssetNameToBundleName(assetName);

            if (string.IsNullOrEmpty(bundleName))
            {//找不到映射包,返回
                DebugConsole.LogError(string.Format("Empty Mapping Bundle by Asset({0})", assetName));
                return;
            }

            T asset = null;

            if (commonBundles.ContainsKey(bundleName))
            {//先看Common中有无资源
                asset = commonBundles[bundleName].LoadAsset <T>(assetName);
                callback.Invoke(asset);
                return;
            }

            //若package中无资源包,尝试加载资源包
            if (!packageBundles.ContainsKey(bundleName))
            {
                Load(bundleName, () =>
                {
                    if (!packageBundles.ContainsKey(bundleName))
                    {
                        DebugConsole.LogError(string.Format("BundleAssetProvider Load Error: Can't Find Bundle({0}) by Raw Resource({1})", bundleName, assetName));
                        return;
                    }

                    //加载资源
                    asset = packageBundles[bundleName].LoadAsset <T>(assetName);
                    if (asset == null)
                    {
                        DebugConsole.LogError(string.Format("Can't Load Asset({0})", assetName));
                    }

                    try
                    {
                        callback.Invoke(asset);
                        return;
                    }
                    catch (System.Exception ex)
                    {
                        DebugConsole.LogError("Load Asset Async Callback Error ==> ");
                        DebugConsole.LogError(ex.Message);
                        DebugConsole.LogError(ex.StackTrace);
                    }
                });
            }
        }
Ejemplo n.º 30
0
        public void GetAssetAsync <T>(string assetName, System.Action <T> callback)
            where T : UnityEngine.Object
        {
            int bundleType = BundleAssetConfig.Instance.AssetNameToAssetType(assetName);

            if (bundleType == (int)AssetType.ResourcesAsset)
            {
                DebugConsole.LogError(string.Format("Only Can Load Bundle Assets({0}) Asynclly!", assetName));
                return;
            }

            bundleAssetProvider.LoadAssetAsync <T>(assetName, callback);
        }