GongYeContral.cs 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970
  1. using System.Collections.Generic;
  2. using UnityEngine;
  3. using LitJson;
  4. public class GongYeContral : MonoBehaviour
  5. {
  6. public TextAsset textobj;
  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. GetData();
  24. }
  25. // Update is called once per frame
  26. void Update()
  27. {
  28. }
  29. /// <summary>
  30. /// 获取工业步骤内容信息
  31. /// </summary>
  32. private void GetData()
  33. {
  34. while (true)
  35. {
  36. m_GongYeData = JsonMapper.ToObject<GongYeData>(textobj.text);
  37. if (m_GongYeData != null)
  38. {
  39. break;
  40. }
  41. }
  42. List<FunctionValue> fvList = new List<FunctionValue>();
  43. for (int i = 0; i < m_GongYeData.contentInfos.Count; i++)
  44. {
  45. FunctionValue fv = new FunctionValue();
  46. fv.index = i;
  47. fv.isShow = fv.index == m_GongYeData.defaultValue ? true : false;
  48. fv.value = 0;
  49. fvList.Add(fv);
  50. }
  51. m_GongYeData.functionValues = fvList;
  52. }
  53. }
  54. public class GongYeData
  55. {
  56. public uint moduleID;
  57. public uint functionID;
  58. public int defaultValue;// 默认值
  59. public int isShowState;
  60. public List<FunctionValue> functionValues;
  61. public List<ContentInfo> contentInfos;
  62. }