public virtual BuildingController UnloadAsset(string tag)
 {
     if (IsLoaded == false)
     {
         Debug.Log("BuildingBox.UnloadAsset IsLoaded == false:" + this);
         return(null);
     }
     IsLoaded = false;
     //GameObject.DestroyImmediate(buildingController.gameObject);
     if (rootObjs != null)
     {
         foreach (var item in rootObjs)
         {
             if (item == null)
             {
                 continue;
             }
             GameObject.DestroyImmediate(item);
         }
         rootObjs = null;
     }
     else
     {
         Debug.LogError("AssetBundleInfo.UnloadAsset rootObjs == null");
     }
     AssetBundleMagic.UnloadBundleEx(AssetName);
     return(null);
 }
    private void ClearBundles()
    {
        List <string> tmp = new List <string>();

        tmp.AddRange(LoadedBundles);
        foreach (var item in tmp)
        {
            AssetBundleMagic.UnloadBundleEx(item);
        }
    }
    public void OnDestroy()
    {
        //Debug.Log("BuildingController.OnDestroy:"+this.name+ "|buildingBox:"+(buildingBox!=null));
        if (buildingBox)
        {
            //buildingBox.UnloadAsset();//以防万一在未经过正式路径卸载了模型,没有把原来的模型替换掉
            //AssetBundleMagic.UnloadBundleEx(buildingBox.AssetName);//UnloadBundle要放到这里,出现了GameObject还在,但是模型材质都没有了的情况
            Debug.Log("BuildingController.OnDestroy AssetBundleMagic.DoUnload");
            AssetBundleMagic.DoUnload();
        }

        IsDestroy = true;
    }
Exemplo n.º 4
0
    public bool UnloadModel(string modelName)
    {
        var bundleName = GetFullBundleName(modelName);

        if (AssetBundleMagic.ContainsBundle(bundleName))
        {
            return(AssetBundleMagic.UnloadBundleEx(bundleName));
        }
        else
        {
            //两个模型公用一个bundle
            return(true);
        }
    }
    // -------------------------------------------------------------------------------
    // DownloadVersions
    // -------------------------------------------------------------------------------
    protected void DownloadVersions()
    {
        if (!CheckBuildTarget())
        {
            return;
        }

#if _CLIENT
        UCE_UI_AssetBundleDownloader.singleton.UpdateUI(labelVersions);
#endif

        AssetBundleMagic.DownloadVersions(delegate(string versions) {
            LoadBundles();
        }, delegate(string error) {
            Debug.LogError(error);
        });
    }
    // -------------------------------------------------------------------------------
    // UnloadBundles
    // -------------------------------------------------------------------------------
    protected void UnloadBundles()
    {
        if (!CheckBuildTarget())
        {
            return;
        }

#if _CLIENT
        UCE_UI_AssetBundleDownloader.singleton.UpdateUI(labelUncache);
#endif

        AssetBundleMagic.CleanBundlesCache();

        foreach (string bundleName in bundleNames)
        {
            AssetBundleMagic.UnloadBundle(bundleName, true);
        }
    }
Exemplo n.º 7
0
    private void DestroyGameObject()
    {
        var obj = buildingController.gameObject;

        if (IsPart)
        {
            obj = obj.transform.parent.gameObject;
        }

        //放到最后删除掉
        //GameObject.DestroyImmediate(buildingController.gameObject);//放到最后删除掉
        //GameObject.Destroy(buildingController.gameObject);//有问题,建筑内的人员会隐藏掉,看不到,但是实际上没有被删除
        GameObject.Destroy(obj, 2f);//加了延迟,人员就正常显示了。看了一下,不显示可能和LocationObject中的locationAreas有关,需要等一下,等移动到新的建筑里重新添加了locationAreas吧。

        //AssetBundleMagic.UnloadBundle(AssetName, true);//不能用false,要卸载掉asset
        //在卸载掉的BuildingController中移除Asset

        AssetBundleMagic.UnloadBundleEx(AssetName);
    }
    // -------------------------------------------------------------------------------
    // LoadBundle
    // -------------------------------------------------------------------------------
    protected void LoadBundle(string sBundleName)
    {
        if (!CheckBuildTarget())
        {
            return;
        }

#if _CLIENT
        UCE_UI_AssetBundleDownloader.singleton.UpdateUI(labelBundle + sBundleName);
#endif

        p = AssetBundleMagic.DownloadBundle(
            sBundleName,
            delegate(AssetBundle ab2) {
            LoadNextBundle();
        },
            delegate(string error) {
            Debug.LogError(error);
        }
            );
    }