Exemple #1
0
    static void ParseXML(string content, SceneConfigData data, string fileName)
    {
        XmlDocument doc = new XmlDocument();

        try
        {
            doc.LoadXml(content);
        }
        catch (System.Xml.XmlException ex)
        {
            ClientLog.Instance.LogError(" xml file : " + fileName + " has exception.");
        }

        data.fileName_ = fileName;

        XmlNode rootNode = doc.SelectSingleNode("/Scene");

        foreach (XmlAttribute attr in rootNode.Attributes)
        {
            if (attr.Name.Equals("ChapterID") && !string.IsNullOrEmpty(attr.Value))
            {
                data.chapterId_ = int.Parse(attr.Value);
            }

            if (attr.Name.Equals("SceneName"))
            {
                data.sceneName_ = attr.Value;
            }

            if (attr.Name.Equals("BattleName"))
            {
                data.battleName_ = attr.Value;
            }
        }
    }
Exemple #2
0
    protected void TryBindSceneRelation(SceneConfigData _data)
    {
        if (_data == null || _data.sceneAsset == null || _data.sceneAsset.gameObjectRelationship == null)
        {
            Debug.LogError("The SceneConfigData has some problem , please check it !");
            return;
        }
        GameObject myScene = GameObject.Find(_data.sceneAsset.sceneName);

        if (myScene != null)
        {
            if (finalObjDic.ContainsKey(_data.sceneAsset.sceneName))
            {
                DestroyImmediate(finalObjDic[_data.sceneAsset.sceneName], true);
                finalObjDic.Remove(_data.sceneAsset.sceneName);
            }
            finalObjDic[_data.sceneAsset.sceneName] = myScene;
            SceneRoot sr = myScene.GetComponent <SceneRoot>();
            if (sr != null)
            {
                PlayGameStage s = GameCenter.curGameStage as PlayGameStage;
                if (s != null)
                {
                    s.SetSceneEffects(sr);
                }
            }
            ProcessGameObjectRelation(myScene, _data.sceneAsset.gameObjectRelationship);
        }
        else
        {
            Debug.LogError(_data.sceneAsset.sceneName + " 场景对象为空!请美术检查资源名称以及配置文件!");
        }
    }
Exemple #3
0
    public void SetTarget(Transform target)
    {
        //m_target = target;
        FindTargetPoint(target);

        //init camera pos and rotation
        m_distanceFromTarget = m_initDistanceFromPlayer;
        Vector3 pos = m_target.position;

        pos += m_initDistanceFromPlayer;

        transform.position = pos;
        //transform.LookAt(m_target,Vector3.up);
        transform.LookAt(m_target);

        //setup the scene parameter
        int             SceneConfigId = (int)GameManager.Instance.GetCurSceneMapID;
        SceneConfigData sData         = EctypeConfigManager.Instance.SceneConfigList[SceneConfigId];

        m_sceneWidth  = sData._mapWidth;
        m_sceneHeight = sData._mapHeight;

        //init Shake Params
        m_normalInitDistanceFromPlayer = m_initDistanceFromPlayer.normalized;
    }
Exemple #4
0
    public static SceneConfigData MergeNeed(List<SceneConfigData> _data)
    {
        SceneConfigData newdata = SceneConfigData.CreateInstance<SceneConfigData>();
        newdata.Name = string.Empty;
        for (int i = 0; i < _data.Count; i++)
        {
            SceneConfigData item = _data[i];
            for (int j = 0; j < item.textureDataList.Count; j++)
            {
                if (!newdata.textureDataList.Contains(item.textureDataList[j]))
                {
                    newdata.textureDataList.Add(item.textureDataList[j]);
                }
            }
            for (int j = 0; j < item.shaderDataList.Count; j++)
            {
                if (!newdata.shaderDataList.Contains(item.shaderDataList[j]))
                {
                    newdata.shaderDataList.Add(item.shaderDataList[j]);
                }
            }
            for (int j = 0; j < item.materialDataList.Count; j++)
            {
                if (!newdata.materialDataList.Contains(item.materialDataList[j]))
                {
                    newdata.materialDataList.Add(item.materialDataList[j]);
                }
            }
        }
        return newdata;

    }
Exemple #5
0
 protected List<string> GetNeedLoadAsset(SceneConfigData _newData, AssetType _type)
 {
     List<string> need = new List<string>();
     switch (_type)
     {
         case AssetType.texture:
             for (int i = 0; i < _newData.textureDataList.Count; i++)
             {
                 string item = _newData.textureDataList[i];
                 if (!LoadCache.textureRefDic.ContainsKey(item) && !need.Contains(item)) need.Add(item);
             }
             break;
         case AssetType.material:
             for (int i = 0; i < _newData.materialDataList.Count; i++)
             {
                 string item = _newData.materialDataList[i];
                 if (!LoadCache.materialRefDic.ContainsKey(item) && !need.Contains(item))
                 {
                     need.Add(item);
                 }
             }
             break;
         default:
             break;
     }
     return need;
 }
Exemple #6
0
    /// <summary>
    /// 获取需要新加载的资源配置表 by吴江
    /// </summary>
    /// <param name="_newData">新场景所需要的整体资源</param>
    /// <param name="_oldData">原场景已经有的整体资源</param>
    /// <returns>新场景还需要加载的资源表</returns>
    private SceneConfigData GetNeedLoad(SceneConfigData _newData)
    {
        SceneConfigData needLoadData = SceneConfigData.CreateInstance<SceneConfigData>();


        needLoadData.name = _newData.name;
        needLoadData.instanceID = _newData.instanceID;

        //获取旧场景中不存在的新资源
        foreach (var newData in _newData.textureDataList)
        {
            if (!LoadCache.HasLoaded(newData, AssetType.texture) && !needLoadData.textureDataList.Contains(newData))
            {
                needLoadData.textureDataList.Add(newData);
            }
        }
        foreach (var newData in _newData.shaderDataList)
        {
            if (!LoadCache.HasLoaded(newData, AssetType.shader) && !needLoadData.shaderDataList.Contains(newData))
            {
                needLoadData.shaderDataList.Add(newData);
            }
        }
        foreach (var newData in _newData.materialDataList)
        {
            if (!LoadCache.HasLoaded(newData, AssetType.material) && !needLoadData.materialDataList.Contains(newData))
            {
                needLoadData.materialDataList.Add(newData);
            }
        }
        return needLoadData;
    }
Exemple #7
0
    /// <summary>
    /// 获取需要删除的资源配置表 by吴江
    /// </summary>
    /// <param name="_newData">新场景所需要的整体资源</param>
    /// <param name="_oldData">原场景已经有的整体资源</param>
    /// <returns>新场景还需要加载的资源表</returns>
    public static void UnLoadUseness(List<SceneConfigData> _newData)
    {
        List<string> unloadTexList = new List<string>();
        List<string> unloadMatList = new List<string>();

        SceneConfigData allNeed = MergeNeed(_newData);
        foreach (var item in LoadCache.textureRefDic.Keys)
        {
            if (!allNeed.textureDataList.Contains(item)) unloadTexList.Add(item);
        }

        foreach (var item in LoadCache.materialRefDic.Keys)
        {
            if (!allNeed.materialDataList.Contains(item)) unloadMatList.Add(item);
        }


        for (int i = 0; i < unloadTexList.Count; i++)
        {
            LoadCache.UnLoad(unloadTexList[i], AssetType.texture);
        }
        for (int i = 0; i < unloadMatList.Count; i++)
        {
            LoadCache.UnLoad(unloadMatList[i], AssetType.material);
        }
    }
Exemple #8
0
    /// <summary>
    /// 
    /// </summary>
    /// <param name="_newData">新场景所需要的整体资源</param>
    /// <param name="_oldData">原场景已经有的整体资源</param>
    /// <returns>新场景还需要加载的资源表</returns>
    protected void CompareChilds(List<SceneConfigData> _newData, ref SceneConfigData _needload)
    {
        SceneConfigData mergedNewData = MergeNeed(_newData);
        _needload = GetNeedLoad(mergedNewData);

        DestroyImmediate(mergedNewData, true);
        mergedNewData = null;
    }
Exemple #9
0
        public void Show()
        {
            MapID = (int)GameManager.Instance.GetCurSceneMapID;
            SceneConfigData sceneConfigData = EctypeConfigManager.Instance.SceneConfigList[MapID];

            miniMapArea.SetMapAreaSize(sceneConfigData);
            miniMapArea.ShowMiniMapUIPoint();
        }
Exemple #10
0
    private void InitBlockCells(SceneConfigData configData, byte[] data)
    {
        //Block文件的文件头,跳过指定字节数(char[5]+float = 9)//
        //struct SMapFileDataInfo
        //{
        //    char	fileHeader[5];
        //    float	Virsion;
        //    int		dwMapHeight;   //高度格子数量
        //    int		dwMapWidth;	   //宽度格子数量

        //    SMapFileDataInfo()
        //    {
        //        //TileBlock = NULL;
        //        Virsion = 0;
        //        dwMapHeight = 0;
        //        dwMapWidth = 0;
        //        memset(fileHeader, 0, sizeof(fileHeader));
        //    }
        //};
        int offset = 9, dwMapHeight, dwMapWidth;

        offset += PackageHelper.ReadData(data.Skip(offset).ToArray(), out dwMapWidth);
        offset += PackageHelper.ReadData(data.Skip(offset).ToArray(), out dwMapHeight);
        //计算地图上的宫格数
        //TraceUtil.Log(dwMapHeight + "  " + dwMapWidth);
        m_heightBound = dwMapHeight;
        m_widthBound  = dwMapWidth;
        m_blockCells  = new BlockCell[m_heightBound, m_widthBound];
        int blockIndex = 0;

        for (int v = 0; v < dwMapHeight; v++)
        {
            for (int h = 0; h < dwMapWidth; h++)
            {
                m_blockCells[v, h] = new BlockCell()
                {
                    Index = blockIndex++, VIndex = v, HIndex = h, BlockValue = data[offset]
                };
                //if (m_blockCells[v, h].IsBlock)
                //{
                //    Debug.Log(blockIndex + "   " + v + "  " + h);
                //GameObject.Instantiate(Block, new Vector3(h * TILEPOSX_WIDTH / 2, 1, v * TILEPOSY_HEIGHT / 2), Quaternion.identity);
                //}
                //this.m_blockCells.Add(new BlockCell() { VIndex = v, HIndex = h, BlockValue = data[offset] });
                offset++;
                if (GameManager.Instance.m_showBlock)
                {
                    if (m_blockCells[v, h].IsBlock)
                    {
                        Vector3 pos = new Vector3((float)(h + 0.5f) * TILEPOSX_WIDTH, 1, -(float)(v + 0.5f) * TILEPOSY_HEIGHT);
                        GameManager.Instance.AddBlockCell(pos);
                    }
                }
            }
        }
    }
Exemple #11
0
    public SceneConfigData GetSceneData(int mapID)
    {
        SceneConfigData data = null;

        if (m_sceneConfigDict.ContainsKey(mapID))
        {
            m_sceneConfigDict.TryGetValue(mapID, out data);
        }
        return(data);
    }
Exemple #12
0
        public void SetMapAreaSize(SceneConfigData sceneConfigData)
        {
            this.sceneConfigData = sceneConfigData;
            float mapWidth  = sceneConfigData._mapWidth;
            float mapHeight = sceneConfigData._mapHeight;
            float XSize     = mapHeight <= mapWidth ? 100 : mapWidth * 100 / mapHeight;
            float YSize     = mapWidth <= mapHeight ? 100 : mapHeight * 100 / mapWidth;

            BackagroundObj.transform.localScale = new Vector3(XSize, YSize, 1);
        }
Exemple #13
0
        public void SetPosition(GameObject Obj, SceneConfigData sceneConfigData)
        {
            this.sceneConfigData = sceneConfigData;
            this.ShowObj         = Obj;
            float mapWidth  = sceneConfigData._mapWidth;
            float mapHeight = sceneConfigData._mapHeight;
            float MaxFloat  = mapWidth > mapHeight ? mapWidth : mapHeight;

            PositionScale = 100 / MaxFloat;
        }
Exemple #14
0
    //产生测试数据
    public static List <SceneConfigData> GenerateSceneConfigData()
    {
        List <SceneConfigData> sceneConfigDatas = new List <SceneConfigData>();

        for (int i = 0; i < 3; i++)
        {
            SceneConfigData newSceneConfigData = new SceneConfigData(i, "scene" + i.ToString(), "", "some descriptions", 10, 0);
            sceneConfigDatas.Add(newSceneConfigData);
        }
        return(sceneConfigDatas);
    }
Exemple #15
0
    protected IEnumerator LoadConfig(string _mainPath, List<string> _wholeNeedNames, Action _callBack)
    {
        //NGUIDebug.Log("开始LoadConfig");
        curConfigList.Clear();

        //通过跟上一个场景比较,得到本次需要加载的特效名称列表,和需要删除的特效名称列表
        CompareMain(_wholeNeedNames, lastConfigList, ref needLoadList);

        //个数+配置文件个数
        ResourcesTotalCount += needLoadList.Count > 0 ? (needLoadList.Count * 2 + progressDelay) : 0;

        for (int i = 0; i < needLoadList.Count; i++)
        {
            string ConfigPath = _mainPath + "config/" + needLoadList[i] + ".assetbundle";
            if (!isFileExist(ConfigPath))
            {
                needLoadList.RemoveAt(i);
                i--;
            }
            else
            {
                // NGUIDebug.Log("yyyyyyyyyyyyyyyyyyy ConfigPath=" + ConfigPath);
            }
        }
        //根据列表,下载配置文件,存入缓存列表
        for (int i = 0; i < needLoadList.Count; i++)
        {
             DownloadConfig(_mainPath, needLoadList, i);
        }
       // DownloadConfig(_mainPath, needLoadList, 0);


        //等待下载结束
        while (configPendings > 0) yield return new WaitForFixedUpdate();

        //确保本次所需要的所有特效配置文件都已经在缓存中
        for (int i = 0; i < _wholeNeedNames.Count; i++)
        {
             if (configRefDic.ContainsKey(_wholeNeedNames[i]))
            {
                SceneConfigData curSceneConfigData = configRefDic[_wholeNeedNames[i]] as SceneConfigData;
                curConfigList.Add(curSceneConfigData);
            }
            else
            {
                Debug.LogError("can't find config data that names " + _wholeNeedNames[i]);
                // NGUIDebug.Log("can't find config data that names " + item);
            }
        }

        if (_callBack != null) _callBack();
    }
Exemple #16
0
    public static int GetBornPosEntryID(string fileName)
    {
        SceneConfigData data = GetData(fileName);

        for (int i = 0; i < data.entryList_.Count; ++i)
        {
            if (data.entryList_[i].isBornPos_)
            {
                return(data.entryList_[i].id_);
            }
        }
        return(0);
    }
Exemple #17
0
    public static EntryInfo GetEntryInfo(string fileName, int entryId)
    {
        SceneConfigData data = GetData(fileName);

        for (int i = 0; i < data.entryList_.Count; ++i)
        {
            if (data.entryList_[i].id_ == entryId)
            {
                return(data.entryList_[i]);
            }
        }
        return(null);
    }
Exemple #18
0
    public static Vector3 GetEntryPos(string fileName, int entryId)
    {
        SceneConfigData data = GetData(fileName);

        for (int i = 0; i < data.entryList_.Count; ++i)
        {
            if (data.entryList_[i].id_ == entryId)
            {
                return(data.entryList_[i].position_);
            }
        }
        return(Vector3.zero);
    }
Exemple #19
0
    //public override void CacheTransform()
    //{
    //    ThisTransform = NormalStatus.transform;
    //}
    private void InitBoundHandle()
    {
        if (GameManager.Instance == null)
        {
            return;
        }

        int             SceneConfigId = (int)GameManager.Instance.GetCurSceneMapID;
        SceneConfigData sData         = EctypeConfigManager.Instance.SceneConfigList[SceneConfigId];

        m_sceneWidth  = sData._mapWidth;
        m_sceneHeight = sData._mapHeight;
    }
Exemple #20
0
    protected void TryBindSceneRelation(SceneConfigData _data)
    {
        if (!finalObjDic.ContainsKey(_data.Name) || finalObjDic[_data.Name] == null)
        {
            if (prefabAssetBundleRefDic.ContainsKey(_data.Name) && prefabAssetBundleRefDic[_data.Name] != null && prefabAssetBundleRefDic[_data.Name].assetBundle != null)
            {
                UnityEngine.Object obj = null;

                UnityEngine.Object[] list = prefabAssetBundleRefDic[_data.Name].assetBundle.LoadAllAssets();
                if (list.Length > 0)
                {
                    obj = list[0];
                }
                finalObjDic[_data.Name] = GameObject.Instantiate(obj, new Vector3(10000, 10000, 10000), Quaternion.identity) as GameObject;
                FXRoot fr = finalObjDic[_data.Name].GetComponent <FXRoot>();
                if (fr == null)
                {
                    fr = finalObjDic[_data.Name].AddComponent <FXRoot>();
                    fr.InitLength();
                }
                if (finalObjDic[_data.Name] != null)
                {
                    finalObjDic[_data.Name].name = _data.Name;
                    finalObjDic[_data.Name].SetActive(false);
                }
                else
                {
                    finalObjDic.Remove(_data.Name);
                    Debug.LogError("asset ref " + _data.Name + " is null ,please check it !");
                }
                prefabAssetBundleRefDic[_data.Name].assetBundle.Unload(false);
            }
            else
            {
                Debug.LogError("找不到名为 " + _data.Name + " 的预制资源,请检查!如果前面没有其他加载报错,有可能是配置表和资源名称的大小写不匹配的问题!");
            }
        }
        if (_data == null || _data.sceneAsset == null || _data.sceneAsset.gameObjectRelationship == null)
        {
            Debug.LogError("配置文件有问题,请检查!");
            return;
        }
        if (!finalObjDic.ContainsKey(_data.Name) || finalObjDic[_data.Name] == null)
        {
            Debug.LogError("找不到名为 " + _data.Name + "的预制,请检查");
            return;
        }
        ProcessGameObjectRelation(finalObjDic[_data.Name], _data.sceneAsset.gameObjectRelationship);
        finalObjDic[_data.Name].transform.parent = finalObjCacheTrans;
    }
Exemple #21
0
 public void Init(SceneConfigData a_data)
 {
     //enable fade screen in case it is disabled
     fadeScreen.SetActive(true);
     menuItem.Init(a_data.Items);
     //setup dummy toggle text
     if (a_data.DummyPosition == ModelManager.DummyPosition.straigt)
     {
         m_toggleDummyText.text = "View : straight";
     }
     else
     {
         m_toggleDummyText.text = "View : inclined";
     }
 }
Exemple #22
0
    protected void CompareMain(List<string> _newData, List<SceneConfigData> _oldData, ref List<string> _needload)
    {
        _needload.Clear();

        List<string> oldList = new List<string>();
        if (_oldData != null)
        {
            for (int i = 0; i < _oldData.Count; i++)
            {
                SceneConfigData item = _oldData[i];
                if (!oldList.Contains(item.Name)) oldList.Add(item.Name);
            }
        }
        for (int i = 0; i < _newData.Count; i++)
        {
            string item = _newData[i];
            if (!oldList.Contains(item) && !_needload.Contains(item)) _needload.Add(item);
        }
    }
Exemple #23
0
    public void Init(SceneConfigData a_data)
    {
        //initialize singleton
        if (instance != null && instance != this)
        {
            Destroy(instance);
        }
        instance = this;
        //set dummy position
        dummyPosition = a_data.DummyPosition;
        if (dummyPosition == DummyPosition.straigt)
        {
            imageTargetDummy = straightDummy;
        }
        else
        {
            imageTargetDummy = inclinedDummy;
        }
        //setup model list
        models          = new List <AEntity>();
        currentSelected = -1;
        //setup the rest of the class

        //get first AR Object assigned to Image Target
        if (imageTargetDummy.transform.childCount == 0)
        {
            currentARObject = null;
        }
        else
        {
            currentARObject = imageTargetDummy.transform.GetChild(0).gameObject.GetComponent <AEntity>();
        }
        //update Object Manager List
        for (int i = 0; i < a_data.Items.Length; ++i)
        {
            AddModel(a_data.Items[i]);
        }
        m_verbose = a_data.Verbose;
    }
Exemple #24
0
    public static void ParseData(string content, string fileName)
    {
        if (!fileName.EndsWith(".xml"))
        {
            return;
        }

        SceneConfigData data = new SceneConfigData();

        data.Init();

        fileName = fileName.Substring(fileName.LastIndexOf("/") + 1, fileName.IndexOf(".xml") - 1 - fileName.LastIndexOf("/"));

        ParseXML(content, data, fileName);

        if (metaData_.ContainsKey(data.fileName_))
        {
            ClientLog.Instance.LogError("Same id in SceneData :" + data.fileName_);
            return;
        }
        metaData_.Add(data.fileName_, data);
    }
Exemple #25
0
    private static void OnPostprocessAllAssets(string[] importedAssets, string[] deletedAssets,
                                               string[] movedAssets, string[] movedFromPath)
    {
        if (CheckResModified(importedAssets) || CheckResModified(deletedAssets) || CheckResModified(movedAssets))
        {
            string     path = System.IO.Path.Combine(RESOURCE_SCENE_CONFIG_FOLDER, "MapInfo.xml");
            TextReader tr   = new StreamReader(path);
            string     text = tr.ReadToEnd();

            if (text == null)
            {
                Debug.LogError("Scene config file not exist");
                return;
            }
            else
            {
                XmlSpreadSheetReader.ReadSheet(text);
                XmlSpreadSheet sheet = XmlSpreadSheetReader.Output;
                string[]       keys  = XmlSpreadSheetReader.Keys;

                object[] levelIds = sheet[keys[0]];

                List <SceneConfigData> tempList = new List <SceneConfigData>();

                for (int i = 2; i < levelIds.Length; i++)
                {
                    SceneConfigData data = new SceneConfigData();
                    data._lMapID      = Convert.ToInt32(sheet["lMapID"][i]);
                    data._szSceneName = Convert.ToString(sheet["szSceneName"][i]);
                    data._szMapFile   = Convert.ToString(sheet["szMapFile"][i]);
                    data._mapWidth    = Convert.ToInt32(sheet["lMapPixelWidth"][i]) / 10;
                    data._mapHeight   = Convert.ToInt32(sheet["lMapPixelHeight"][i]) / 10;
                    data._szNameID    = Convert.ToString(sheet["szName"][i]);
                    data._szMapIcon   = Convert.ToString(sheet["szMapIcon"][i]);
                    string iconPath = System.IO.Path.Combine(MapIconPrefabPath, data._szMapIcon + ".prefab");
                    data.MpIconPrefab = (GameObject)AssetDatabase.LoadAssetAtPath(iconPath, typeof(GameObject));
                    data._mapBGM      = Convert.ToString(sheet["MapBgm"][i]);
                    data._sceneType   = Convert.ToInt32(sheet["lType"][i]);
                    data._isLockMode  = Convert.ToBoolean(sheet["LockingOperationMode"][i]);
                    var triggerData = Convert.ToString(sheet["TrigerArea"][i]);
                    if (triggerData != "0")
                    {
                        var triggers   = triggerData.Split('|');
                        var triggerNum = triggers.Length;
                        data._TriggerAreaPoint  = new Vector3[triggerNum];
                        data._TriggerAreaRadius = new float[triggerNum];

                        for (int j = 0; j < triggerNum; j++)
                        {
                            var pointInfo = triggers[j].Split('+');
                            data._TriggerAreaPoint[j]  = new Vector3(float.Parse(pointInfo[0]) * 0.1f, 0, float.Parse(pointInfo[1]) * -0.1f);
                            data._TriggerAreaRadius[j] = float.Parse(pointInfo[2]) * 0.1f;
                        }
                    }

                    tempList.Add(data);
                }

                CreateSceneConfigDataBase(tempList);
            }
        }
    }
Exemple #26
0
    protected IEnumerator LoadSingleEffect(string _mainPath, string _name, Action _callBack)
    {
        List <string> str = new List <string>();

        str.Add(_name);
        //根据列表,下载配置文件,存入缓存列表
        DownloadConfig(_mainPath, str, 0);

        //等待下载结束
        while (configPendings > 0)
        {
            yield return(new WaitForFixedUpdate());
        }

        SceneConfigData curSingleConfigData = null;

        //确保本次所需要的所有特效配置文件都已经在缓存中
        if (configRefDic.ContainsKey(_name))
        {
            curSingleConfigData = configRefDic[_name] as SceneConfigData;
        }
        if (curSingleConfigData != null)
        {
            for (int i = 0; i < str.Count; i++)
            {
                DownloadFinalObject(_mainPath, str, i);
            }
            while (finalObjectPendings > 0)
            {
                yield return(new WaitForFixedUpdate());
            }

            List <string> needText = GetNeedLoadAsset(curSingleConfigData, AssetType.texture);
            for (int i = 0; i < needText.Count; i++)
            {
                DownloadTexture(_mainPath, needText, i);
            }
            while (texturePendings > 0)
            {
                yield return(new WaitForFixedUpdate());
            }


            List <string> needMat = GetNeedLoadAsset(curSingleConfigData, AssetType.material);
            for (int i = 0; i < needMat.Count; i++)
            {
                DownloadMaterial(_mainPath, needMat, i);
            }
            while (materialPendings > 0)
            {
                yield return(new WaitForFixedUpdate());
            }

            BindMaterialDepend(curSingleConfigData.materialAssetList);

            while (finalObjInitPendings > 0)
            {
                yield return(new WaitForFixedUpdate());
            }
            TryBindSceneRelation(curSingleConfigData);
        }
        else
        {
            Debug.LogError("can't find config data that names " + _name);
        }

        if (_callBack != null)
        {
            _callBack();
        }
    }
Exemple #27
0
    protected IEnumerator downloadConfig(string _mainPath, List<string> _list, int _index, Action<string, List<string>, int> _moveNext)
    {
        if (_list.Count <= _index) yield break;
        string name = _list[_index];
        //如果缓存列表中已经有,则不再重复下载
        if (configRefDic.ContainsKey(name) || waitConfig.Contains(name))
        {
           // if (_moveNext != null) _moveNext(_mainPath, _list, ++_index);
            yield break;
        }
        else
        {
            configPendings++;
            string ConfigPath = _mainPath + "config/" + name + ".assetbundle";
            if (!isFileExist(ConfigPath))
            {

                configPendings--;
                Debug.LogWarning("File not Exists ConfigPath=" + ConfigPath);
                if (_moveNext != null) _moveNext(_mainPath, _list, ++_index);
                yield break;
            }
            waitConfig.Add(name);
            using (WWW www = new WWW(ConfigPath))
            {
                yield return www;
                if (www != null && www.isDone)
                {
                    waitConfig.Remove(name);
                    configPendings--;
                    if (www.assetBundle != null)
                    {
                        SceneConfigData data = null;
                        try
                        {
                            data = www.assetBundle.mainAsset as SceneConfigData;
                        }
                        catch
                        {
                            Debug.LogError(ConfigPath + "数据装箱转换出错!");
                        }
                        if (data != null)
                        {
                            data.sceneAsset.gameObjectRelationship.InitData();
                            if (configRefDic.ContainsKey(name))
                            {
                                DestroyImmediate(configRefDic[name],true);
                                configRefDic[name] = data;
                            }
                            else
                            {
                                configRefDic.Add(name, data);
                            }
                        }
                        else
                        {
                            Debug.Log("www.assetBundle.mainAsset is null");
                        }
                        www.assetBundle.Unload(false);
                    }
                    else
                    {
                        Debug.Log("load false");
                    }
                    if (_moveNext != null)
                    {
                        _moveNext(_mainPath, _list, ++_index);
                    }
                    else
                    {
                    }
                }
            }


        }


    }
Exemple #28
0
    public IEnumerator LoadResources(string _mainPath, List<string> _wholeNeedNames, Action _callBack, bool _asyncBind = false)
    {
        if (_asyncBind)
        {
            canAsyncBind = false;
        }
        if (needLoadList.Count == 0)//如果是相同场景
        {
            foreach (var item in _wholeNeedNames)
            {
                InitFinalObject(item);
            }
        }
        else
        {
            if (curConfigList == null || curConfigList.Count == 0)
            {
                Debug.LogError("本次资源加载任务没有找到配置文件,直接跳过!");
            }
            else
            {
                if (needLoadData != null)
                {
                    DestroyImmediate(needLoadData, true);
                    needLoadData = null;
                }
                CompareChilds(curConfigList, ref needLoadData);
                ResourcesTotalCount += (needLoadData.materialAssetList.Count + needLoadData.materialDataList.Count + needLoadData.textureDataList.Count
                    + needLoadData.shaderDataList.Count - progressDelay);
                ResourcesCurCount = needLoadList.Count;//配置文件已经下载完成
            }

        }
        if (needLoadData != null)
        {
            for (int i = 0; i < needLoadData.textureDataList.Count; i++)
            {
                DownloadTexture(_mainPath, needLoadData.textureDataList, i);
            }
            while (texturePendings > 0)
            {
                yield return new WaitForFixedUpdate();
            }


            for (int i = 0; i < needLoadData.materialDataList.Count; i++)
            {
                DownloadMaterial(_mainPath, needLoadData.materialDataList, i);
            }
            while (materialPendings > 0)
            {
                yield return new WaitForFixedUpdate();
            }

            BindMaterialDepend(MergeMaterialAssetList(curConfigList));


            while (finalObjInitPendings > 0)
            {
                yield return new WaitForFixedUpdate();
            }
        }
        if (needLoadList.Count > 0)
        {
            for (int i = 0; i < needLoadList.Count; i++)
            {
                DownloadFinalObject(_mainPath, needLoadList, i);
            }
           // DownloadFinalObject(_mainPath, needLoadList, 0);
            while (finalObjectPendings > 0)
            {
                yield return new WaitForFixedUpdate();
            }
        }
        if (!_asyncBind)
        {
            TryBindSceneRelation(curConfigList);

            //清理主对象缓存
            DeleteMainAssetBundle(_wholeNeedNames);



            lastConfigList.Clear();
            foreach (var item in curConfigList)
            {
                lastConfigList.Add(item);
            }

            DestroyImmediate(needLoadData, true);
            needLoadData = null;
            curConfigList.Clear();


            if (complete != null) complete();

            if (_callBack != null) _callBack();
        }
        else
        {
            while (!canAsyncBind)
            {
                yield return new WaitForFixedUpdate();
            }
            //清理主对象缓存
            DeleteMainAssetBundle(_wholeNeedNames);

            lastConfigList.Clear();
            foreach (var item in curConfigList)
            {
                lastConfigList.Add(item);
            }

            DestroyImmediate(needLoadData, true);
            needLoadData = null;
            curConfigList.Clear();

            if (complete != null) complete();

            if (_callBack != null) _callBack();
        }


    }