123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687 |
- using System.Collections;
- using System.Collections.Generic;
- using UnityEngine;
- using System.Xml;
- using System;
- using System.IO;
- namespace AIPagedLod
- {
- [System.Serializable]
- public class DataPathInfo
- {
- public string mDataName;
- public string mDataPath;
- public bool mIsDaJiangData = false;
- public int mMinLevel;
- public bool mLodEnable = false;
- }
- public enum TileDataType
- {
- OSGB = 1,
- B3DM = 2,
- UNKNOWN= 3
- }
- public class PagedLodConfig : MonoBehaviour
- {
- public static PagedLodConfig mInstance = null;
- public static int mThreadCount = 2;
- public int mExpiryFrames = 0;
- public Dictionary<string, DataPathInfo> mDataPathDict = new Dictionary<string, DataPathInfo>();
- public int mMeshLayer = 8;
- public int mCoroutineCount = 0;
- public float mLoadRadius = 3000.0f;
- public float mMaxSSE = 60.0F;
- public bool mIsLoadFromUrl = false;
- public TileDataType mTileDataType = TileDataType.UNKNOWN;
- public int mCollectCount = 0;
- public void Awake()
- {
- mInstance = this;
- #if !UNITY_EDITOR && !UNITY_WEBGL && !UNITY_ANDROID
- InitConfig();
- #endif
- }
- public string GetFileSufix()
- {
- if (mTileDataType == TileDataType.OSGB)
- return ".osgb";
- else
- return ".b3dm";
- }
- public void InitConfig()
- {
- XmlDocument xmlDoc = new XmlDocument();
- xmlDoc.Load(Application.streamingAssetsPath + "/PagedLodConfig/Config.xml");
- XmlElement mainConfig = (XmlElement)xmlDoc.DocumentElement.GetElementsByTagName("MainConfig")[0];
- mThreadCount = int.Parse(mainConfig.GetAttribute("threadCount"));
- mExpiryFrames = int.Parse(mainConfig.GetAttribute("expiryFrames"));
- mCoroutineCount = int.Parse(mainConfig.GetAttribute("coroutineCount"));
- mDataPathDict.Clear();
- XmlElement dataPathConfig = (XmlElement)xmlDoc.DocumentElement.GetElementsByTagName("DataPathConfig")[0];
- foreach (var node in dataPathConfig.ChildNodes)
- {
- XmlElement pathConfig = (XmlElement)node;
- DataPathInfo info = new DataPathInfo();
- info.mIsDaJiangData = bool.Parse(pathConfig.GetAttribute("isDaJiangData"));
- info.mDataName = pathConfig.GetAttribute("name");
- info.mDataPath = pathConfig.GetAttribute("path");
- info.mMinLevel = int.Parse(pathConfig.GetAttribute("minLevel"));
- info.mLodEnable = bool.Parse(pathConfig.GetAttribute("lodEnable"));
- mDataPathDict.Add(pathConfig.GetAttribute("name"), info);
- if (!Directory.Exists(info.mDataPath))
- {
- Directory.CreateDirectory(info.mDataPath);
- }
- }
- }
- }
- }
|