1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980 |
- using System.Collections;
- using System.Collections.Generic;
- using UnityEngine;
- using XRTool.Util;
- using XRTool.WorldUI;
- using System;
- #if UNITY_EDITOR
- using UnityEditor;
- #endif
- namespace XRTool.UI
- {
- [Serializable]
- public class ItemData
- {
- /// <summary>
- /// 对应的图标?可能为空
- /// </summary>
- public Texture2D icon;
- /// <summary>
- /// 事件的主键值
- /// </summary>
- public string actionKey;
- /// <summary>
- /// 下载地址或者路径
- /// </summary>
- public string url;
- /// <summary>
- /// 事件类型
- /// </summary>
- public int actionType;
- }
- /// <summary>
- /// 主要引用Icon3D为载体进行实例化出对应的图标
- /// 或者其他载体做一些规则排列的图标
- /// </summary>
- public class IteamConf : ScriptableObject
- {
- /// <summary>
- /// 图标引用的对象,可能为空,为空代表引用Scroll的资源
- /// </summary>
- public XRButtonToggle iteamPrefab;
- /// <summary>
- /// 模型数据
- /// </summary>
- public ItemData itemData;
- /// <summary>
- /// 缩放比例
- /// </summary>
- public Vector3 scale = Vector3.one;
- [HideInInspector]
- public int index = -1;
- public virtual void InitData(XRButtonToggle prefab)
- {
- prefab.SetImage(itemData.icon);
- }
- #if UNITY_EDITOR
- [MenuItem("Assets/Create/DataConf/IteamConf", false, 0)]
- static void CreateDynamicConf()
- {
- UnityEngine.Object obj = Selection.activeObject;
- if (obj)
- {
- string path = AssetDatabase.GetAssetPath(obj);
- IteamConf bullet = CreateInstance<IteamConf>();
- if (bullet)
- {
- string confName = UnityUtil.TryGetName<IteamConf>(path);
- AssetDatabase.CreateAsset(bullet, confName);
- }
- else
- {
- Debug.Log(typeof(IteamConf) + " is null");
- }
- }
- }
- #endif
- }
- }
|