123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100 |
- using System;
- using System.Collections;
- using System.Collections.Generic;
- #if UNITY_EDITOR
- using UnityEditor;
- #endif
- using UnityEngine;
- using UnityEngine.UI;
- using XRTool.Util;
- using XRTool.WorldUI;
- using static UnityEngine.UI.Toggle;
- namespace XRTool.UI
- {
- /// <summary>
- /// 滑动列表的配置
- /// </summary>
- public class ScrollConf : ScriptableObject
- {
- /// <summary>
- /// 列表的内容
- /// </summary>
- public List<IteamConf> iteamConfs;
- /// <summary>
- /// 显示数量
- /// </summary>
- public int showCount;
- /// <summary>
- /// 组件的尺寸
- /// </summary>
- public Vector2 cellSize;
- /// <summary>
- /// iteam的间隔,作用于layout
- /// </summary>
- public Vector3 cellSpace = Vector2.one * 10;
- /// <summary>
- /// 列表的元素载体
- /// </summary>
- public XRButtonToggle iteamPrefab;
- private ToggleGroup toggleGroup;
- public ToggleEvent onValueChanged;
- public virtual void InitData(XRScrollRect scroll)
- {
- //if (!toggleGroup)
- //{
- // toggleGroup = scroll.content.GetComponent<ToggleGroup>();
- //}
- //XRButtonToggle togglePrefab = iteamPrefab;
- //for (int i = 0; i < iteamConfs.Count; i++)
- //{
- // IteamConf item = iteamConfs[i];
- // item.index = i;
- // var prefab = item.iteamPrefab;
- // if (!prefab)
- // {
- // prefab = togglePrefab;
- // }
- // if (prefab)
- // {
- // var toggle = Instantiate(prefab);
- // UnityUtil.SetParent(scroll.content, toggle.transform);
- // toggle.isOn = false;
- // toggle.group = toggleGroup;
- // item.InitData(toggle);
- // onValueChanged = toggle.onValueChanged;
- // }
- //}
- }
- public void SetData()
- {
- }
- #if UNITY_EDITOR
- [MenuItem("Assets/Create/DataConf/ScrollConf", false, 0)]
- static void CreateDynamicConf()
- {
- UnityEngine.Object obj = Selection.activeObject;
- if (obj)
- {
- string path = AssetDatabase.GetAssetPath(obj);
- ScrollConf bullet = CreateInstance<ScrollConf>();
- if (bullet)
- {
- string confName = UnityUtil.TryGetName<ScrollConf>(path);
- AssetDatabase.CreateAsset(bullet, confName);
- }
- else
- {
- Debug.Log(typeof(ScrollConf) + " is null");
- }
- }
- }
- #endif
- }
- }
|