Exemple #1
0
    //未读消息回调
    public void OnAIHelpMessageArrived(string str)
    {
        GlobalUtils.CallStaticHotfix("Hotfix_LT.UI.LTGameSettingManager", "RefreshHwCsRedPoint");
        Debug.Log("OnMessageArrived is called str:" + str);
        var jnode = Johny.JSONNode.Parse(str);

        if (jnode != null && jnode.IsObject)
        {
            var data = jnode["data"]?["cs_message_count"];
            if (data != null && data.IsNumber)
            {
                AIHelp.AIHelpManager.IshaveUnreadMessage = (int)data > 0;
            }
        }
    }
Exemple #2
0
    public IEnumerator SetStreamingAssetsBG(string path)
    {
        string url;

        if (!ILRDefine.UNITY_EDITOR && ILRDefine.UNITY_ANDROID)
        {
            url = string.Format("{0}/{1}", Application.streamingAssetsPath, path);
        }
        else
        {
            url = string.Format("file://{0}/{1}", Application.streamingAssetsPath, path);
        }
        UnityWebRequest www = UnityWebRequestTexture.GetTexture(url);

        yield return(www.SendWebRequest());

        if (www.error == null)
        {
            Texture2D localTexture = DownloadHandlerTexture.GetContent(www);

            if (TextureDic.ContainsKey(path))
            {
                if (!TextureDic[path].Equals(localTexture))
                {
                    TextureDic[path] = localTexture;
                }
            }
            else
            {
                TextureDic.Add(path, localTexture);
            }
        }
        else
        {
            Debug.Log(www.error);
        }
        www.Dispose();
    }
Exemple #3
0
 //初始化回调
 public void OnAIHelpInitialized(string str)
 {
     AIHelp.AIHelpManager.IsAihelpInitialize = true;
     Debug.Log("AIhelpInitCallback is called str:" + str);
 }
Exemple #4
0
    IEnumerator Start()
    {
        Debug.Log(Caching.spaceOccupied);

        // Prevent Test instance destroied when level loading
        DontDestroyOnLoad(gameObject);


        // Test start download
        string[] sceneList = new string[] { "LA", "LB", "LC", "LD" };

        foreach (string sceneBundleName in sceneList)
        {
            DownloadManager.Instance.StartDownload(sceneBundleName + ".assetBundle");
        }

        if (!DownloadManager.Instance.IsUrlRequested("LA.assetBundle"))
        {
            Debug.LogError("TEST:IsUrlRequested() ERORR");
        }
        else
        {
            Debug.Log("TEST:IsUrlRequested() test finished.");
        }

        bool sceneBundleSucceed = false;

        do
        {
            sceneBundleSucceed = true;
            foreach (string sceneBundleName in sceneList)
            {
                if (DownloadManager.Instance.GetWWW(sceneBundleName + ".assetBundle") == null)
                {
                    sceneBundleSucceed = false;
                }
            }

            List <string> sceneBundles = new List <string>();
            foreach (string sceneBundleName in sceneList)
            {
                sceneBundles.Add(sceneBundleName + ".assetBundle");
            }
            float progressOfScenes = DownloadManager.Instance.ProgressOfBundles(sceneBundles.ToArray());
            Debug.Log("scenes' Progress {0}", progressOfScenes);

            yield return(null);
        }while(!sceneBundleSucceed);

        Debug.Log("TEST:StartDownload() test finished.");

        // Test WaitDownload
        yield return(StartCoroutine(DownloadManager.Instance.WaitDownload("LE.assetBundle")));

        Debug.Log("TEST:WaitDownload() test finished.");

        string errMsg = DownloadManager.Instance.GetError("LE.assetBundle");

        if (errMsg == null)
        {
            Debug.LogError("TEST:GetError() ERORR");
        }
        else
        {
            Debug.Log("TEST:GetError() test finished.");
        }

        // Test DisposeWWW()
        foreach (string sceneBundleName in sceneList)
        {
            DownloadManager.Instance.DisposeWWW(sceneBundleName + ".assetBundle");
        }

        if (DownloadManager.Instance.GetWWW("LA.assetBundle") != null)
        {
            Debug.LogError("TEST:DisposeWWW() ERORR");
        }
        else
        {
            Debug.Log("TEST:DisposeWWW() test finished.");
        }

        // Test StopAll()
        foreach (string sceneBundleName in sceneList)
        {
            DownloadManager.Instance.StartDownload(sceneBundleName + ".assetBundle");
        }
        DownloadManager.Instance.StopAll();

        yield return(new WaitForSeconds(2f));

        if (DownloadManager.Instance.GetWWW("LA.assetBundle") != null)
        {
            Debug.LogError("TEST:StopAll() ERORR");
        }
        else
        {
            Debug.Log("TEST:StopAll() test finished.");
        }

        // Test scene bundles based on scene bundles
        yield return(StartCoroutine(DownloadManager.Instance.WaitDownload("sub/LA-A.assetBundle")));

                #pragma warning disable 0168
        var sceneBundle = DownloadHandlerAssetBundle.GetContent(DownloadManager.Instance.GetWWW("sub/LA-A.assetBundle"));
        #pragma warning restore 0168
#pragma warning disable 0618
        Application.LoadLevel("LA-A");
        #pragma warning restore 0618
        yield return(null);

        if (GameObject.Find("LA-AWorker") == null)
        {
            Debug.LogError("TEST:Load scene bundle based on scene bundle ERORR ");
        }
        else
        {
            Debug.Log("TEST Load scene bundle based on scene bundle finished.");
        }

        // Test asset bundles based on scene bundles
        yield return(StartCoroutine(DownloadManager.Instance.WaitDownload("AB-A.assetBundle")));

#if UNITY_5 || UNITY_2018
        var workerObj = DownloadHandlerAssetBundle.GetContent(DownloadManager.Instance.GetWWW("AB-A.assetBundle")).LoadAsset <GameObject>("worker");
#else
        var workerObj = DownloadManager.Instance.GetWWW("AB-A.assetBundle").assetBundle.Load("worker");
#endif
        if (workerObj == null)
        {
            Debug.LogError("TEST:Load asset bundle based on scene bundle ERORR");
        }
        else
        {
            Debug.Log("TEST Load asset bundle based on scene bundle finished.");
        }

        // Test scene bundles based on asset bundles
        yield return(StartCoroutine(DownloadManager.Instance.WaitDownload("LB-A.assetBundle")));

                #pragma warning disable 0168
        sceneBundle = DownloadHandlerAssetBundle.GetContent(DownloadManager.Instance.GetWWW("LB-A.assetBundle"));
        #pragma warning restore 0168
        #pragma warning disable 0618
        Application.LoadLevel("LB-A");
        #pragma warning restore 0618
        yield return(null);

        if (GameObject.Find("LB-AWorker") == null)
        {
            Debug.LogError("TEST:Load scene bundle based on asset bundle ERORR ");
        }
        else
        {
            Debug.Log("TEST Load scene bundle based on asset bundle finished.");
        }

        // Test asset bundles based on asset bundles
        yield return(StartCoroutine(DownloadManager.Instance.WaitDownload("AA-A.assetBundle")));

#if UNITY_5 || UNITY_2018
        workerObj = DownloadHandlerAssetBundle.GetContent(DownloadManager.Instance.GetWWW("AA-A.assetBundle")).LoadAsset <GameObject>("worker");
#else
        workerObj = DownloadManager.Instance.GetWWW("AA-A.assetBundle").assetBundle.Load("worker");
#endif
        if (workerObj == null)
        {
            Debug.LogError("TEST:Load asset bundle based on asset bundle ERORR");
        }
        else
        {
            Debug.Log("TEST Load asset bundle based on asset bundle finished.");
        }

        // Test Load deep dependend tree
        yield return(StartCoroutine(DownloadManager.Instance.WaitDownload("LAAAAA.assetBundle")));

                #pragma warning disable 0168
        sceneBundle = DownloadHandlerAssetBundle.GetContent(DownloadManager.Instance.GetWWW("LAAAAA.assetBundle"));
        #pragma warning restore 0168
        #pragma warning disable 0618
        Application.LoadLevel("LAAAAA");
        #pragma warning restore 0618
        yield return(null);

        if (GameObject.Find("LAAAAAWorker") == null)
        {
            Debug.LogError("TEST:Load deep dependend tree ERORR ");
        }
        else
        {
            Debug.Log("TEST Load deep dependend tree finished.");
        }


        // Test two bundle based on one bundle
        yield return(StartCoroutine(DownloadManager.Instance.WaitDownload("ACA.assetBundle")));

        yield return(StartCoroutine(DownloadManager.Instance.WaitDownload("ACB.assetBundle")));

#if UNITY_5 || UNITY_2018
        var cube   = DownloadHandlerAssetBundle.GetContent(DownloadManager.Instance.GetWWW("ACA.assetBundle")).LoadAsset <UnityEngine.Object>("Cube");
        var sphere = DownloadHandlerAssetBundle.GetContent(DownloadManager.Instance.GetWWW("ACB.assetBundle")).LoadAsset <UnityEngine.Object>("Sphere");
#else
        var cube   = DownloadManager.Instance.GetWWW("ACA.assetBundle").assetBundle.Load("Cube");
        var sphere = DownloadManager.Instance.GetWWW("ACB.assetBundle").assetBundle.Load("Sphere");
#endif
        if (cube == null || sphere == null)
        {
            Debug.LogError("TEST: two bundle based on one bundle ERORR");
        }
        else
        {
            Debug.Log("TEST two bundle based on one bundle finished");
        }


        // Test Built Bundles
        if (DownloadManager.Instance.ConfigLoaded)
        {
            var bundles = DownloadManager.Instance.BuiltBundles;
            if (bundles != null && bundles.Length > 0)
            {
                Debug.Log("TEST BuiltBundles finished");
            }
            else
            {
                Debug.LogError("TEST: BuiltBundles ERORR");
            }
        }

        Debug.Log("TEST finished");
    }