GongYeContral.cs 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071
  1. using System.Collections.Generic;
  2. using UnityEngine;
  3. using LitJson;
  4. using System.Collections;
  5. public class GongYeContral : MonoBehaviour
  6. {
  7. private GongYeData m_GongYeData;
  8. private List<FunctionValue> m_FunctionValues;
  9. public List<FunctionValue> FunctionValues
  10. {
  11. get
  12. {
  13. if (null == m_FunctionValues)
  14. {
  15. m_FunctionValues = m_GongYeData.functionValues;
  16. }
  17. return m_FunctionValues;
  18. }
  19. set { m_FunctionValues = value; }
  20. }
  21. void Start()
  22. {
  23. StartCoroutine(GetData());
  24. }
  25. // Update is called once per frame
  26. void Update()
  27. {
  28. }
  29. /// <summary>
  30. /// 获取工业步骤内容信息
  31. /// </summary>
  32. IEnumerator GetData()
  33. {
  34. while (m_GongYeData==null)
  35. {
  36. yield return null;
  37. StartCoroutine(LoadDll2.DownLoadAssets((AssetBundle ab) => {
  38. TextAsset obj = ab.LoadAsset<TextAsset>("gongyedata");
  39. m_GongYeData = JsonMapper.ToObject<GongYeData>(obj.text);
  40. }));
  41. }
  42. yield return null;
  43. List<FunctionValue> fvList = new List<FunctionValue>();
  44. for (int i = 0; i < m_GongYeData.contentInfos.Count; i++)
  45. {
  46. FunctionValue fv = new FunctionValue();
  47. fv.index = i;
  48. fv.isShow = fv.index == m_GongYeData.defaultValue ? true : false;
  49. fv.value = 0;
  50. fvList.Add(fv);
  51. }
  52. m_GongYeData.functionValues = fvList;
  53. }
  54. }
  55. public class GongYeData
  56. {
  57. public uint moduleID;
  58. public uint functionID;
  59. public int defaultValue;// 默认值
  60. public int isShowState;
  61. public List<FunctionValue> functionValues;
  62. public List<ContentInfo> contentInfos;
  63. }