GongYeContral.cs 1.6 KB

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