修改获取数据方式
This commit is contained in:
parent
3b4fb3ac95
commit
b1f1678fab
Binary file not shown.
|
|
@ -35,7 +35,7 @@ RectTransform:
|
|||
m_AnchorMin: {x: 0, y: 0}
|
||||
m_AnchorMax: {x: 0, y: 0}
|
||||
m_AnchoredPosition: {x: 0, y: 0}
|
||||
m_SizeDelta: {x: 260, y: 50}
|
||||
m_SizeDelta: {x: 232, y: 50}
|
||||
m_Pivot: {x: 0, y: 1}
|
||||
--- !u!222 &6600844594400070395
|
||||
CanvasRenderer:
|
||||
|
|
@ -100,7 +100,7 @@ MonoBehaviour:
|
|||
m_fontSizeMin: 18
|
||||
m_fontSizeMax: 72
|
||||
m_fontStyle: 0
|
||||
m_HorizontalAlignment: 2
|
||||
m_HorizontalAlignment: 1
|
||||
m_VerticalAlignment: 512
|
||||
m_textAlignment: 65535
|
||||
m_characterSpacing: 0
|
||||
|
|
|
|||
File diff suppressed because it is too large
Load Diff
|
|
@ -90,9 +90,6 @@ public class Bootstrap : MonoSingleton<Bootstrap>
|
|||
}
|
||||
});
|
||||
|
||||
//string data = FileUtil.ReadFromLocal("WebAddress.json");
|
||||
//urlDic = JsonConvert.DeserializeObject<Dictionary<string, string>>(data);
|
||||
|
||||
webAdapter = GetComponent<WebAdapter>();
|
||||
rayHitTester = GetComponent<RayHitTester>();
|
||||
}
|
||||
|
|
@ -104,7 +101,11 @@ public class Bootstrap : MonoSingleton<Bootstrap>
|
|||
{
|
||||
//landMarks = new List<string> { "网络负荷:49.84 kw", "上网负荷:49.84 kw", "削峰负荷:49.84 kw", "填谷负荷:49.84 kw", "发电负荷:49.84 kw" };
|
||||
landMarkAndInfoCotroller.gameObject.SetActive(false);
|
||||
cameraRt.OnLimitScroll += SwitchLand;
|
||||
cameraRt.OnLimitScroll += (s) =>
|
||||
{
|
||||
SwitchLand(s);
|
||||
webAdapter.OnLevelChange(s);
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
|
|
@ -112,7 +113,7 @@ public class Bootstrap : MonoSingleton<Bootstrap>
|
|||
private void Update()
|
||||
{
|
||||
var hit = rayHitTester.HitTest();
|
||||
if (Input.GetMouseButtonDown(2))
|
||||
if (Input.GetMouseButtonDown(0))
|
||||
{
|
||||
if (hit.collider != null)
|
||||
{
|
||||
|
|
@ -246,7 +247,7 @@ public class Bootstrap : MonoSingleton<Bootstrap>
|
|||
Debug.Log("区县");
|
||||
break;
|
||||
}
|
||||
webAdapter.OnLevelChange(_currentLevel);
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
|
@ -282,6 +283,13 @@ public class Bootstrap : MonoSingleton<Bootstrap>
|
|||
{
|
||||
renderers[i].GetComponent<Collider>().enabled = true;
|
||||
renderers[i].materials = mat;
|
||||
if (renderers[i].transform.childCount > 0)
|
||||
{
|
||||
for (int j = 0; j < renderers[i].transform.childCount; j++)
|
||||
{
|
||||
renderers[i].transform.GetChild(j).gameObject.SetActive(true);
|
||||
}
|
||||
}
|
||||
}
|
||||
_fadeTweens.Remove(parent);
|
||||
});
|
||||
|
|
@ -301,6 +309,13 @@ public class Bootstrap : MonoSingleton<Bootstrap>
|
|||
{
|
||||
renderers[i].GetComponent<Collider>().enabled = false;
|
||||
renderers[i].materials = opacity;
|
||||
if(renderers[i].transform.childCount > 0)
|
||||
{
|
||||
for(int j = 0; j< renderers[i].transform.childCount; j++)
|
||||
{
|
||||
renderers[i].transform.GetChild(j).gameObject.SetActive(false);
|
||||
}
|
||||
}
|
||||
}
|
||||
List<Material> currentMaters = new List<Material>();
|
||||
for (int i = 0; i < renderers.Count; i++)
|
||||
|
|
|
|||
|
|
@ -63,6 +63,7 @@ public class CameraRT : MonoBehaviour
|
|||
bool isAutoRotating = false;
|
||||
|
||||
public bool isMove = true;
|
||||
public bool isRotate = true;
|
||||
public int[] levels;
|
||||
//动态调节相机缩放的灵敏度
|
||||
float tempSpeed;
|
||||
|
|
@ -156,7 +157,8 @@ public class CameraRT : MonoBehaviour
|
|||
Scroll();
|
||||
if (isMove)
|
||||
Move();
|
||||
Rotate();
|
||||
if (isRotate)
|
||||
Rotate();
|
||||
|
||||
Quaternion rotation = Quaternion.Euler(y, x, z);
|
||||
Vector3 disVector = new Vector3(0.0f, 0.0f, -distance);
|
||||
|
|
@ -174,7 +176,7 @@ public class CameraRT : MonoBehaviour
|
|||
cam.transform.position = position;
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -7,17 +7,25 @@ public class CityInfo : MonoBehaviour
|
|||
public string distCode;
|
||||
public string cityName;
|
||||
public ScreenTopStatistics sts = new ScreenTopStatistics();
|
||||
|
||||
public AreaData areaData = new AreaData();
|
||||
private void Start()
|
||||
{
|
||||
if (!GetComponent<Collider>())
|
||||
gameObject.AddComponent<MeshCollider>();
|
||||
|
||||
}
|
||||
public void Init()
|
||||
{
|
||||
OnSetStationInfo();
|
||||
GetAreaData();
|
||||
}
|
||||
|
||||
public async void OnSetStationInfo()
|
||||
{
|
||||
sts = await DataController.Instance.GetProvincialLevelStationInfo(distCode,cityName);
|
||||
if (distCode.Length == 6)
|
||||
sts = await DataController.Instance.GetProvincialLevelStationInfo(distCode, cityName);
|
||||
else
|
||||
sts = DataController.Instance.GetProvincialLevelStationDataByDistCode(distCode);
|
||||
if (sts != null)
|
||||
{
|
||||
transform.GetChild(0).GetComponent<AggregateStation>().SetInfo(sts.agentCons);
|
||||
|
|
@ -34,9 +42,15 @@ public class CityInfo : MonoBehaviour
|
|||
transform.GetChild(i).gameObject.SetActive(false);
|
||||
}
|
||||
}
|
||||
if (distCode.Length == 6 && transform.parent.gameObject.activeSelf)
|
||||
transform.parent.gameObject.SetActive(false);
|
||||
}
|
||||
|
||||
|
||||
public async void GetAreaData()
|
||||
{
|
||||
if (!string.IsNullOrEmpty(distCode))
|
||||
areaData = await DataController.Instance.GetAreaDataByDistCode(distCode);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -26,6 +26,22 @@ public class AreaStationData
|
|||
public string msg ;
|
||||
}
|
||||
[Serializable]
|
||||
public class DataItem
|
||||
{
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
public string distCode;
|
||||
/// <summary>
|
||||
/// 济南市
|
||||
/// </summary>
|
||||
public string disName;
|
||||
/// <summary>
|
||||
/// 用户资源统计
|
||||
/// </summary>
|
||||
public ScreenTopStatistics screenTopStatistics;
|
||||
}
|
||||
[Serializable]
|
||||
public class ScreenTopStatistics
|
||||
{
|
||||
/// <summary>
|
||||
|
|
@ -57,19 +73,4 @@ public class ScreenTopStatistics
|
|||
/// </summary>
|
||||
public string airCondition ;
|
||||
}
|
||||
[Serializable]
|
||||
public class DataItem
|
||||
{
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
public string distCode ;
|
||||
/// <summary>
|
||||
/// 济南市
|
||||
/// </summary>
|
||||
public string disName ;
|
||||
/// <summary>
|
||||
/// 用户资源统计
|
||||
/// </summary>
|
||||
public ScreenTopStatistics screenTopStatistics ;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -6,13 +6,27 @@ using UnityEngine;
|
|||
public class DataController : MonoSingleton<DataController>
|
||||
{
|
||||
public string distCode;
|
||||
// Start is called before the first frame update
|
||||
public AreaStationData areaStationData = new AreaStationData();
|
||||
public CityInfo[] cityInfos;
|
||||
|
||||
private async void Start()
|
||||
{
|
||||
areaStationData = await GetProvincialLevelStationData("37");
|
||||
cityInfos = transform.GetComponentsInChildren<CityInfo>();
|
||||
for (int i = 0; i < cityInfos.Length; i++)
|
||||
{
|
||||
cityInfos[i].Init();
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 针对区县
|
||||
/// </summary>
|
||||
/// <param name="_distCode"></param>
|
||||
/// <param name="_disName"></param>
|
||||
/// <returns></returns>
|
||||
public async UniTask<ScreenTopStatistics> GetProvincialLevelStationInfo(string _distCode, string _disName)
|
||||
{
|
||||
await UniTask.Delay(1000);
|
||||
if (_distCode.Length == 4)
|
||||
distCode = _distCode.Substring(0, 2);
|
||||
if (_distCode.Length == 6)
|
||||
distCode = _distCode.Substring(0, 4);
|
||||
string url = Bootstrap.Instance.urlDic["地图信息汇总"];
|
||||
|
|
@ -22,4 +36,50 @@ public class DataController : MonoSingleton<DataController>
|
|||
return null;
|
||||
return sts.screenTopStatistics;
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 针对省级区域
|
||||
/// </summary>
|
||||
/// <param name="_distCode"></param>
|
||||
/// <returns></returns>
|
||||
public ScreenTopStatistics GetProvincialLevelStationDataByDistCode(string _distCode)
|
||||
{
|
||||
for (int i = 0; i < areaStationData.data.Count; i++)
|
||||
{
|
||||
if (areaStationData.data[i].distCode == _distCode)
|
||||
{
|
||||
return areaStationData.data[i].screenTopStatistics;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 获取每个区域的聚合信息
|
||||
/// </summary>
|
||||
/// <param name="_distCode"></param>
|
||||
/// <returns></returns>
|
||||
public async UniTask<AreaData> GetAreaDataByDistCode(string _distCode)
|
||||
{
|
||||
await UniTask.Delay(100);
|
||||
string url = Bootstrap.Instance.urlDic["地图弹出框"];
|
||||
AreaData areaData = await AsyncWebReq.Get<AreaData>($"{url}{_distCode}", Bootstrap.Instance.webAdapter.head, Bootstrap.Instance.webAdapter.token);
|
||||
if (!bool.Parse(areaData.success)) return null;
|
||||
return areaData;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 获取地图汇总
|
||||
/// </summary>
|
||||
/// <param name="_distCode"></param>
|
||||
/// <returns></returns>
|
||||
private async UniTask<AreaStationData> GetProvincialLevelStationData(string _distCode)
|
||||
{
|
||||
string url = Bootstrap.Instance.urlDic["地图信息汇总"];
|
||||
AreaStationData areaStationData = await AsyncWebReq.Get<AreaStationData>(url + _distCode, Bootstrap.Instance.webAdapter.head, Bootstrap.Instance.webAdapter.token);
|
||||
return areaStationData;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -22,7 +22,7 @@ public class WebAdapter : MonoBehaviour
|
|||
public UnityEvent<string> onStation;
|
||||
public void OnLevelChange(int _level)
|
||||
{
|
||||
//LevelChange(_level);
|
||||
LevelChange(_level);
|
||||
//Debug.Log("UnityLog==level==" + _level);
|
||||
}
|
||||
|
||||
|
|
|
|||
Binary file not shown.
Loading…
Reference in New Issue