GongYeContral.cs 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869
  1. using CCS.App;
  2. using System.Collections.Generic;
  3. using UnityEngine;
  4. using LitJson;
  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. 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>(((Resources.Load("config/gongyedata")) as TextAsset).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. }