IteamConf.cs 2.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980
  1. using System.Collections;
  2. using System.Collections.Generic;
  3. using UnityEngine;
  4. using XRTool.Util;
  5. using XRTool.WorldUI;
  6. using System;
  7. #if UNITY_EDITOR
  8. using UnityEditor;
  9. #endif
  10. namespace XRTool.UI
  11. {
  12. [Serializable]
  13. public class ItemData
  14. {
  15. /// <summary>
  16. /// 对应的图标?可能为空
  17. /// </summary>
  18. public Texture2D icon;
  19. /// <summary>
  20. /// 事件的主键值
  21. /// </summary>
  22. public string actionKey;
  23. /// <summary>
  24. /// 下载地址或者路径
  25. /// </summary>
  26. public string url;
  27. /// <summary>
  28. /// 事件类型
  29. /// </summary>
  30. public int actionType;
  31. }
  32. /// <summary>
  33. /// 主要引用Icon3D为载体进行实例化出对应的图标
  34. /// 或者其他载体做一些规则排列的图标
  35. /// </summary>
  36. public class IteamConf : ScriptableObject
  37. {
  38. /// <summary>
  39. /// 图标引用的对象,可能为空,为空代表引用Scroll的资源
  40. /// </summary>
  41. public XRButtonToggle iteamPrefab;
  42. /// <summary>
  43. /// 模型数据
  44. /// </summary>
  45. public ItemData itemData;
  46. /// <summary>
  47. /// 缩放比例
  48. /// </summary>
  49. public Vector3 scale = Vector3.one;
  50. [HideInInspector]
  51. public int index = -1;
  52. public virtual void InitData(XRButtonToggle prefab)
  53. {
  54. prefab.SetImage(itemData.icon);
  55. }
  56. #if UNITY_EDITOR
  57. [MenuItem("Assets/Create/DataConf/IteamConf", false, 0)]
  58. static void CreateDynamicConf()
  59. {
  60. UnityEngine.Object obj = Selection.activeObject;
  61. if (obj)
  62. {
  63. string path = AssetDatabase.GetAssetPath(obj);
  64. IteamConf bullet = CreateInstance<IteamConf>();
  65. if (bullet)
  66. {
  67. string confName = UnityUtil.TryGetName<IteamConf>(path);
  68. AssetDatabase.CreateAsset(bullet, confName);
  69. }
  70. else
  71. {
  72. Debug.Log(typeof(IteamConf) + " is null");
  73. }
  74. }
  75. }
  76. #endif
  77. }
  78. }