Authored Unity primitive/object-model shim, VFX layer (control-flow-preserving, InstantVfx never invokes its action -- headless suppression), god-object stubs (GameMgr/EffectMgr/UIManager with faithfully-extracted nested enums), View/UI/Touch tree, LitJson+BetterList+Tuple copied, third-party stubs. Discovered Roslyn header-error masking: fixing class-header type errors unmasks body references, so the true copy closure is ~2570 files (was 782 under masking). Errors: masked-25720 -> 268; our shim files compile clean. Remaining: ~50 residual shim/external types, 24 NGUI UI-base overrides, static-type fixes, plus likely 1-2 more unmask waves.
163 lines
4.0 KiB
C#
163 lines
4.0 KiB
C#
using System;
|
|
using System.Collections;
|
|
using System.Collections.Generic;
|
|
using Cute;
|
|
using UnityEngine;
|
|
|
|
public class UtilityDrumrollScroll : MonoBehaviour
|
|
{
|
|
[SerializeField]
|
|
private UIScrollView _scrollView;
|
|
|
|
[SerializeField]
|
|
private UIGrid _gridItemList;
|
|
|
|
[SerializeField]
|
|
private UICenterOnChild _centerOnChild;
|
|
|
|
[SerializeField]
|
|
private GameObject _itemOriginal;
|
|
|
|
private List<GameObject> _itemList = new List<GameObject>();
|
|
|
|
private bool _isDrag;
|
|
|
|
private Action<int> _selectCallBack;
|
|
|
|
[SerializeField]
|
|
private UIButton _upButton;
|
|
|
|
[SerializeField]
|
|
private UIButton _downButton;
|
|
|
|
[SerializeField]
|
|
private UIPanel _panel;
|
|
|
|
public int CurrentIndex { get; private set; }
|
|
|
|
public IEnumerator CreateDrumrollScroll_Coroutine(List<string> textList, int defaultIndex, Action<int> selectCallback, Action callBack = null)
|
|
{
|
|
if (_panel != null)
|
|
{
|
|
_panel.alpha = 0f;
|
|
}
|
|
_InitList();
|
|
CurrentIndex = defaultIndex;
|
|
_selectCallBack = selectCallback;
|
|
for (int i = 0; i < textList.Count; i++)
|
|
{
|
|
_AddList(i, textList[i]);
|
|
UIEventListener uIEventListener = UIEventListener.Get(_itemList[i]);
|
|
uIEventListener.onClick = (UIEventListener.VoidDelegate)Delegate.Combine(uIEventListener.onClick, (UIEventListener.VoidDelegate)delegate(GameObject g)
|
|
{
|
|
_OnChangeScroll(g);
|
|
});
|
|
}
|
|
yield return null;
|
|
_centerOnChild.onCenter = null;
|
|
float springStrength = _centerOnChild.springStrength;
|
|
_centerOnChild.springStrength = 100f;
|
|
_centerOnChild.CenterOn(_itemList[defaultIndex].transform);
|
|
_centerOnChild.springStrength = springStrength;
|
|
_centerOnChild.onCenter = delegate(GameObject g)
|
|
{
|
|
_isDrag = true;
|
|
_OnChangeScroll(g);
|
|
};
|
|
if (_itemList.Count <= 1)
|
|
{
|
|
_scrollView.enabled = false;
|
|
}
|
|
if (_upButton != null)
|
|
{
|
|
_upButton.onClick.Add(new EventDelegate(delegate
|
|
{
|
|
OnClickUpButton();
|
|
}));
|
|
}
|
|
if (_downButton != null)
|
|
{
|
|
_downButton.onClick.Add(new EventDelegate(delegate
|
|
{
|
|
OnClickDownButton();
|
|
}));
|
|
}
|
|
callBack.Call();
|
|
yield return null;
|
|
if (_panel != null)
|
|
{
|
|
_panel.alpha = 1f;
|
|
}
|
|
}
|
|
|
|
private void OnClickUpButton()
|
|
{
|
|
if (CurrentIndex > 0)
|
|
{
|
|
_centerOnChild.CenterOn(_itemList[CurrentIndex - 1].transform);
|
|
}
|
|
}
|
|
|
|
private void OnClickDownButton()
|
|
{
|
|
if (CurrentIndex < _itemList.Count - 1)
|
|
{
|
|
_centerOnChild.CenterOn(_itemList[CurrentIndex + 1].transform);
|
|
}
|
|
}
|
|
|
|
private void _InitList()
|
|
{
|
|
if (_itemList.Count > 0)
|
|
{
|
|
foreach (GameObject item in _itemList)
|
|
{
|
|
UnityEngine.Object.Destroy(item.gameObject);
|
|
}
|
|
}
|
|
_itemList.Clear();
|
|
_itemOriginal.gameObject.SetActive(value: false);
|
|
}
|
|
|
|
private void _AddList(int index, string text, bool isNew = false)
|
|
{
|
|
GameObject gameObject = UnityEngine.Object.Instantiate(_itemOriginal.gameObject);
|
|
gameObject.transform.parent = _gridItemList.transform;
|
|
gameObject.transform.localScale = _itemOriginal.transform.localScale;
|
|
gameObject.name = index.ToString();
|
|
gameObject.gameObject.SetActive(value: true);
|
|
UtilityDrumrollItem utilityDrumrollItem = gameObject.GetComponent<UtilityDrumrollItem>();
|
|
if (utilityDrumrollItem == null)
|
|
{
|
|
utilityDrumrollItem = gameObject.AddComponent<UtilityDrumrollItem>();
|
|
}
|
|
utilityDrumrollItem.Init(_scrollView.GetComponent<UIPanel>(), index, text);
|
|
if (utilityDrumrollItem.CustomizeItem != null)
|
|
{
|
|
utilityDrumrollItem.CustomizeItem.OnInitialize(index);
|
|
}
|
|
_itemList.Add(gameObject);
|
|
_gridItemList.repositionNow = true;
|
|
_scrollView.ResetPosition();
|
|
}
|
|
|
|
private void _OnChangeScroll(GameObject g)
|
|
{
|
|
int index = g.GetComponent<UtilityDrumrollItem>()._index;
|
|
if (CurrentIndex != index)
|
|
{
|
|
CurrentIndex = index;
|
|
GameMgr.GetIns().GetSoundMgr().PlaySe(Se.TYPE.SYS_SLIDE_BTN);
|
|
if (!_isDrag)
|
|
{
|
|
_centerOnChild.CenterOn(g.transform);
|
|
}
|
|
else
|
|
{
|
|
_isDrag = false;
|
|
}
|
|
_selectCallBack.Call(CurrentIndex);
|
|
}
|
|
}
|
|
}
|