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
{
///
/// 滑动列表的配置
///
public class ScrollConf : ScriptableObject
{
///
/// 列表的内容
///
public List iteamConfs;
///
/// 显示数量
///
public int showCount;
///
/// 组件的尺寸
///
public Vector2 cellSize;
///
/// iteam的间隔,作用于layout
///
public Vector3 cellSpace = Vector2.one * 10;
///
/// 列表的元素载体
///
public XRButtonToggle iteamPrefab;
private ToggleGroup toggleGroup;
public ToggleEvent onValueChanged;
public virtual void InitData(XRScrollRect scroll)
{
//if (!toggleGroup)
//{
// toggleGroup = scroll.content.GetComponent();
//}
//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();
if (bullet)
{
string confName = UnityUtil.TryGetName(path);
AssetDatabase.CreateAsset(bullet, confName);
}
else
{
Debug.Log(typeof(ScrollConf) + " is null");
}
}
}
#endif
}
}