2024-03-14 16:41:05 +08:00
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
|
using cfg.CharacterCfg;
|
2024-03-19 19:23:42 +08:00
|
|
|
|
using cfg.ShowCfg;
|
2024-03-18 16:20:35 +08:00
|
|
|
|
using Cysharp.Threading.Tasks;
|
2024-03-14 16:41:05 +08:00
|
|
|
|
using TMPro;
|
|
|
|
|
|
using UnityEngine;
|
|
|
|
|
|
using UnityEngine.UI;
|
|
|
|
|
|
using Button = UnityEngine.UI.Button;
|
|
|
|
|
|
using Image = UnityEngine.UI.Image;
|
|
|
|
|
|
using Framework;
|
|
|
|
|
|
using Gameplay;
|
2024-03-19 19:23:42 +08:00
|
|
|
|
using Gameplay.SubSystems;
|
2024-03-14 16:41:05 +08:00
|
|
|
|
using PhxhSDK;
|
2024-06-13 16:40:13 +08:00
|
|
|
|
using System.Threading;
|
|
|
|
|
|
using UnityEngine.EventSystems;
|
2024-06-14 17:01:31 +08:00
|
|
|
|
using UnityEngine.Events;
|
|
|
|
|
|
using System;
|
2024-06-21 15:06:21 +08:00
|
|
|
|
using cfg.ActorCfg;
|
2024-03-14 16:41:05 +08:00
|
|
|
|
|
|
|
|
|
|
public class UICameraAndPosterChangeController : UIWindow
|
|
|
|
|
|
{
|
2024-06-13 14:49:04 +08:00
|
|
|
|
# region UI GameObj
|
|
|
|
|
|
///Auto Gen Start///
|
|
|
|
|
|
public Image Image_CBG;
|
2024-03-14 16:41:05 +08:00
|
|
|
|
public Button Button_Back;
|
|
|
|
|
|
public TMP_Text Text_Back;
|
|
|
|
|
|
public Button Button_Home;
|
|
|
|
|
|
public Button Button_Scene01;
|
|
|
|
|
|
public Button Button_Scene02;
|
|
|
|
|
|
public Image Image_View01;
|
|
|
|
|
|
public Image Image_View02;
|
|
|
|
|
|
public Image Image_View03;
|
|
|
|
|
|
public TMP_Text Text_ChangeThisScene;
|
|
|
|
|
|
public Button Button_Scene03;
|
|
|
|
|
|
public Button Button_Scene04;
|
|
|
|
|
|
public Button Button_Confirm;
|
|
|
|
|
|
public TMP_Text Text_BtnConfirm;
|
|
|
|
|
|
public Button Button_Cancel;
|
|
|
|
|
|
public Button Button_ChangePoster;
|
|
|
|
|
|
public TMP_Text Text_ChangePoster;
|
|
|
|
|
|
public Button Button_ChangeScene;
|
|
|
|
|
|
public TMP_Text Text_ChangeScene;
|
|
|
|
|
|
public Image Image_Menu;
|
|
|
|
|
|
public Button Button_Rarity;
|
|
|
|
|
|
public TMP_Text Text_Rarity;
|
|
|
|
|
|
public TMP_Text Text_RaritySelect;
|
|
|
|
|
|
public Button Button_Level;
|
|
|
|
|
|
public TMP_Text Text_Lv;
|
|
|
|
|
|
public TMP_Text Text_LvSelect;
|
|
|
|
|
|
public Image Image_Lv;
|
2024-04-03 16:15:49 +08:00
|
|
|
|
//public Image Image_Down1;
|
2024-03-14 16:41:05 +08:00
|
|
|
|
public Button Button_AdvanceLevel;
|
|
|
|
|
|
public TMP_Text Text_AdvSelect;
|
|
|
|
|
|
public TMP_Text Text_Advance;
|
2024-04-03 16:15:49 +08:00
|
|
|
|
//public Image Image_Down2;
|
2024-03-14 16:41:05 +08:00
|
|
|
|
public TMP_Dropdown Dropdown_ChangeLevel;
|
|
|
|
|
|
public TMP_Text Text_Profession;
|
|
|
|
|
|
public Button Button_Confirm01;
|
|
|
|
|
|
public TMP_Text Text_Confirm;
|
|
|
|
|
|
public Button Button_Cancel01;
|
2024-04-22 14:51:37 +08:00
|
|
|
|
|
2024-06-04 14:10:39 +08:00
|
|
|
|
public Button Button_ChangeLocation;
|
2024-06-11 13:21:27 +08:00
|
|
|
|
public Button Button_HidePic;
|
|
|
|
|
|
public Button Button_HidePicDown;
|
2024-03-14 16:41:05 +08:00
|
|
|
|
|
2024-06-04 14:10:39 +08:00
|
|
|
|
///Auto Gen End///
|
2024-06-13 14:49:04 +08:00
|
|
|
|
#endregion
|
2024-06-04 14:10:39 +08:00
|
|
|
|
|
|
|
|
|
|
public static async UniTask<UIWindow> Open()
|
2024-04-22 14:51:37 +08:00
|
|
|
|
{
|
2024-08-13 14:29:50 +08:00
|
|
|
|
await CommonUtils.CaptureScreenshot();
|
2024-04-22 14:51:37 +08:00
|
|
|
|
|
2024-05-16 12:40:15 +08:00
|
|
|
|
return await UIManager.Instance.CreateAndOpenWindow(UINameConst.UICameraAndPosterChange);
|
2024-04-22 14:51:37 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
2024-06-04 17:17:16 +08:00
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// 在首页编辑完成看板娘之后重新激活显示此界面
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
/// <param name="deltaPos"></param>
|
|
|
|
|
|
/// <param name="scale"></param>
|
2024-06-04 14:10:39 +08:00
|
|
|
|
public static void ShowWindowInactived(Vector2 deltaPos, float scale)
|
|
|
|
|
|
{
|
2024-06-04 17:17:16 +08:00
|
|
|
|
UIManager.Instance.Show(UINameConst.UICameraAndPosterChange, isMainCameraClose: false);//显示弹窗界面时关闭主相机
|
2024-06-04 14:10:39 +08:00
|
|
|
|
EventManager.Instance.Send(EventManager.EventName.MainPanelPosterRelocate, new MainPanelSceneStoreData(0, 0, 0, 0, deltaPos, scale));
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// 背景模糊
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
private RawImage rawImageGaussianBlurMask;
|
2024-04-22 14:51:37 +08:00
|
|
|
|
|
|
|
|
|
|
//test data
|
|
|
|
|
|
private List<string> _testImgList = new()
|
2024-03-14 16:41:05 +08:00
|
|
|
|
{
|
|
|
|
|
|
"Assets/Art/UI/Texture/CameraChange/NewCameraChange/UI_Pic01.png",
|
|
|
|
|
|
"Assets/Art/UI/Texture/CameraChange/NewCameraChange/UI_Pic02.png",
|
|
|
|
|
|
"Assets/Art/UI/Texture/CameraChange/NewCameraChange/UI_Pic03.png",
|
|
|
|
|
|
"Assets/Art/UI/Texture/CameraChange/NewCameraChange/UI_Pic04.png",
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
private enum PageEnum
|
|
|
|
|
|
{
|
|
|
|
|
|
Scene,
|
|
|
|
|
|
Poster
|
|
|
|
|
|
}
|
2024-03-20 16:25:29 +08:00
|
|
|
|
|
|
|
|
|
|
private enum SortType
|
|
|
|
|
|
{
|
2024-04-03 16:15:49 +08:00
|
|
|
|
None,
|
2024-03-20 16:25:29 +08:00
|
|
|
|
Rarity,
|
|
|
|
|
|
Level,
|
|
|
|
|
|
Likely
|
|
|
|
|
|
}
|
2024-03-14 16:41:05 +08:00
|
|
|
|
|
2024-03-18 16:31:11 +08:00
|
|
|
|
private PageEnum _curPage = PageEnum.Poster;//当前切页
|
2024-03-14 16:41:05 +08:00
|
|
|
|
private GameObject _sceneObj;
|
|
|
|
|
|
private GameObject _posterObj;
|
2024-04-03 16:15:49 +08:00
|
|
|
|
private SortType _sortType = SortType.None;
|
|
|
|
|
|
private bool _isUpSort = true;
|
|
|
|
|
|
|
2024-06-14 17:01:31 +08:00
|
|
|
|
|
|
|
|
|
|
private ScenePanelScrollView SceneScrollView = new();//场景切换页面列表类
|
|
|
|
|
|
private SkinPanelScrollView SkinScrollView = new();//看板娘皮肤切换列表类
|
|
|
|
|
|
|
2024-06-13 14:49:04 +08:00
|
|
|
|
private int _curSceneIndex;
|
2024-03-14 16:41:05 +08:00
|
|
|
|
private int _curCameraPosIdx;
|
|
|
|
|
|
|
|
|
|
|
|
//立绘切换页面
|
2024-04-02 19:02:09 +08:00
|
|
|
|
private RecycleView _scrollPosterPool;
|
2024-06-14 17:01:31 +08:00
|
|
|
|
|
|
|
|
|
|
//private PhxhScrollView _scrollSkin;
|
|
|
|
|
|
//private GameObject _skinItemTemp;
|
2024-03-14 16:41:05 +08:00
|
|
|
|
|
|
|
|
|
|
private List<uint> _charIDList;
|
2024-03-20 16:25:29 +08:00
|
|
|
|
private List<uint> _displayIDList;
|
2024-03-14 16:41:05 +08:00
|
|
|
|
private int _curSelect; //当前选择的角色
|
|
|
|
|
|
private int _curSelectSkin; //当前选择的皮肤
|
|
|
|
|
|
private List<DataCharacterSkin> _skinDataList; //当前选择角色的皮肤列表
|
2024-06-07 15:07:29 +08:00
|
|
|
|
|
|
|
|
|
|
private bool _isHidePoster = false;//立绘显示开关
|
2024-06-07 16:00:18 +08:00
|
|
|
|
|
|
|
|
|
|
private bool PosterHide
|
|
|
|
|
|
{
|
|
|
|
|
|
set
|
|
|
|
|
|
{
|
|
|
|
|
|
_isHidePoster = value;
|
|
|
|
|
|
RefreshPosterHideButton();
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2024-06-07 15:07:29 +08:00
|
|
|
|
private MainPanelSceneStoreData _saveData;
|
2024-03-14 16:41:05 +08:00
|
|
|
|
|
|
|
|
|
|
// deal with input data
|
|
|
|
|
|
public override void PreLoad(object data = null)
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// Use this for initialization
|
|
|
|
|
|
public override void OnInit()
|
|
|
|
|
|
{
|
2024-08-09 18:05:11 +08:00
|
|
|
|
CommonUtils.ScreenshotReset();
|
2024-03-14 16:41:05 +08:00
|
|
|
|
//bind UI GameObj
|
|
|
|
|
|
UICameraAndPosterChangeBinder.GetComponents(this);
|
2024-04-22 14:51:37 +08:00
|
|
|
|
|
|
|
|
|
|
rawImageGaussianBlurMask = GetComponent<RawImage>("GaussianBlurMask");
|
|
|
|
|
|
_sceneObj = FindObj("ImageBG/SceneChange");
|
2024-03-14 16:41:05 +08:00
|
|
|
|
_posterObj = FindObj("ImageBG/PosterChange");
|
|
|
|
|
|
|
2024-08-15 13:31:51 +08:00
|
|
|
|
rawImageGaussianBlurMask.texture = CommonUtils.GetScreenTexture2D();
|
2024-04-22 14:51:37 +08:00
|
|
|
|
|
2024-08-15 13:31:51 +08:00
|
|
|
|
SceneScrollView.SetScrollRect(GetComponent<PhxhScrollView>("ImageBG/SceneChange/SceneScrollView"));
|
2024-06-14 17:01:31 +08:00
|
|
|
|
SceneScrollView.InitItemCellList(SceneScrollView.SceneItemCount());
|
2024-03-14 16:41:05 +08:00
|
|
|
|
|
2024-04-02 19:02:09 +08:00
|
|
|
|
_scrollPosterPool = GetComponent<RecycleView>("ImageBG/PosterChange/ChangeHeadPic/PosterScrollView");
|
2024-06-14 17:01:31 +08:00
|
|
|
|
|
|
|
|
|
|
SkinScrollView.SetScrollRect(GetComponent<PhxhScrollView>("ImageBG/PosterChange/ChangeSkin/ScrollView"));
|
2024-03-14 16:41:05 +08:00
|
|
|
|
|
|
|
|
|
|
_charIDList = new List<uint>();
|
|
|
|
|
|
var charList = CharacterDataInfoManager.Instance.DataList;
|
|
|
|
|
|
for (int i = 0; i < charList.Count; i++)
|
|
|
|
|
|
{
|
|
|
|
|
|
_charIDList.Add(charList[i].Uid);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2024-06-14 17:01:31 +08:00
|
|
|
|
BindSceneScrollView();
|
2024-06-13 16:40:13 +08:00
|
|
|
|
|
2024-06-14 17:01:31 +08:00
|
|
|
|
BindSkinScrollView();
|
2024-06-13 16:40:13 +08:00
|
|
|
|
|
2024-06-13 14:49:04 +08:00
|
|
|
|
BindButton(Button_Back, _OnClickClose);
|
2024-03-14 16:41:05 +08:00
|
|
|
|
BindButton(Button_ChangePoster, _OnClickPosterTab);
|
|
|
|
|
|
BindButton(Button_ChangeScene, _OnClickSceneTab);
|
|
|
|
|
|
BindButton(Button_Confirm, _OnClickSceneConfirm);
|
|
|
|
|
|
BindButton(Button_Confirm01, _OnClickPosterConfirm);
|
2024-04-03 16:15:49 +08:00
|
|
|
|
BindButton(Button_Home, _OnClickHome);
|
|
|
|
|
|
|
|
|
|
|
|
BindButton(Button_Rarity, _OnClickSortBtn, SortType.Rarity);
|
|
|
|
|
|
BindButton(Button_Level, _OnClickSortBtn, SortType.Level);
|
|
|
|
|
|
BindButton(Button_AdvanceLevel, _OnClickSortBtn, SortType.Likely);
|
2024-06-07 15:07:29 +08:00
|
|
|
|
|
2024-06-11 13:21:27 +08:00
|
|
|
|
BindButton(Button_HidePic, OnClickHideKanbanban);
|
|
|
|
|
|
BindButton(Button_HidePicDown, OnClickHideKanbanban);
|
2024-06-07 15:07:29 +08:00
|
|
|
|
|
|
|
|
|
|
BindButton(Button_ChangeLocation, OnClickAdjustPoster);
|
2024-06-04 14:10:39 +08:00
|
|
|
|
|
|
|
|
|
|
EventManager.Instance.Register<MainPanelSceneStoreData>(EventManager.EventName.MainPanelPosterRelocate, ResetPosterPosition);
|
2024-03-14 16:41:05 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
//invoke when open window
|
|
|
|
|
|
protected override void OnShowWindow(object data = null)
|
|
|
|
|
|
{
|
2024-06-04 17:17:16 +08:00
|
|
|
|
base.OnShowWindow(data);
|
2024-03-14 16:41:05 +08:00
|
|
|
|
_InitSceneScroll();
|
|
|
|
|
|
_InitPosterScroll();
|
|
|
|
|
|
_Refresh();
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//invoke when reload window
|
|
|
|
|
|
protected override void OnReloadWindow(object data = null)
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
//invoke when close window
|
|
|
|
|
|
protected override void OnHideWindow()
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
//invoke when destroy
|
|
|
|
|
|
public override void OnRelease()
|
|
|
|
|
|
{
|
|
|
|
|
|
base.OnRelease();
|
2024-06-14 17:01:31 +08:00
|
|
|
|
SceneScrollView.Release();
|
|
|
|
|
|
SkinScrollView.Release();
|
|
|
|
|
|
EventManager.Instance.Unregister<MainPanelSceneStoreData>(EventManager.EventName.MainPanelPosterRelocate, ResetPosterPosition);
|
2024-06-04 14:10:39 +08:00
|
|
|
|
}
|
2024-03-14 16:41:05 +08:00
|
|
|
|
|
|
|
|
|
|
#region #Event Function
|
|
|
|
|
|
|
|
|
|
|
|
protected override void OnUpdate()
|
|
|
|
|
|
{
|
|
|
|
|
|
base.OnUpdate();
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// 刷新界面
|
|
|
|
|
|
/// </summary>
|
2024-04-03 16:15:49 +08:00
|
|
|
|
#region RefreshPanel
|
2024-03-14 16:41:05 +08:00
|
|
|
|
|
|
|
|
|
|
private void _Refresh()
|
|
|
|
|
|
{
|
|
|
|
|
|
_RefreshTab();
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2024-06-18 16:22:42 +08:00
|
|
|
|
private void _RefreshTab()
|
2024-03-14 16:41:05 +08:00
|
|
|
|
{
|
|
|
|
|
|
switch (_curPage)
|
|
|
|
|
|
{
|
|
|
|
|
|
case PageEnum.Scene:
|
2024-06-04 14:10:39 +08:00
|
|
|
|
{
|
2024-06-17 13:54:58 +08:00
|
|
|
|
int index = _curSceneIndex;
|
|
|
|
|
|
Button_ChangePoster.gameObject.SetActive(false);
|
2024-06-04 14:10:39 +08:00
|
|
|
|
Button_ChangeScene.gameObject.SetActive(true);
|
|
|
|
|
|
_sceneObj.SetActive(true);
|
|
|
|
|
|
_posterObj.SetActive(false);
|
|
|
|
|
|
Image_CBG.gameObject.SetActive(false);
|
|
|
|
|
|
Button_ChangeLocation.gameObject.SetActive(false);
|
2024-06-11 13:21:27 +08:00
|
|
|
|
Button_HidePic.gameObject.SetActive(false);
|
|
|
|
|
|
Button_HidePicDown.gameObject.SetActive(false);
|
2024-06-04 14:10:39 +08:00
|
|
|
|
|
2024-06-18 16:22:42 +08:00
|
|
|
|
_SetPosYListData();
|
2024-06-17 13:54:58 +08:00
|
|
|
|
SceneScrollView.UpdateData();
|
2024-06-18 16:22:42 +08:00
|
|
|
|
//await UniTask.DelayFrame(1);
|
2024-06-17 13:54:58 +08:00
|
|
|
|
SceneScrollView.ScrollTo(index);
|
2024-06-14 17:01:31 +08:00
|
|
|
|
//LayoutRebuilder.ForceRebuildLayoutImmediate(_sceneScrollContent.GetComponent<RectTransform>());
|
2024-06-04 14:10:39 +08:00
|
|
|
|
break;
|
|
|
|
|
|
}
|
2024-03-14 16:41:05 +08:00
|
|
|
|
case PageEnum.Poster:
|
2024-06-04 14:10:39 +08:00
|
|
|
|
{
|
2024-06-18 15:33:33 +08:00
|
|
|
|
int index = _curSelectSkin;
|
|
|
|
|
|
Button_ChangePoster.gameObject.SetActive(true);
|
2024-06-04 14:10:39 +08:00
|
|
|
|
Button_ChangeScene.gameObject.SetActive(false);
|
|
|
|
|
|
_sceneObj.SetActive(false);
|
|
|
|
|
|
_posterObj.SetActive(true);
|
|
|
|
|
|
Image_CBG.gameObject.SetActive(true);
|
|
|
|
|
|
_RefreshPosterButton();
|
2024-06-14 17:01:31 +08:00
|
|
|
|
|
|
|
|
|
|
SkinScrollView.UpdateData();
|
2024-06-18 16:22:42 +08:00
|
|
|
|
//await UniTask.DelayFrame(1);
|
2024-06-18 15:33:33 +08:00
|
|
|
|
SkinScrollView.ScrollTo(index);
|
2024-06-17 13:54:58 +08:00
|
|
|
|
break;
|
2024-06-04 14:10:39 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
2024-03-14 16:41:05 +08:00
|
|
|
|
default:
|
|
|
|
|
|
break;
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2024-03-20 16:25:29 +08:00
|
|
|
|
#region DropDown
|
|
|
|
|
|
|
|
|
|
|
|
private void _DropDown()
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
2024-03-14 16:41:05 +08:00
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// 更换场景
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
#region ScenePage
|
|
|
|
|
|
|
2024-06-14 17:01:31 +08:00
|
|
|
|
void BindSceneScrollView()
|
|
|
|
|
|
{
|
|
|
|
|
|
SceneScrollView.AddValueChangeListener(_OnScrollViewValChange);
|
|
|
|
|
|
SceneScrollView.SetItemCountFunc(SceneScrollView.SceneItemCount);
|
2024-06-17 17:50:08 +08:00
|
|
|
|
SceneScrollView.SetItemSizeFunc((index) => SceneScrollView.SceneItemSize(index, _curSceneIndex));//GetItemSizeFromList(index));//
|
2024-06-14 17:01:31 +08:00
|
|
|
|
SceneScrollView.SetUpdateFunc(_RefreshSceneItem);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2024-03-20 16:25:29 +08:00
|
|
|
|
private void _RefreshSceneButtons()
|
|
|
|
|
|
{
|
|
|
|
|
|
if (_saveData != null)
|
|
|
|
|
|
{
|
|
|
|
|
|
if (_curSceneIndex == _saveData.SceneIdx && _curCameraPosIdx == _saveData.CameraPosIdx)
|
|
|
|
|
|
{
|
|
|
|
|
|
Button_Confirm.gameObject.SetActive(false);
|
|
|
|
|
|
Button_Cancel.gameObject.SetActive(true);
|
|
|
|
|
|
}
|
|
|
|
|
|
else
|
|
|
|
|
|
{
|
|
|
|
|
|
Button_Confirm.gameObject.SetActive(true);
|
|
|
|
|
|
Button_Cancel.gameObject.SetActive(false);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
return;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
var storeData = StorageMgr.Instance.GetStorage<MainPanelSceneStoreData>("MainPanelSceneStoreData");
|
|
|
|
|
|
if (storeData != null)
|
|
|
|
|
|
{
|
|
|
|
|
|
if (_curSceneIndex == storeData.SceneIdx && _curCameraPosIdx == storeData.CameraPosIdx)
|
|
|
|
|
|
{
|
|
|
|
|
|
Button_Confirm.gameObject.SetActive(false);
|
|
|
|
|
|
Button_Cancel.gameObject.SetActive(true);
|
|
|
|
|
|
}
|
|
|
|
|
|
else
|
|
|
|
|
|
{
|
|
|
|
|
|
Button_Confirm.gameObject.SetActive(true);
|
|
|
|
|
|
Button_Cancel.gameObject.SetActive(false);
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
2024-03-14 16:41:05 +08:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private void _RefreshSingleItem(GameObject go, int index)
|
|
|
|
|
|
{
|
|
|
|
|
|
var btnScene = CommonUtils.GetComponent<Button>(go, "ButtonScene");
|
|
|
|
|
|
var btnFull = CommonUtils.GetComponent<Button>(go, "ButtonSceneFull");
|
2024-03-18 16:20:35 +08:00
|
|
|
|
|
|
|
|
|
|
List<Button> btnViewList = new List<Button>();
|
|
|
|
|
|
for (int i = 0; i < 3; i++)
|
|
|
|
|
|
{
|
|
|
|
|
|
var btn = CommonUtils.GetComponent<Button>(go, "ButtonSceneFull/ImageView" + i);
|
|
|
|
|
|
btnViewList.Add(btn);
|
|
|
|
|
|
}
|
2024-06-13 14:49:04 +08:00
|
|
|
|
|
|
|
|
|
|
if (_curSceneIndex + 1 == index)
|
2024-03-14 16:41:05 +08:00
|
|
|
|
{
|
|
|
|
|
|
btnFull.gameObject.SetActive(true);
|
|
|
|
|
|
btnScene.gameObject.SetActive(false);
|
2024-06-13 14:49:04 +08:00
|
|
|
|
_RefreshItemView(go);
|
2024-03-14 16:41:05 +08:00
|
|
|
|
}
|
|
|
|
|
|
else
|
|
|
|
|
|
{
|
|
|
|
|
|
btnScene.gameObject.SetActive(true);
|
|
|
|
|
|
btnFull.gameObject.SetActive(false);
|
|
|
|
|
|
}
|
2024-03-18 16:20:35 +08:00
|
|
|
|
|
|
|
|
|
|
for (int i = 0; i < btnViewList.Count; i++)
|
|
|
|
|
|
{
|
|
|
|
|
|
var imgSelect = CommonUtils.GetGameObject(btnViewList[i].gameObject, "ImageYellow");
|
|
|
|
|
|
var imgGray = CommonUtils.GetGameObject(btnViewList[i].gameObject, "ImageGrey");
|
|
|
|
|
|
|
|
|
|
|
|
imgSelect.SetActive(_curCameraPosIdx == i);
|
|
|
|
|
|
imgGray.SetActive(_curCameraPosIdx != i);
|
|
|
|
|
|
|
|
|
|
|
|
ClearBind(btnViewList[i]);
|
|
|
|
|
|
|
|
|
|
|
|
BindButton(btnViewList[i], _OnClickCameraPos, i);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
private void _RefreshItemView(GameObject go)
|
|
|
|
|
|
{
|
|
|
|
|
|
List<GameObject> goViewList = new List<GameObject>();
|
|
|
|
|
|
for (int i = 0; i < 3; i++)
|
|
|
|
|
|
{
|
|
|
|
|
|
var obj = CommonUtils.GetGameObject(go, "ButtonSceneFull/ImageView" + i);
|
|
|
|
|
|
goViewList.Add(obj);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
for (int i = 0; i < goViewList.Count; i++)
|
|
|
|
|
|
{
|
|
|
|
|
|
var imgSelect = CommonUtils.GetGameObject(goViewList[i], "ImageYellow");
|
|
|
|
|
|
var imgGray = CommonUtils.GetGameObject(goViewList[i], "ImageGrey");
|
2024-04-02 14:07:26 +08:00
|
|
|
|
var imgMaskBg = CommonUtils.GetGameObject(goViewList[i], "ImageBlackCover");
|
2024-03-18 16:20:35 +08:00
|
|
|
|
|
|
|
|
|
|
imgSelect.SetActive(_curCameraPosIdx == i);
|
|
|
|
|
|
imgGray.SetActive(_curCameraPosIdx != i);
|
2024-04-02 14:07:26 +08:00
|
|
|
|
imgMaskBg.SetActive(_curCameraPosIdx == i);
|
2024-03-18 16:20:35 +08:00
|
|
|
|
}
|
2024-03-14 16:41:05 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
private void _OnScrollViewValChange(Vector2 pos)
|
|
|
|
|
|
{
|
2024-06-14 17:01:31 +08:00
|
|
|
|
var curIndex = SceneScrollView.GetClosestIdx(_curSceneIndex);
|
2024-03-14 16:41:05 +08:00
|
|
|
|
if (curIndex == _curSceneIndex)
|
|
|
|
|
|
{
|
|
|
|
|
|
return;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
_curSceneIndex = curIndex;
|
2024-03-18 16:20:35 +08:00
|
|
|
|
_curCameraPosIdx = 0;
|
2024-03-14 16:41:05 +08:00
|
|
|
|
_SetPosYListData();
|
2024-06-13 14:49:04 +08:00
|
|
|
|
_RefreshSceneButtons();
|
2024-06-14 17:01:31 +08:00
|
|
|
|
SceneScrollView.UpdateData();
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
//#if UNITY_EDITOR
|
|
|
|
|
|
// void SceneItemDebugText(RectTransform item)
|
|
|
|
|
|
// {
|
|
|
|
|
|
// if (CommonUtils.GetGameObject(item.gameObject, "txt") == null)
|
|
|
|
|
|
// {
|
|
|
|
|
|
// GameObject txt = new GameObject("txt");
|
|
|
|
|
|
// txt.transform.SetParent(item);
|
|
|
|
|
|
// txt.transform.localPosition = Vector3.zero;
|
|
|
|
|
|
// txt.transform.localScale = Vector3.one;
|
|
|
|
|
|
// var TXT = txt.AddComponent<TextMeshProUGUI>();
|
|
|
|
|
|
// txt.AddComponent<LayoutElement>().ignoreLayout = true;
|
|
|
|
|
|
// txt.AddComponent<AspectRatioFitter>().aspectMode = AspectRatioFitter.AspectMode.FitInParent;
|
|
|
|
|
|
// TXT.color = Color.red;
|
|
|
|
|
|
// TXT.enableAutoSizing = true;
|
|
|
|
|
|
// }
|
|
|
|
|
|
// }
|
|
|
|
|
|
//#endif
|
|
|
|
|
|
private void _RefreshSceneItem(int index, RectTransform item)
|
|
|
|
|
|
{
|
|
|
|
|
|
if (index == 0 || index == SceneScrollView.SceneItemCount() - 1)
|
2024-06-13 14:49:04 +08:00
|
|
|
|
{
|
|
|
|
|
|
item.gameObject.SetActive(false);
|
|
|
|
|
|
return;
|
|
|
|
|
|
}
|
|
|
|
|
|
var go = item.gameObject;
|
|
|
|
|
|
go.SetActive(true);
|
|
|
|
|
|
|
|
|
|
|
|
_RefreshSingleItem(go, index);
|
2024-06-14 17:01:31 +08:00
|
|
|
|
foreach (var cell in SceneScrollView._itemCells)
|
2024-06-13 14:49:04 +08:00
|
|
|
|
{
|
|
|
|
|
|
if (cell.index == index)
|
|
|
|
|
|
{
|
|
|
|
|
|
cell.GoRoot = go;
|
2024-06-14 17:01:31 +08:00
|
|
|
|
if (SceneScrollView._shownItemList.ContainsKey(go.GetInstanceID()))
|
2024-06-13 14:49:04 +08:00
|
|
|
|
{
|
2024-06-14 17:01:31 +08:00
|
|
|
|
SceneScrollView._shownItemList[go.GetInstanceID()] = cell;
|
2024-06-13 14:49:04 +08:00
|
|
|
|
}
|
|
|
|
|
|
else
|
|
|
|
|
|
{
|
2024-06-14 17:01:31 +08:00
|
|
|
|
SceneScrollView._shownItemList.Add(go.GetInstanceID(), cell);
|
2024-06-13 14:49:04 +08:00
|
|
|
|
}
|
|
|
|
|
|
break;
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
int id = index - 1;
|
|
|
|
|
|
ClearBind(CommonUtils.GetComponent<Button>(go, "ButtonScene"));
|
|
|
|
|
|
BindButton(CommonUtils.GetComponent<Button>(go, "ButtonScene"), () =>
|
|
|
|
|
|
{
|
|
|
|
|
|
_curSceneIndex = id;
|
2024-06-13 15:13:06 +08:00
|
|
|
|
_curCameraPosIdx = 0;
|
2024-06-14 17:01:31 +08:00
|
|
|
|
_SetPosYListData();
|
2024-06-13 14:49:04 +08:00
|
|
|
|
_RefreshSceneButtons();
|
2024-06-14 17:01:31 +08:00
|
|
|
|
SceneScrollView.AnimScrollTo(id);
|
2024-06-13 14:49:04 +08:00
|
|
|
|
});
|
2024-03-14 16:41:05 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
2024-06-13 14:49:04 +08:00
|
|
|
|
|
2024-06-14 17:01:31 +08:00
|
|
|
|
private void _SetPosYListData()
|
2024-03-14 16:41:05 +08:00
|
|
|
|
{
|
2024-06-14 17:01:31 +08:00
|
|
|
|
var posY = 0f;
|
|
|
|
|
|
for (int i = 1; i < SceneScrollView.SceneItemCount() - 1; i++)
|
2024-03-14 16:41:05 +08:00
|
|
|
|
{
|
2024-06-17 17:50:08 +08:00
|
|
|
|
Vector2 size = SceneScrollView.SceneItemSize(i, _curSceneIndex);
|
|
|
|
|
|
posY -= size.y / 2;
|
2024-06-14 17:01:31 +08:00
|
|
|
|
SceneScrollView._itemCells[i - 1].localPosY = posY;
|
2024-06-17 17:50:08 +08:00
|
|
|
|
posY -= size.y / 2;
|
2024-03-14 16:41:05 +08:00
|
|
|
|
}
|
|
|
|
|
|
}
|
2024-06-17 17:50:08 +08:00
|
|
|
|
private void _SetSkinPosYListData(bool setSize = true)
|
2024-03-14 16:41:05 +08:00
|
|
|
|
{
|
2024-06-17 17:50:08 +08:00
|
|
|
|
if (setSize)
|
|
|
|
|
|
{
|
|
|
|
|
|
for (int i = 0; i < _GetSkinItemFunc(); i++)
|
|
|
|
|
|
{
|
2024-06-21 15:06:21 +08:00
|
|
|
|
Vector2 size;
|
|
|
|
|
|
|
|
|
|
|
|
if (CategoryManager.Instance.TryGetSkinItemInfo((int)_charIDList[_curSelect], i + 1, out DataItem dataItem))//物品类皮肤
|
|
|
|
|
|
{
|
2024-06-25 16:27:41 +08:00
|
|
|
|
if (CategoryManager.Instance.GetItemCount(dataItem.ID) != 0 || i == 0)
|
2024-06-21 15:06:21 +08:00
|
|
|
|
{
|
|
|
|
|
|
size = SkinScrollView.SkinItemSize(i, _curSelectSkin);
|
|
|
|
|
|
}
|
|
|
|
|
|
else
|
|
|
|
|
|
{
|
|
|
|
|
|
size = Vector2.zero;
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
2024-06-24 13:53:23 +08:00
|
|
|
|
else
|
2024-06-21 15:06:21 +08:00
|
|
|
|
{
|
|
|
|
|
|
if (i != 0)
|
|
|
|
|
|
{
|
|
|
|
|
|
DebugUtil.LogError("这个皮肤并未在Item表内配置,并且它不是初始皮肤,SkinID:" + (i + 1));
|
|
|
|
|
|
}
|
|
|
|
|
|
size = SkinScrollView.SkinItemSize(i, _curSelectSkin);
|
|
|
|
|
|
}
|
|
|
|
|
|
SkinScrollView._itemCells[i].size = size;
|
2024-06-17 17:50:08 +08:00
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
var posY = 0f;
|
2024-06-14 17:01:31 +08:00
|
|
|
|
for (int i = 0; i < _GetSkinItemFunc(); i++)
|
2024-03-14 16:41:05 +08:00
|
|
|
|
{
|
2024-06-17 17:50:08 +08:00
|
|
|
|
Vector2 size = SkinScrollView._itemCells[i].size;
|
|
|
|
|
|
posY -= size.y / 2;
|
2024-06-14 17:01:31 +08:00
|
|
|
|
SkinScrollView._itemCells[i].localPosY = posY;
|
2024-06-17 17:50:08 +08:00
|
|
|
|
posY -= size.y / 2;
|
2024-03-14 16:41:05 +08:00
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2024-03-18 16:20:35 +08:00
|
|
|
|
private async void _InitSceneScroll()
|
2024-03-14 16:41:05 +08:00
|
|
|
|
{
|
2024-03-18 16:20:35 +08:00
|
|
|
|
var storeData = StorageMgr.Instance.GetStorage<MainPanelSceneStoreData>("MainPanelSceneStoreData");
|
|
|
|
|
|
_curSceneIndex = storeData.SceneIdx;
|
|
|
|
|
|
_curCameraPosIdx = storeData.CameraPosIdx;
|
|
|
|
|
|
await UniTask.DelayFrame(1);
|
2024-03-20 16:25:29 +08:00
|
|
|
|
_RefreshSceneButtons();
|
2024-06-13 14:49:04 +08:00
|
|
|
|
}
|
2024-03-14 16:41:05 +08:00
|
|
|
|
|
2024-06-14 17:01:31 +08:00
|
|
|
|
#endregion
|
2024-03-14 16:41:05 +08:00
|
|
|
|
|
|
|
|
|
|
|
2024-06-14 17:01:31 +08:00
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// 更换看板娘
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
#region PosterPage
|
|
|
|
|
|
private void _InitPosterScroll()
|
2024-03-14 16:41:05 +08:00
|
|
|
|
{
|
|
|
|
|
|
_InitSelectCharacter();
|
|
|
|
|
|
_CreatePoolScroll();
|
|
|
|
|
|
_CreateSkinScroll();
|
2024-03-15 15:24:28 +08:00
|
|
|
|
_InitPosterImg();
|
2024-06-14 17:01:31 +08:00
|
|
|
|
SkinScrollView.InitItemCellList(_GetSkinItemFunc());
|
|
|
|
|
|
_SetSkinPosYListData();
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void BindSkinScrollView()
|
|
|
|
|
|
{
|
2024-06-18 14:32:45 +08:00
|
|
|
|
//SkinScrollView.AddValueChangeListener(_OnSkinScrollViewValChange);
|
2024-06-14 17:01:31 +08:00
|
|
|
|
SkinScrollView.SetItemCountFunc(_GetSkinItemFunc);
|
2024-06-17 17:50:08 +08:00
|
|
|
|
SkinScrollView.SetItemSizeFunc((index) => SkinScrollView.GetItemSizeFromList(index));//SkinItemSize(index, _curSelectSkin));
|
2024-06-14 17:01:31 +08:00
|
|
|
|
SkinScrollView.SetUpdateFunc(_RefreshSkinItem);
|
|
|
|
|
|
}
|
2024-03-15 15:24:28 +08:00
|
|
|
|
|
|
|
|
|
|
private async void _InitPosterImg()
|
|
|
|
|
|
{
|
|
|
|
|
|
var posterPath = CommonUtils.GetCharacterPicPath((int)_charIDList[_curSelect],
|
2024-06-21 18:11:19 +08:00
|
|
|
|
CommonUtils.ECharacterPicPathType.Poster, _curSelectSkin + 1);
|
2024-05-07 14:09:50 +08:00
|
|
|
|
var posterSprite = await LoadAssetAsync<Sprite>(posterPath);
|
2024-03-15 15:24:28 +08:00
|
|
|
|
Image_CBG.sprite = posterSprite;
|
2024-03-14 16:41:05 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
2024-04-03 16:15:49 +08:00
|
|
|
|
private void _RefreshCharList()
|
|
|
|
|
|
{
|
|
|
|
|
|
switch (_sortType)
|
|
|
|
|
|
{
|
|
|
|
|
|
case SortType.Level:
|
|
|
|
|
|
{
|
|
|
|
|
|
_charIDList.Sort((a, b) =>
|
|
|
|
|
|
{
|
|
|
|
|
|
var dataA = CharacterDataInfoManager.Instance.DataDic[a];
|
|
|
|
|
|
var dataB = CharacterDataInfoManager.Instance.DataDic[b];
|
|
|
|
|
|
if (dataA.Level > dataB.Level)
|
|
|
|
|
|
{
|
|
|
|
|
|
return _isUpSort? 1 : -1;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if (dataA.Level < dataB.Level)
|
|
|
|
|
|
{
|
|
|
|
|
|
return _isUpSort? -1 : 1;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
|
|
});
|
|
|
|
|
|
break;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
case SortType.Rarity:
|
|
|
|
|
|
{
|
|
|
|
|
|
_charIDList.Sort((a, b) =>
|
|
|
|
|
|
{
|
|
|
|
|
|
var dataA = CharacterDataInfoManager.Instance.DataDic[a];
|
|
|
|
|
|
var dataB = CharacterDataInfoManager.Instance.DataDic[b];
|
|
|
|
|
|
return _isUpSort ? dataA.Cfg.StartStar.CompareTo(dataB.Cfg.StartStar) :
|
|
|
|
|
|
dataB.Cfg.StartStar.CompareTo(dataA.Cfg.StartStar);
|
|
|
|
|
|
});
|
|
|
|
|
|
break;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
case SortType.Likely:
|
|
|
|
|
|
{
|
|
|
|
|
|
_charIDList.Sort((a, b) =>
|
|
|
|
|
|
{
|
|
|
|
|
|
var dataA = CharacterDataInfoManager.Instance.DataDic[a];
|
|
|
|
|
|
var dataB = CharacterDataInfoManager.Instance.DataDic[b];
|
|
|
|
|
|
return _isUpSort ? dataA.LikelyLevel.CompareTo(dataB.LikelyLevel) :
|
|
|
|
|
|
dataB.LikelyLevel.CompareTo(dataA.LikelyLevel);
|
|
|
|
|
|
});
|
|
|
|
|
|
break;
|
|
|
|
|
|
}
|
|
|
|
|
|
default:
|
|
|
|
|
|
{
|
|
|
|
|
|
_charIDList.Clear();
|
|
|
|
|
|
var charList = CharacterDataInfoManager.Instance.DataList;
|
|
|
|
|
|
for (int i = 0; i < charList.Count; i++)
|
|
|
|
|
|
{
|
|
|
|
|
|
_charIDList.Add(charList[i].Uid);
|
|
|
|
|
|
}
|
|
|
|
|
|
break;
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
private void _RefreshPosterPanel()
|
|
|
|
|
|
{
|
|
|
|
|
|
_RefreshCharList();
|
|
|
|
|
|
|
|
|
|
|
|
MainPanelSceneStoreData data;
|
|
|
|
|
|
if (_saveData != null)
|
|
|
|
|
|
{
|
|
|
|
|
|
data = _saveData;
|
|
|
|
|
|
}
|
|
|
|
|
|
else
|
|
|
|
|
|
{
|
|
|
|
|
|
data = StorageMgr.Instance.GetStorage<MainPanelSceneStoreData>("MainPanelSceneStoreData");
|
|
|
|
|
|
}
|
|
|
|
|
|
if (data != null)
|
|
|
|
|
|
{
|
|
|
|
|
|
_curSelect = GetPosterIndexByID(data.PosterID);
|
|
|
|
|
|
_curSelectSkin = data.PosterSkinIdx;
|
2024-06-21 15:06:21 +08:00
|
|
|
|
|
|
|
|
|
|
if (CategoryManager.Instance.TryGetSkinItemInfo(data.PosterID, _curSelectSkin + 1, out DataItem dataItem))
|
|
|
|
|
|
{
|
|
|
|
|
|
if (CategoryManager.Instance.GetItemCount(dataItem.ID) == 0)
|
|
|
|
|
|
{
|
|
|
|
|
|
_curSelectSkin = 0;
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
2024-06-07 16:00:18 +08:00
|
|
|
|
PosterHide = data.hideKanbanban;
|
2024-04-03 16:15:49 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
_RefreshImageMenu();
|
|
|
|
|
|
_RefreshPoolScroll();
|
2024-06-14 17:01:31 +08:00
|
|
|
|
//_RefreshSkinScroll();
|
2024-04-03 16:15:49 +08:00
|
|
|
|
_RefreshPosterButton();
|
2024-06-14 17:01:31 +08:00
|
|
|
|
SkinScrollView.UpdateData();
|
2024-04-03 16:15:49 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
private void _RefreshImageMenu()
|
|
|
|
|
|
{
|
|
|
|
|
|
Text_RaritySelect.gameObject.SetActive(_sortType == SortType.Rarity);
|
|
|
|
|
|
Text_LvSelect.gameObject.SetActive(_sortType == SortType.Level);
|
|
|
|
|
|
Text_AdvSelect.gameObject.SetActive(_sortType == SortType.Likely);
|
|
|
|
|
|
|
|
|
|
|
|
var imgUpRarity = CommonUtils.GetGameObject(Button_Rarity.gameObject, "ImageDefault/ImageUP");
|
|
|
|
|
|
var imgDownRarity = CommonUtils.GetGameObject(Button_Rarity.gameObject, "ImageDefault/ImageDown");
|
|
|
|
|
|
|
|
|
|
|
|
var imgUpLevel = CommonUtils.GetGameObject(Image_Lv.gameObject, "ImageUP");
|
|
|
|
|
|
var imgDownLevel = CommonUtils.GetGameObject(Image_Lv.gameObject, "ImageDown");
|
|
|
|
|
|
|
|
|
|
|
|
var imgUpLikely = CommonUtils.GetGameObject(Button_AdvanceLevel.gameObject, "ImageDefault/ImageUP");
|
|
|
|
|
|
var imgDownLikely = CommonUtils.GetGameObject(Button_AdvanceLevel.gameObject, "ImageDefault/ImageDown");
|
|
|
|
|
|
|
|
|
|
|
|
imgUpRarity.SetActive(_sortType == SortType.Rarity && _isUpSort);
|
|
|
|
|
|
imgDownRarity.SetActive(_sortType == SortType.Rarity && !_isUpSort);
|
|
|
|
|
|
imgUpLevel.SetActive(_sortType == SortType.Level && _isUpSort);
|
|
|
|
|
|
imgDownLevel.SetActive(_sortType == SortType.Level && !_isUpSort);
|
|
|
|
|
|
imgUpLikely.SetActive(_sortType == SortType.Likely && _isUpSort);
|
|
|
|
|
|
imgDownLikely.SetActive(_sortType == SortType.Likely && !_isUpSort);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2024-03-14 16:41:05 +08:00
|
|
|
|
//右侧角色池列表
|
|
|
|
|
|
private void _CreatePoolScroll()
|
|
|
|
|
|
{
|
2024-04-02 19:02:09 +08:00
|
|
|
|
// var content = CommonUtils.GetGameObject(_scrollPosterPool.gameObject, "Viewport/Content");
|
|
|
|
|
|
// if (content)
|
|
|
|
|
|
// {
|
|
|
|
|
|
// CommonUtils.DestoryAllChildGameObject(content);
|
|
|
|
|
|
// }
|
|
|
|
|
|
_scrollPosterPool.Init(_RefreshPoolItem);
|
2024-03-14 16:41:05 +08:00
|
|
|
|
_RefreshPoolScroll();
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
private void _RefreshPoolScroll()
|
|
|
|
|
|
{
|
2024-04-02 19:02:09 +08:00
|
|
|
|
// _scrollPosterPool.SetUpdateFunc(_RefreshPoolItem);
|
|
|
|
|
|
// _scrollPosterPool.SetItemCountFunc(_GetPoolCountFunc);
|
|
|
|
|
|
// _scrollPosterPool.UpdateData(false);
|
|
|
|
|
|
// _scrollPosterPool.SetButton(_SetPoolItemButton);
|
|
|
|
|
|
_scrollPosterPool.ShowList(_GetPoolCountFunc());
|
2024-03-14 16:41:05 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
2024-04-02 19:02:09 +08:00
|
|
|
|
private async void _RefreshPoolItem(GameObject go, int index)
|
2024-03-14 16:41:05 +08:00
|
|
|
|
{
|
2024-04-02 19:02:09 +08:00
|
|
|
|
//var go = item.gameObject;
|
2024-03-14 16:41:05 +08:00
|
|
|
|
var uid = _charIDList[index];
|
|
|
|
|
|
var headPicPath = CommonUtils.GetDefaultHeadPathByUid(uid);
|
|
|
|
|
|
|
|
|
|
|
|
var imgHead = CommonUtils.GetComponent<Image>(go, "ImageHead");
|
|
|
|
|
|
var btn = CommonUtils.GetComponent<Button>(go, "ImageHead");
|
|
|
|
|
|
var goSelect = CommonUtils.GetGameObject(go, "ImageHead/ImageChooseRect");
|
|
|
|
|
|
|
2024-05-07 14:09:50 +08:00
|
|
|
|
imgHead.sprite = await LoadAssetAsync<Sprite>(headPicPath);
|
2024-03-14 16:41:05 +08:00
|
|
|
|
goSelect.SetActive(_curSelect == index);
|
|
|
|
|
|
ClearBind(btn);
|
|
|
|
|
|
BindButton(btn, _OnClickPoolHeadItem, index);
|
|
|
|
|
|
|
|
|
|
|
|
go.SetActive(true);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
private int _GetPoolCountFunc()
|
|
|
|
|
|
{
|
|
|
|
|
|
return _charIDList.Count;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
//左侧角色皮肤列表
|
|
|
|
|
|
private void _CreateSkinScroll()
|
|
|
|
|
|
{
|
2024-06-14 17:01:31 +08:00
|
|
|
|
var content = SkinScrollView._scrollContent;//CommonUtils.GetGameObject(_scrollSkin.gameObject, "Viewport/Content");
|
2024-03-14 16:41:05 +08:00
|
|
|
|
if (content)
|
|
|
|
|
|
{
|
|
|
|
|
|
CommonUtils.DestoryAllChildGameObject(content);
|
|
|
|
|
|
}
|
2024-04-02 19:02:09 +08:00
|
|
|
|
|
2024-06-14 17:01:31 +08:00
|
|
|
|
//_RefreshSkinScroll();
|
2024-03-14 16:41:05 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
2024-06-14 17:01:31 +08:00
|
|
|
|
//private async void _RefreshSkinScroll()
|
|
|
|
|
|
//{
|
|
|
|
|
|
// // _scrollSkin.SetUpdateFunc(_RefreshSkinItem);
|
|
|
|
|
|
// // _scrollSkin.SetItemCountFunc(_GetSkinItemFunc);
|
|
|
|
|
|
// // _scrollSkin.UpdateData(false);
|
|
|
|
|
|
// // _scrollSkin.SetButton(_SetSkinItemButton);
|
|
|
|
|
|
// var content = CommonUtils.GetGameObject(_scrollSkin.gameObject, "Viewport/Content");
|
|
|
|
|
|
// if (content)
|
|
|
|
|
|
// {
|
|
|
|
|
|
// CommonUtils.DestoryAllChildGameObject(content);
|
|
|
|
|
|
// }
|
|
|
|
|
|
//
|
|
|
|
|
|
// var contentTrans = content.transform;
|
|
|
|
|
|
// int count = _GetSkinItemFunc();
|
|
|
|
|
|
// for (int i = 0; i < count; i++)
|
|
|
|
|
|
// {
|
|
|
|
|
|
// var goItem = Instantiate(_skinItemTemp);
|
|
|
|
|
|
// goItem.transform.SetParent(contentTrans);
|
|
|
|
|
|
// await _RefreshSkinItem(i, goItem);
|
|
|
|
|
|
// //LayoutRebuilder.ForceRebuildLayoutImmediate(goItem.GetComponent<RectTransform>());
|
|
|
|
|
|
// }
|
|
|
|
|
|
// await UniTask.DelayFrame(1);
|
|
|
|
|
|
// LayoutRebuilder.ForceRebuildLayoutImmediate(content.GetComponent<RectTransform>());
|
|
|
|
|
|
//}
|
2024-03-14 16:41:05 +08:00
|
|
|
|
|
2024-06-14 17:01:31 +08:00
|
|
|
|
private async void _RefreshSkinItem(int index, RectTransform item)
|
2024-03-14 16:41:05 +08:00
|
|
|
|
{
|
2024-06-14 17:01:31 +08:00
|
|
|
|
var go = item.gameObject;
|
2024-04-02 19:02:09 +08:00
|
|
|
|
go.SetActive(true);
|
|
|
|
|
|
|
2024-06-17 17:50:08 +08:00
|
|
|
|
//if (_curSelectSkin == index)
|
|
|
|
|
|
//{
|
2024-06-25 15:17:09 +08:00
|
|
|
|
//TODO 目前半身图使用好感度图片路径
|
|
|
|
|
|
var posterPic =
|
2024-04-02 19:02:09 +08:00
|
|
|
|
CommonUtils.GetCharacterPicPath((int)_charIDList[_curSelect], CommonUtils.ECharacterPicPathType.Favorable, index + 1);
|
2024-06-25 15:17:09 +08:00
|
|
|
|
var imgSkin = CommonUtils.GetComponent<Image>(go, "ButtonChange/ImageSkin");
|
|
|
|
|
|
var imgSelect = CommonUtils.GetGameObject(go, "ButtonChange/ImageChooseRect");
|
|
|
|
|
|
var imgDoSelect = CommonUtils.GetGameObject(go, "ButtonChange/ImageCover");
|
|
|
|
|
|
var btnChange = CommonUtils.GetComponent<Button>(go, "ButtonChange");
|
|
|
|
|
|
var btnNotSelect = CommonUtils.GetComponent<Button>(go, "ButtonNotSelect");
|
|
|
|
|
|
|
2024-08-02 15:57:31 +08:00
|
|
|
|
//DebugUtil.Log("目前半身图暂用使用路径为:" + posterPic + ",请待补充相关资源与更新配置表后在此处更新相关代码");
|
2024-06-25 15:17:09 +08:00
|
|
|
|
imgSkin.sprite = await LoadAssetAsync<Sprite>(posterPic);
|
|
|
|
|
|
|
|
|
|
|
|
btnChange.gameObject.SetActive(true);
|
|
|
|
|
|
btnNotSelect.gameObject.SetActive(false);
|
|
|
|
|
|
imgSelect.SetActive(_curSelectSkin == index);
|
|
|
|
|
|
imgDoSelect.SetActive(_curSelectSkin != index);
|
|
|
|
|
|
ClearBind(btnChange);
|
|
|
|
|
|
ClearBind(btnNotSelect);
|
|
|
|
|
|
BindButton(btnChange, _OnClickSkinItem, index);
|
2024-06-17 17:50:08 +08:00
|
|
|
|
|
|
|
|
|
|
btnChange.GetComponent<RectTransform>().sizeDelta = SkinScrollView.GetItemSizeFromList(index);
|
|
|
|
|
|
//}
|
|
|
|
|
|
//else
|
|
|
|
|
|
//{
|
|
|
|
|
|
// var imgSkin = CommonUtils.GetComponent<Image>(go, "ButtonNotSelect/ImageSkin");
|
|
|
|
|
|
// //var imgSelect = CommonUtils.GetGameObject(go, "ButtonNotSelect/ImageChooseRect");
|
|
|
|
|
|
//
|
|
|
|
|
|
// var posterPic =
|
|
|
|
|
|
// CommonUtils.GetCharacterPicPath((int)_charIDList[_curSelect], CommonUtils.ECharacterPicPathType.Favorable, index + 1);
|
|
|
|
|
|
// var sprite = await LoadAssetAsync<Sprite>(posterPic);
|
|
|
|
|
|
// var rect = imgSkin.GetComponent<RectTransform>().rect;
|
|
|
|
|
|
// //sprtie.rect.Set(sprtie.rect.x, sprtie.rect.y, rect.width, rect.height);
|
|
|
|
|
|
// //sprite = _CropSprite(sprite, new Rect(sprite.rect.x, sprite.rect.y, rect.width, rect.height));
|
|
|
|
|
|
// imgSkin.sprite = sprite;
|
|
|
|
|
|
//
|
|
|
|
|
|
// var btnChange = CommonUtils.GetComponent<Button>(go, "ButtonChange");
|
|
|
|
|
|
// var btnNotSelect = CommonUtils.GetComponent<Button>(go, "ButtonNotSelect");
|
|
|
|
|
|
//
|
|
|
|
|
|
// btnChange.gameObject.SetActive(false);
|
|
|
|
|
|
// btnNotSelect.gameObject.SetActive(true);
|
|
|
|
|
|
// ClearBind(btnNotSelect);
|
|
|
|
|
|
// BindButton(btnNotSelect, _OnClickSkinItem, index);
|
|
|
|
|
|
//}
|
2024-03-14 16:41:05 +08:00
|
|
|
|
}
|
2024-04-11 13:19:47 +08:00
|
|
|
|
|
|
|
|
|
|
private Sprite _CropSprite(Sprite sprite, Rect rect)
|
|
|
|
|
|
{
|
|
|
|
|
|
Texture2D texture = sprite.texture;
|
|
|
|
|
|
Texture2D croppedTexture = new Texture2D((int)rect.width, (int)rect.height);
|
|
|
|
|
|
Color[] pixels = texture.GetPixels((int)rect.x, (int)rect.y, (int)rect.width, (int)rect.height);
|
|
|
|
|
|
croppedTexture.SetPixels(pixels);
|
|
|
|
|
|
croppedTexture.Apply();
|
|
|
|
|
|
|
|
|
|
|
|
Sprite croppedSprite = Sprite.Create(croppedTexture, new Rect(0, 0, rect.width, rect.height), Vector2.one * 0.5f);
|
|
|
|
|
|
return croppedSprite;
|
|
|
|
|
|
}
|
2024-03-14 16:41:05 +08:00
|
|
|
|
|
2024-06-14 17:01:31 +08:00
|
|
|
|
private void _OnSkinScrollViewValChange(Vector2 pos)
|
|
|
|
|
|
{
|
|
|
|
|
|
var curIndex = SkinScrollView.GetClosestIdx(_curSelectSkin);
|
|
|
|
|
|
if (curIndex == _curSelectSkin)
|
|
|
|
|
|
{
|
|
|
|
|
|
return;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2024-06-17 17:50:08 +08:00
|
|
|
|
// _curSelectSkin = curIndex;
|
|
|
|
|
|
SkinItemChangeShow(_curSelectSkin, curIndex);
|
|
|
|
|
|
//SkinScrollView.UpdateData();
|
2024-06-14 17:01:31 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
2024-06-18 12:26:12 +08:00
|
|
|
|
void SkinItemChangeShow(int from, int to, Action callback = null)
|
2024-06-17 17:50:08 +08:00
|
|
|
|
{
|
2024-06-18 12:26:12 +08:00
|
|
|
|
if (from == to)
|
|
|
|
|
|
{
|
|
|
|
|
|
return;
|
|
|
|
|
|
}
|
|
|
|
|
|
_curSelectSkin = to;
|
2024-06-21 15:06:21 +08:00
|
|
|
|
_InitPosterImg();
|
2024-06-18 12:26:12 +08:00
|
|
|
|
_RefreshPosterButton();
|
2024-06-17 17:50:08 +08:00
|
|
|
|
SkinScrollView.DoTwoItemScale(to, from, SkinScrollView.ItemFullRectTrans.rect.size, SkinScrollView.ItemRectTrans.rect.size, 0.1f,
|
|
|
|
|
|
() =>
|
|
|
|
|
|
{
|
|
|
|
|
|
_SetSkinPosYListData(false);
|
2024-06-18 14:32:45 +08:00
|
|
|
|
}, callback);
|
2024-06-17 17:50:08 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
2024-06-14 17:01:31 +08:00
|
|
|
|
private int _GetSkinItemFunc()
|
2024-03-14 16:41:05 +08:00
|
|
|
|
{
|
|
|
|
|
|
return _skinDataList.Count;
|
|
|
|
|
|
}
|
|
|
|
|
|
private void _ChangeSelectCharacter(int index)
|
|
|
|
|
|
{
|
|
|
|
|
|
if (_curSelect == index)
|
|
|
|
|
|
{
|
|
|
|
|
|
return;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
_curSelect = index;
|
2024-03-15 13:36:53 +08:00
|
|
|
|
_curSelectSkin = 0;
|
2024-06-21 15:06:21 +08:00
|
|
|
|
_skinDataList = CommonUtils.GetCharacterSkinCfgList((int)_charIDList[_curSelect]);
|
2024-06-14 17:01:31 +08:00
|
|
|
|
SkinScrollView._itemCells.Clear();
|
|
|
|
|
|
SkinScrollView.InitItemCellList(_GetSkinItemFunc());
|
|
|
|
|
|
_SetSkinPosYListData();
|
|
|
|
|
|
}
|
2024-03-14 16:41:05 +08:00
|
|
|
|
|
|
|
|
|
|
private void _InitSelectCharacter()
|
|
|
|
|
|
{
|
2024-06-05 16:22:27 +08:00
|
|
|
|
if (_saveData == null)
|
2024-03-14 16:41:05 +08:00
|
|
|
|
{
|
2024-06-05 16:22:27 +08:00
|
|
|
|
var storeData =
|
|
|
|
|
|
StorageMgr.Instance.GetStorage<MainPanelSceneStoreData>("MainPanelSceneStoreData");
|
|
|
|
|
|
if (storeData != null)
|
|
|
|
|
|
{
|
|
|
|
|
|
_curSelect = GetPosterIndexByID(storeData.PosterID);
|
|
|
|
|
|
_curSelectSkin = storeData.PosterSkinIdx;
|
2024-06-07 16:00:18 +08:00
|
|
|
|
PosterHide = storeData.hideKanbanban;
|
2024-06-07 15:07:29 +08:00
|
|
|
|
}
|
2024-03-14 16:41:05 +08:00
|
|
|
|
}
|
2024-06-05 16:22:27 +08:00
|
|
|
|
else
|
|
|
|
|
|
{
|
|
|
|
|
|
_curSelect = GetPosterIndexByID(_saveData.PosterID);
|
|
|
|
|
|
_curSelectSkin = _saveData.PosterSkinIdx;
|
2024-06-07 16:00:18 +08:00
|
|
|
|
PosterHide = _saveData.hideKanbanban;
|
2024-06-05 16:22:27 +08:00
|
|
|
|
}
|
2024-03-14 16:41:05 +08:00
|
|
|
|
_skinDataList = CommonUtils.GetCharacterSkinCfgList((int)_charIDList[_curSelect]);
|
|
|
|
|
|
}
|
2024-03-15 15:24:28 +08:00
|
|
|
|
|
2024-03-20 16:25:29 +08:00
|
|
|
|
private int GetPosterIndexByID(int id)
|
|
|
|
|
|
{
|
|
|
|
|
|
var idx = _charIDList.IndexOf((uint)id);
|
|
|
|
|
|
if (idx < 0)
|
|
|
|
|
|
{
|
|
|
|
|
|
DebugUtil.LogError($"当前选择Poster Uid: {id}不在列表中!!!");
|
|
|
|
|
|
return 0;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
return idx;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2024-03-15 15:24:28 +08:00
|
|
|
|
private void _RefreshPosterButton()
|
|
|
|
|
|
{
|
|
|
|
|
|
if (_saveData != null)
|
|
|
|
|
|
{
|
2024-06-04 14:10:39 +08:00
|
|
|
|
if (_curSelect == GetPosterIndexByID(_saveData.PosterID) && _curSelectSkin == _saveData.PosterSkinIdx)//当前展示角色
|
2024-03-15 15:24:28 +08:00
|
|
|
|
{
|
|
|
|
|
|
Button_Confirm01.gameObject.SetActive(false);
|
|
|
|
|
|
Button_Cancel01.gameObject.SetActive(true);
|
2024-06-04 14:10:39 +08:00
|
|
|
|
Button_ChangeLocation.gameObject.SetActive(true);
|
2024-06-11 13:21:27 +08:00
|
|
|
|
Button_HidePic.gameObject.SetActive(!_isHidePoster);
|
|
|
|
|
|
Button_HidePicDown.gameObject.SetActive(_isHidePoster);
|
2024-06-04 14:10:39 +08:00
|
|
|
|
}
|
|
|
|
|
|
else//非当前展示角色
|
|
|
|
|
|
{
|
2024-03-15 15:24:28 +08:00
|
|
|
|
Button_Confirm01.gameObject.SetActive(true);
|
|
|
|
|
|
Button_Cancel01.gameObject.SetActive(false);
|
2024-06-04 14:10:39 +08:00
|
|
|
|
Button_ChangeLocation.gameObject.SetActive(false);
|
2024-06-11 13:21:27 +08:00
|
|
|
|
Button_HidePic.gameObject.SetActive(false);
|
|
|
|
|
|
Button_HidePicDown.gameObject.SetActive(false);
|
2024-06-04 14:10:39 +08:00
|
|
|
|
}
|
2024-03-15 15:24:28 +08:00
|
|
|
|
|
|
|
|
|
|
return;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
var storeData = StorageMgr.Instance.GetStorage<MainPanelSceneStoreData>("MainPanelSceneStoreData");
|
|
|
|
|
|
if (storeData != null)
|
|
|
|
|
|
{
|
2024-06-04 14:10:39 +08:00
|
|
|
|
if (_curSelect == GetPosterIndexByID(storeData.PosterID) && _curSelectSkin == storeData.PosterSkinIdx)//当前展示角色
|
|
|
|
|
|
{
|
2024-03-15 15:24:28 +08:00
|
|
|
|
Button_Confirm01.gameObject.SetActive(false);
|
|
|
|
|
|
Button_Cancel01.gameObject.SetActive(true);
|
2024-06-04 14:10:39 +08:00
|
|
|
|
Button_ChangeLocation.gameObject.SetActive(true);
|
2024-06-11 13:21:27 +08:00
|
|
|
|
Button_HidePic.gameObject.SetActive(!_isHidePoster);
|
|
|
|
|
|
Button_HidePicDown.gameObject.SetActive(_isHidePoster);
|
2024-06-04 14:10:39 +08:00
|
|
|
|
}
|
|
|
|
|
|
else//非当前展示角色
|
|
|
|
|
|
{
|
2024-03-15 15:24:28 +08:00
|
|
|
|
Button_Confirm01.gameObject.SetActive(true);
|
|
|
|
|
|
Button_Cancel01.gameObject.SetActive(false);
|
2024-06-04 14:10:39 +08:00
|
|
|
|
Button_ChangeLocation.gameObject.SetActive(false);
|
2024-06-11 13:21:27 +08:00
|
|
|
|
Button_HidePic.gameObject.SetActive(false);
|
|
|
|
|
|
Button_HidePicDown.gameObject.SetActive(false);
|
2024-06-04 14:10:39 +08:00
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2024-06-07 16:00:18 +08:00
|
|
|
|
private void RefreshPosterHideButton()
|
|
|
|
|
|
{
|
2024-06-11 13:21:27 +08:00
|
|
|
|
Button_HidePic.gameObject.SetActive(!_isHidePoster);
|
|
|
|
|
|
Button_HidePicDown.gameObject.SetActive(_isHidePoster);
|
2024-06-07 16:00:18 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
2024-06-04 14:10:39 +08:00
|
|
|
|
private void ResetPosterPosition(MainPanelSceneStoreData data)
|
|
|
|
|
|
{
|
|
|
|
|
|
if (_saveData != null)
|
|
|
|
|
|
{
|
|
|
|
|
|
_saveData.deltaPos = data.deltaPos;
|
|
|
|
|
|
_saveData.scale = data.scale;
|
|
|
|
|
|
//DebugUtil.Log("调整看板娘位置,saveData不为空,在原先数据更改");
|
|
|
|
|
|
}
|
|
|
|
|
|
else
|
|
|
|
|
|
{
|
|
|
|
|
|
_saveData = new MainPanelSceneStoreData(_curSceneIndex, _curCameraPosIdx, (int)_charIDList[_curSelect], _curSelectSkin, data.PositionDelta(), data.scale);
|
|
|
|
|
|
//DebugUtil.Log("调整看板娘位置,saveData为空,重新赋值");
|
2024-03-15 15:24:28 +08:00
|
|
|
|
}
|
|
|
|
|
|
}
|
2024-03-14 16:41:05 +08:00
|
|
|
|
|
2024-06-14 17:01:31 +08:00
|
|
|
|
#endregion
|
2024-06-13 16:40:13 +08:00
|
|
|
|
|
|
|
|
|
|
|
2024-06-14 17:01:31 +08:00
|
|
|
|
#endregion
|
2024-03-14 16:41:05 +08:00
|
|
|
|
|
2024-06-14 17:01:31 +08:00
|
|
|
|
#region class
|
|
|
|
|
|
|
2024-06-13 16:40:13 +08:00
|
|
|
|
|
2024-06-14 17:01:31 +08:00
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// 场景切换列表类
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
class ScenePanelScrollView : IPanelScrollView
|
2024-06-13 16:40:13 +08:00
|
|
|
|
{
|
2024-06-14 17:01:31 +08:00
|
|
|
|
public override void SetScrollRect(PhxhScrollView scrollRect)
|
|
|
|
|
|
{
|
|
|
|
|
|
base.SetScrollRect(scrollRect);
|
|
|
|
|
|
|
|
|
|
|
|
SetItemRectTrans(CommonUtils.GetComponent<RectTransform>(_scrollRect.itemTemplate.gameObject, "ButtonScene"),
|
|
|
|
|
|
CommonUtils.GetComponent<RectTransform>(_scrollRect.itemTemplate.gameObject, "ButtonSceneFull"));
|
|
|
|
|
|
|
|
|
|
|
|
SetPaddingSize(new Vector2(590, 300));
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public void InitItemCellList(int count)
|
|
|
|
|
|
{
|
2024-06-14 19:06:41 +08:00
|
|
|
|
_itemCells.Clear();
|
|
|
|
|
|
|
|
|
|
|
|
for (int i = 1; i < count - 1; i++)//由于有上下padding的空item,所以需要减去2
|
2024-06-14 17:01:31 +08:00
|
|
|
|
{
|
|
|
|
|
|
UIScrollViewItemCell cell = new UIScrollViewItemCell();
|
|
|
|
|
|
cell.index = i;
|
|
|
|
|
|
_itemCells.Add(cell);
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public int SceneItemCount()
|
|
|
|
|
|
{
|
|
|
|
|
|
return TableManager.Instance.Tables.MainSceneConfig.DataList.Count + 2;//+2是上下两个空白item作为padding
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public Vector2 SceneItemSize(int index, int curIndex)
|
|
|
|
|
|
{
|
|
|
|
|
|
if (index == 0 || index == SceneItemCount() - 1)//两个inactive的item作为padding
|
|
|
|
|
|
{
|
|
|
|
|
|
return ScrollPaddingSize;
|
|
|
|
|
|
}
|
|
|
|
|
|
else
|
|
|
|
|
|
{
|
|
|
|
|
|
if (index != curIndex + 1)
|
|
|
|
|
|
{
|
|
|
|
|
|
return ItemRectTrans.rect.size;
|
|
|
|
|
|
}
|
|
|
|
|
|
else
|
|
|
|
|
|
{
|
|
|
|
|
|
return ItemFullRectTrans.rect.size;
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
class SkinPanelScrollView : IPanelScrollView
|
|
|
|
|
|
{
|
|
|
|
|
|
public override void SetScrollRect(PhxhScrollView scrollRect)
|
|
|
|
|
|
{
|
2024-06-18 12:26:12 +08:00
|
|
|
|
centerAnchor = true;
|
2024-06-18 14:36:47 +08:00
|
|
|
|
canDrag = false;
|
2024-06-18 14:32:45 +08:00
|
|
|
|
Self_aligning = false;
|
2024-06-14 17:01:31 +08:00
|
|
|
|
base.SetScrollRect(scrollRect);
|
|
|
|
|
|
SetItemRectTrans(CommonUtils.GetComponent<RectTransform>(_scrollRect.itemTemplate.gameObject, "ButtonNotSelect"),
|
|
|
|
|
|
CommonUtils.GetComponent<RectTransform>(_scrollRect.itemTemplate.gameObject, "ButtonChange"));
|
|
|
|
|
|
}
|
|
|
|
|
|
public Vector2 SkinItemSize(int index, int curIndex)
|
|
|
|
|
|
{
|
2024-06-21 15:06:21 +08:00
|
|
|
|
//if(CategoryManager.Instance.TryGetSkinItemInfo(c))
|
2024-06-14 17:01:31 +08:00
|
|
|
|
if (index == curIndex)
|
|
|
|
|
|
{
|
|
|
|
|
|
return _itemFullRectTrans.rect.size;
|
|
|
|
|
|
}
|
|
|
|
|
|
else
|
|
|
|
|
|
{
|
|
|
|
|
|
return _itemRectTrans.rect.size;
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// 注意操作完请调用_SetSkinPosYListData
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
/// <param name="count"></param>
|
|
|
|
|
|
public void InitItemCellList(int count)
|
|
|
|
|
|
{
|
2024-06-14 19:06:41 +08:00
|
|
|
|
_itemCells.Clear();
|
2024-06-14 17:01:31 +08:00
|
|
|
|
for (int i = 0; i < count; i++)
|
|
|
|
|
|
{
|
|
|
|
|
|
UIScrollViewItemCell cell = new UIScrollViewItemCell();
|
|
|
|
|
|
cell.index = i;
|
|
|
|
|
|
_itemCells.Add(cell);
|
|
|
|
|
|
}
|
2024-06-17 17:50:08 +08:00
|
|
|
|
}
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// 这个函数用于缓动动画动态的设置需要缩放的item的大小
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
/// <param name="index"></param>
|
|
|
|
|
|
/// <returns></returns>
|
|
|
|
|
|
public Vector2 GetItemSizeFromList(int index)
|
|
|
|
|
|
{
|
|
|
|
|
|
if (index < _itemCells.Count)
|
|
|
|
|
|
{
|
|
|
|
|
|
return _itemCells[index].size;
|
|
|
|
|
|
}
|
|
|
|
|
|
else
|
|
|
|
|
|
{
|
|
|
|
|
|
DebugUtil.LogError("GetItemSizeFromList index out of range");
|
|
|
|
|
|
return default;
|
|
|
|
|
|
}
|
2024-06-14 17:01:31 +08:00
|
|
|
|
}
|
|
|
|
|
|
}
|
2024-06-13 16:40:13 +08:00
|
|
|
|
#endregion
|
2024-03-14 16:41:05 +08:00
|
|
|
|
|
2024-06-13 16:40:13 +08:00
|
|
|
|
#region ClickEvent
|
|
|
|
|
|
|
|
|
|
|
|
private void _OnClickClose()
|
2024-03-14 16:41:05 +08:00
|
|
|
|
{
|
2024-03-15 13:36:53 +08:00
|
|
|
|
_CheckAndSaveChange();
|
2024-03-14 16:41:05 +08:00
|
|
|
|
CloseWindow();
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
private void _OnClickSceneConfirm()
|
|
|
|
|
|
{
|
|
|
|
|
|
_ConfirmChangeMainScene();
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2024-03-15 15:24:28 +08:00
|
|
|
|
private async void _OnClickPoolHeadItem(int index)
|
2024-03-14 16:41:05 +08:00
|
|
|
|
{
|
|
|
|
|
|
if (index != _curSelect)
|
|
|
|
|
|
{
|
2024-03-15 13:36:53 +08:00
|
|
|
|
_ChangeSelectCharacter(index);
|
2024-04-02 19:02:09 +08:00
|
|
|
|
//_scrollPosterPool.UpdateData();
|
|
|
|
|
|
_RefreshPoolScroll();
|
2024-06-14 17:01:31 +08:00
|
|
|
|
//_RefreshSkinScroll();
|
|
|
|
|
|
SkinScrollView.UpdateData();
|
2024-03-15 15:24:28 +08:00
|
|
|
|
_RefreshPosterButton();
|
|
|
|
|
|
|
|
|
|
|
|
var posterPath = CommonUtils.GetCharacterPicPath((int)_charIDList[_curSelect],
|
2024-06-21 18:11:19 +08:00
|
|
|
|
CommonUtils.ECharacterPicPathType.Poster, _curSelectSkin + 1);
|
2024-05-07 14:09:50 +08:00
|
|
|
|
var posterSprite = await LoadAssetAsync<Sprite>(posterPath);
|
2024-03-15 15:24:28 +08:00
|
|
|
|
Image_CBG.sprite = posterSprite;
|
2024-03-14 16:41:05 +08:00
|
|
|
|
}
|
|
|
|
|
|
}
|
2024-06-06 19:26:12 +08:00
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// 看板娘调整位置
|
|
|
|
|
|
/// </summary>
|
2024-06-04 14:10:39 +08:00
|
|
|
|
private void OnClickAdjustPoster()
|
|
|
|
|
|
{
|
|
|
|
|
|
if (_saveData != null)
|
|
|
|
|
|
{
|
|
|
|
|
|
UIManager.Instance.Hide(UINameConst.UICameraAndPosterChange, isMainCameraActive: true);
|
2024-06-07 16:00:18 +08:00
|
|
|
|
_saveData.hideKanbanban = false;
|
|
|
|
|
|
PosterHide = false;
|
2024-06-04 14:10:39 +08:00
|
|
|
|
EventManager.Instance.Send(EventManager.EventName.PreviewMainPanelPoster, _saveData);
|
|
|
|
|
|
}
|
|
|
|
|
|
else
|
|
|
|
|
|
{
|
|
|
|
|
|
var sendData = StorageMgr.Instance.GetStorage<MainPanelSceneStoreData>("MainPanelSceneStoreData");
|
|
|
|
|
|
UIManager.Instance.Hide(UINameConst.UICameraAndPosterChange, isMainCameraActive: true);
|
2024-06-07 16:00:18 +08:00
|
|
|
|
sendData.hideKanbanban = false;
|
|
|
|
|
|
PosterHide = false;
|
2024-06-04 14:10:39 +08:00
|
|
|
|
EventManager.Instance.Send(EventManager.EventName.PreviewMainPanelPoster, sendData);
|
|
|
|
|
|
}
|
2024-06-07 15:07:29 +08:00
|
|
|
|
}
|
|
|
|
|
|
private void OnClickHideKanbanban()
|
|
|
|
|
|
{
|
2024-06-07 16:00:18 +08:00
|
|
|
|
PosterHide = !_isHidePoster;
|
2024-06-07 15:07:29 +08:00
|
|
|
|
if (_saveData == null)
|
|
|
|
|
|
{
|
|
|
|
|
|
var storeData = StorageMgr.Instance.GetStorage<MainPanelSceneStoreData>("MainPanelSceneStoreData");
|
|
|
|
|
|
_saveData = new MainPanelSceneStoreData(_curSceneIndex, _curCameraPosIdx, (int)_charIDList[_curSelect], _curSelectSkin, storeData.PositionDelta(), storeData.scale);
|
|
|
|
|
|
}
|
|
|
|
|
|
_saveData.hideKanbanban = _isHidePoster;
|
|
|
|
|
|
DebugUtil.Log("poster hide: "+_isHidePoster);
|
2024-06-04 14:10:39 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
2024-06-18 12:26:12 +08:00
|
|
|
|
private void _OnClickSkinItem(int index)
|
2024-06-18 14:32:45 +08:00
|
|
|
|
{
|
2024-06-18 12:26:12 +08:00
|
|
|
|
SkinItemChangeShow(_curSelectSkin, index, callback: () => SkinScrollView.AnimScrollTo(index));
|
|
|
|
|
|
//_curSelectSkin = index;
|
|
|
|
|
|
//_RefreshPosterButton();
|
|
|
|
|
|
//_SetSkinPosYListData();
|
|
|
|
|
|
//SkinScrollView.UpdateData();
|
|
|
|
|
|
}
|
2024-03-14 16:41:05 +08:00
|
|
|
|
|
|
|
|
|
|
private void _OnClickPosterConfirm()
|
|
|
|
|
|
{
|
|
|
|
|
|
_ConfirmChangePoster();
|
2024-03-15 15:24:28 +08:00
|
|
|
|
_RefreshPosterButton();
|
2024-03-14 16:41:05 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
private void _OnClickPosterTab()
|
|
|
|
|
|
{
|
|
|
|
|
|
_curPage = PageEnum.Scene;
|
|
|
|
|
|
_RefreshTab();
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
private void _OnClickSceneTab()
|
|
|
|
|
|
{
|
|
|
|
|
|
_curPage = PageEnum.Poster;
|
|
|
|
|
|
_RefreshTab();
|
|
|
|
|
|
}
|
2024-04-03 16:15:49 +08:00
|
|
|
|
|
|
|
|
|
|
private void _OnClickHome()
|
|
|
|
|
|
{
|
2024-04-12 19:41:37 +08:00
|
|
|
|
_CheckAndSaveChange();
|
|
|
|
|
|
UIManager.Instance.CloseAllNormalExcept(UINameConst.UI_MainPanel);
|
2024-04-03 16:15:49 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
private void _OnClickSortBtn(SortType sortType)
|
|
|
|
|
|
{
|
|
|
|
|
|
if (_sortType == sortType)
|
|
|
|
|
|
{
|
|
|
|
|
|
_isUpSort = !_isUpSort;
|
|
|
|
|
|
}
|
|
|
|
|
|
else
|
|
|
|
|
|
{
|
2024-08-02 15:57:31 +08:00
|
|
|
|
//非先前选择方式,默认以降序排列
|
|
|
|
|
|
_isUpSort = false;
|
2024-04-03 16:15:49 +08:00
|
|
|
|
_sortType = sortType;
|
|
|
|
|
|
}
|
|
|
|
|
|
_RefreshPosterPanel();
|
|
|
|
|
|
}
|
|
|
|
|
|
#endregion
|
2024-03-14 16:41:05 +08:00
|
|
|
|
|
|
|
|
|
|
private void _ConfirmChangeMainScene()
|
|
|
|
|
|
{
|
2024-03-15 13:36:53 +08:00
|
|
|
|
if (_saveData == null)
|
|
|
|
|
|
{
|
2024-08-07 17:08:09 +08:00
|
|
|
|
var storeData = StorageMgr.Instance.GetStorage<MainPanelSceneStoreData>("MainPanelSceneStoreData");
|
|
|
|
|
|
_saveData = new MainPanelSceneStoreData(_curSceneIndex, _curCameraPosIdx, (int)_charIDList[_curSelect], _curSelectSkin, storeData.PositionDelta(), storeData.scale);
|
2024-03-15 13:36:53 +08:00
|
|
|
|
}
|
2024-03-15 15:24:28 +08:00
|
|
|
|
else
|
|
|
|
|
|
{
|
|
|
|
|
|
_saveData.SceneIdx = _curSceneIndex;
|
|
|
|
|
|
_saveData.CameraPosIdx = _curCameraPosIdx;
|
|
|
|
|
|
}
|
2024-03-20 16:25:29 +08:00
|
|
|
|
|
|
|
|
|
|
_RefreshSceneButtons();
|
2024-03-15 13:36:53 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
private void _ConfirmChangePoster()
|
|
|
|
|
|
{
|
|
|
|
|
|
if (_saveData == null)
|
2024-03-14 16:41:05 +08:00
|
|
|
|
{
|
2024-03-20 16:25:29 +08:00
|
|
|
|
_saveData = new MainPanelSceneStoreData(_curSceneIndex, _curCameraPosIdx, (int)_charIDList[_curSelect], _curSelectSkin);
|
2024-06-11 13:21:27 +08:00
|
|
|
|
PosterHide = false;
|
|
|
|
|
|
}
|
2024-03-15 15:24:28 +08:00
|
|
|
|
else
|
|
|
|
|
|
{
|
2024-03-20 16:25:29 +08:00
|
|
|
|
_saveData.PosterID = (int)_charIDList[_curSelect];
|
2024-03-15 15:24:28 +08:00
|
|
|
|
_saveData.PosterSkinIdx = _curSelectSkin;
|
2024-06-05 16:22:27 +08:00
|
|
|
|
_saveData.deltaPos = new float[2] { 0, 0 };
|
|
|
|
|
|
_saveData.scale = 0;
|
2024-06-07 16:00:18 +08:00
|
|
|
|
_saveData.hideKanbanban = false;
|
|
|
|
|
|
PosterHide = false;
|
2024-06-05 16:22:27 +08:00
|
|
|
|
}
|
2024-03-15 15:24:28 +08:00
|
|
|
|
|
|
|
|
|
|
_RefreshPosterButton();
|
2024-03-15 13:36:53 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
2024-04-19 19:32:11 +08:00
|
|
|
|
private void _CheckAndSaveChange()
|
2024-03-15 13:36:53 +08:00
|
|
|
|
{
|
2024-06-07 16:32:13 +08:00
|
|
|
|
|
2024-03-15 13:36:53 +08:00
|
|
|
|
var oldSaveData = StorageMgr.Instance.GetStorage<MainPanelSceneStoreData>("MainPanelSceneStoreData");
|
|
|
|
|
|
if (oldSaveData != null && _saveData != null)
|
|
|
|
|
|
{
|
2024-06-07 16:00:18 +08:00
|
|
|
|
bool refreshPoster = false;
|
|
|
|
|
|
if (CheckIsPosterChange(_saveData, oldSaveData))//更换看板娘或调整位置
|
2024-03-14 16:41:05 +08:00
|
|
|
|
{
|
2024-03-20 16:25:29 +08:00
|
|
|
|
oldSaveData.PosterID = _saveData.PosterID;
|
2024-03-15 15:24:28 +08:00
|
|
|
|
oldSaveData.PosterSkinIdx = _saveData.PosterSkinIdx;
|
2024-06-04 14:10:39 +08:00
|
|
|
|
oldSaveData.deltaPos = _saveData.deltaPos;
|
|
|
|
|
|
oldSaveData.scale = _saveData.scale;
|
2024-06-07 16:00:18 +08:00
|
|
|
|
|
|
|
|
|
|
refreshPoster = true;
|
2024-06-04 14:10:39 +08:00
|
|
|
|
DebugUtil.Log("保存看板娘调整数据");
|
2024-03-15 15:24:28 +08:00
|
|
|
|
}
|
2024-06-07 16:00:18 +08:00
|
|
|
|
if (oldSaveData.hideKanbanban != _isHidePoster)//隐藏看板娘
|
|
|
|
|
|
{
|
|
|
|
|
|
oldSaveData.hideKanbanban = _isHidePoster;
|
2024-06-04 14:10:39 +08:00
|
|
|
|
|
2024-06-07 16:00:18 +08:00
|
|
|
|
refreshPoster = true;
|
|
|
|
|
|
DebugUtil.Log("保存看板娘隐藏数据");
|
|
|
|
|
|
}
|
|
|
|
|
|
if (refreshPoster)
|
|
|
|
|
|
{
|
|
|
|
|
|
ShowManager.Instance.RefreshShow(E_ShowSceneType.Main);
|
|
|
|
|
|
EventManager.Instance.Send(EventManager.EventName.ChangeMainPanelPoster);
|
|
|
|
|
|
}
|
2024-03-15 15:24:28 +08:00
|
|
|
|
if (CheckIsSceneChange(_saveData, oldSaveData))
|
|
|
|
|
|
{
|
|
|
|
|
|
oldSaveData.SceneIdx = _saveData.SceneIdx;
|
|
|
|
|
|
oldSaveData.CameraPosIdx = _saveData.CameraPosIdx;
|
2024-05-17 19:27:02 +08:00
|
|
|
|
LoadingExecutorManager.Instance.ExecuteLoading(new MainSceneReLoadingExecutor()).Forget();
|
2024-06-11 20:01:38 +08:00
|
|
|
|
DebugUtil.Log("保存场景调整数据,当前场景: " + _saveData.SceneIdx);
|
2024-06-07 16:00:18 +08:00
|
|
|
|
}
|
2024-03-20 16:25:29 +08:00
|
|
|
|
StorageMgr.Instance.SyncForce = true;
|
2024-03-14 16:41:05 +08:00
|
|
|
|
}
|
2024-03-15 13:36:53 +08:00
|
|
|
|
}
|
2024-03-14 16:41:05 +08:00
|
|
|
|
|
2024-03-15 13:36:53 +08:00
|
|
|
|
private bool CheckIsSceneChange(MainPanelSceneStoreData newStoreData, MainPanelSceneStoreData oldStoreData)
|
|
|
|
|
|
{
|
|
|
|
|
|
if (newStoreData.SceneIdx != oldStoreData.SceneIdx)
|
2024-03-14 16:41:05 +08:00
|
|
|
|
{
|
2024-03-15 13:36:53 +08:00
|
|
|
|
return true;
|
2024-03-14 16:41:05 +08:00
|
|
|
|
}
|
2024-06-11 20:01:38 +08:00
|
|
|
|
if (newStoreData.CameraPosIdx != oldStoreData.CameraPosIdx)
|
|
|
|
|
|
{
|
|
|
|
|
|
return true;
|
|
|
|
|
|
}
|
2024-03-15 13:36:53 +08:00
|
|
|
|
return false;
|
2024-03-14 16:41:05 +08:00
|
|
|
|
}
|
2024-08-07 17:08:09 +08:00
|
|
|
|
|
2024-03-15 13:36:53 +08:00
|
|
|
|
private bool CheckIsPosterChange(MainPanelSceneStoreData newStoreData, MainPanelSceneStoreData oldStoreData)
|
2024-03-14 16:41:05 +08:00
|
|
|
|
{
|
2024-03-20 16:25:29 +08:00
|
|
|
|
if (newStoreData.PosterID != oldStoreData.PosterID)
|
2024-03-14 16:41:05 +08:00
|
|
|
|
{
|
2024-03-15 13:36:53 +08:00
|
|
|
|
return true;
|
2024-03-14 16:41:05 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
2024-03-15 13:36:53 +08:00
|
|
|
|
if (newStoreData.PosterSkinIdx != oldStoreData.PosterSkinIdx)
|
2024-03-14 16:41:05 +08:00
|
|
|
|
{
|
2024-03-15 13:36:53 +08:00
|
|
|
|
return true;
|
2024-03-14 16:41:05 +08:00
|
|
|
|
}
|
2024-06-04 14:10:39 +08:00
|
|
|
|
|
2024-06-07 16:32:13 +08:00
|
|
|
|
if (newStoreData.deltaPos[0] != oldStoreData.deltaPos[0] || newStoreData.deltaPos[1] != oldStoreData.deltaPos[1])
|
2024-06-04 14:10:39 +08:00
|
|
|
|
{
|
|
|
|
|
|
return true;
|
|
|
|
|
|
}
|
|
|
|
|
|
if (newStoreData.scale != oldStoreData.scale)
|
|
|
|
|
|
{
|
|
|
|
|
|
return true;
|
|
|
|
|
|
}
|
2024-08-07 17:08:09 +08:00
|
|
|
|
|
2024-03-15 13:36:53 +08:00
|
|
|
|
return false;
|
2024-03-14 16:41:05 +08:00
|
|
|
|
}
|
2024-03-18 16:20:35 +08:00
|
|
|
|
|
|
|
|
|
|
private void _OnClickCameraPos(int index)
|
|
|
|
|
|
{
|
|
|
|
|
|
if (_curCameraPosIdx == index)
|
|
|
|
|
|
{
|
|
|
|
|
|
return;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2024-06-13 14:49:04 +08:00
|
|
|
|
_curCameraPosIdx = index;
|
2024-06-14 17:01:31 +08:00
|
|
|
|
_RefreshItemView(SceneScrollView._itemCells[_curSceneIndex].GoRoot);
|
2024-06-11 20:01:38 +08:00
|
|
|
|
_RefreshSceneButtons();
|
2024-03-18 16:20:35 +08:00
|
|
|
|
}
|
2024-03-14 16:41:05 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public class MainPanelSceneStoreData
|
|
|
|
|
|
{
|
|
|
|
|
|
public int SceneIdx = 0;
|
|
|
|
|
|
public int CameraPosIdx = 0;
|
2024-03-20 16:25:29 +08:00
|
|
|
|
public int PosterID = 0;
|
2024-03-14 16:41:05 +08:00
|
|
|
|
public int PosterSkinIdx = 0;
|
2024-06-04 15:22:09 +08:00
|
|
|
|
|
|
|
|
|
|
//看板娘自定义数据
|
|
|
|
|
|
public float[] deltaPos = new float[2] { 0, 0 };//位置偏移量
|
|
|
|
|
|
public float scale = 0f;//缩放比例指数,底数为2
|
2024-06-07 15:07:29 +08:00
|
|
|
|
public bool hideKanbanban = false;//是否隐藏看板娘
|
2024-03-15 13:36:53 +08:00
|
|
|
|
|
2024-06-04 14:10:39 +08:00
|
|
|
|
public MainPanelSceneStoreData()
|
2024-03-15 13:36:53 +08:00
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2024-03-20 16:25:29 +08:00
|
|
|
|
public MainPanelSceneStoreData(int sceneIdx, int cameraPosIdx, int posterID, int posterSkinIdx)
|
2024-03-15 13:36:53 +08:00
|
|
|
|
{
|
|
|
|
|
|
SceneIdx = sceneIdx;
|
|
|
|
|
|
CameraPosIdx = cameraPosIdx;
|
2024-03-20 16:25:29 +08:00
|
|
|
|
if (posterID <= 0)
|
|
|
|
|
|
{
|
|
|
|
|
|
if (CharacterDataInfoManager.Instance.DataList.Count > 0)
|
|
|
|
|
|
{
|
|
|
|
|
|
PosterID = CharacterDataInfoManager.Instance.DataList[0].Cfg.RoleID;
|
|
|
|
|
|
}
|
|
|
|
|
|
else
|
|
|
|
|
|
{
|
|
|
|
|
|
DebugUtil.LogError("初始角色为空咯!!!请检查数据!!!");
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
else
|
|
|
|
|
|
{
|
|
|
|
|
|
PosterID = posterID;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2024-03-15 13:36:53 +08:00
|
|
|
|
PosterSkinIdx = posterSkinIdx;
|
|
|
|
|
|
}
|
2024-06-04 14:10:39 +08:00
|
|
|
|
public MainPanelSceneStoreData(int sceneIdx, int cameraPosIdx, int posterID, int posterSkinIdx, Vector2 deltaPos, float scale)
|
|
|
|
|
|
{
|
|
|
|
|
|
SceneIdx = sceneIdx;
|
|
|
|
|
|
CameraPosIdx = cameraPosIdx;
|
|
|
|
|
|
if (posterID <= 0)
|
|
|
|
|
|
{
|
|
|
|
|
|
if (CharacterDataInfoManager.Instance.DataList.Count > 0)
|
|
|
|
|
|
{
|
|
|
|
|
|
PosterID = CharacterDataInfoManager.Instance.DataList[0].Cfg.RoleID;
|
|
|
|
|
|
}
|
|
|
|
|
|
else
|
|
|
|
|
|
{
|
|
|
|
|
|
DebugUtil.LogError("初始角色为空咯!!!请检查数据!!!");
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
else
|
|
|
|
|
|
{
|
|
|
|
|
|
PosterID = posterID;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
PosterSkinIdx = posterSkinIdx;
|
|
|
|
|
|
this.deltaPos = new float[2] { deltaPos.x, deltaPos.y };
|
|
|
|
|
|
this.scale = scale;
|
|
|
|
|
|
}
|
|
|
|
|
|
public Vector2 PositionDelta()
|
|
|
|
|
|
{
|
|
|
|
|
|
return new Vector2(deltaPos[0], deltaPos[1]);
|
|
|
|
|
|
}
|
2024-03-14 16:41:05 +08:00
|
|
|
|
}
|
2024-06-13 14:49:04 +08:00
|
|
|
|
|
2024-06-14 17:01:31 +08:00
|
|
|
|
public class UIScrollViewItemCell
|
2024-06-13 14:49:04 +08:00
|
|
|
|
{
|
|
|
|
|
|
public int index;
|
|
|
|
|
|
public float localPosY;
|
2024-06-17 17:50:08 +08:00
|
|
|
|
public Vector2 size;
|
2024-06-13 14:49:04 +08:00
|
|
|
|
public GameObject GoRoot;
|
|
|
|
|
|
}
|
2024-06-13 16:40:13 +08:00
|
|
|
|
|
2024-06-17 17:50:08 +08:00
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// 对列表中一项进行放大的同时缩小另一项
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
public class ScrollingItemSizeFitter
|
|
|
|
|
|
{
|
|
|
|
|
|
CancellationTokenSource cts;
|
|
|
|
|
|
|
|
|
|
|
|
UIScrollViewItemCell magnifyCell;
|
|
|
|
|
|
UIScrollViewItemCell shrinkCell;
|
|
|
|
|
|
|
|
|
|
|
|
Vector2 magnifySize;
|
|
|
|
|
|
Vector2 shrinkSize;
|
|
|
|
|
|
|
2024-06-18 12:26:12 +08:00
|
|
|
|
Action onComplete;
|
|
|
|
|
|
|
2024-06-17 17:50:08 +08:00
|
|
|
|
PhxhScrollView DoingScrollview;
|
|
|
|
|
|
|
2024-06-18 12:26:12 +08:00
|
|
|
|
public void DOScale(PhxhScrollView scrollView, UIScrollViewItemCell magnify, UIScrollViewItemCell shrink, Vector2 magnifySize, Vector2 shrinkSize, float duration,
|
|
|
|
|
|
Action OnValueChange = null, Action callback = null)
|
2024-06-17 17:50:08 +08:00
|
|
|
|
{
|
2024-06-18 12:26:12 +08:00
|
|
|
|
if (cts != null)
|
2024-06-17 17:50:08 +08:00
|
|
|
|
{
|
2024-06-18 12:26:12 +08:00
|
|
|
|
cts.Cancel();
|
|
|
|
|
|
}
|
2024-06-17 17:50:08 +08:00
|
|
|
|
|
2024-06-18 12:26:12 +08:00
|
|
|
|
cts = new CancellationTokenSource();
|
|
|
|
|
|
DoingScrollview = scrollView;
|
|
|
|
|
|
this.magnifyCell = magnify;
|
|
|
|
|
|
this.shrinkCell = shrink;
|
|
|
|
|
|
this.magnifySize = magnifySize;
|
|
|
|
|
|
this.shrinkSize = shrinkSize;
|
|
|
|
|
|
onComplete = callback;
|
|
|
|
|
|
ScaleAsync(magnify.size, shrink.size, duration, cts.Token, OnValueChange).Forget();
|
|
|
|
|
|
}
|
2024-06-17 17:50:08 +08:00
|
|
|
|
|
2024-06-18 12:26:12 +08:00
|
|
|
|
async UniTask ScaleAsync(Vector2 startMagnifySize, Vector2 startShrinkSize, float duration, CancellationToken token, Action OnValueChange)
|
2024-06-17 17:50:08 +08:00
|
|
|
|
{
|
|
|
|
|
|
float time = 0;
|
|
|
|
|
|
while (time < duration)
|
|
|
|
|
|
{
|
|
|
|
|
|
if (token.IsCancellationRequested)
|
|
|
|
|
|
return;
|
|
|
|
|
|
time += Time.deltaTime;
|
|
|
|
|
|
float t = time / duration;
|
|
|
|
|
|
|
|
|
|
|
|
Vector2 MagSize = Vector2.Lerp(startMagnifySize, magnifySize, t);
|
|
|
|
|
|
magnifyCell.size = MagSize;
|
|
|
|
|
|
Vector2 ShrSize = Vector2.Lerp(startShrinkSize, shrinkSize, t);
|
|
|
|
|
|
shrinkCell.size = ShrSize;
|
|
|
|
|
|
|
|
|
|
|
|
OnValueChange?.Invoke();
|
2024-06-18 12:26:12 +08:00
|
|
|
|
if(DoingScrollview != null)
|
|
|
|
|
|
DoingScrollview.UpdateData();
|
2024-06-17 17:50:08 +08:00
|
|
|
|
await UniTask.Yield();
|
|
|
|
|
|
}
|
2024-06-18 12:26:12 +08:00
|
|
|
|
if (DoingScrollview != null)
|
|
|
|
|
|
DoingScrollview.UpdateData();
|
|
|
|
|
|
DoingScrollview = null;
|
|
|
|
|
|
onComplete?.Invoke();
|
|
|
|
|
|
onComplete = null;
|
2024-06-17 17:50:08 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public void DoComplete()
|
|
|
|
|
|
{
|
|
|
|
|
|
if(DoingScrollview != null)
|
|
|
|
|
|
{
|
|
|
|
|
|
cts.Cancel();
|
|
|
|
|
|
magnifyCell.size = magnifySize;
|
|
|
|
|
|
shrinkCell.size = shrinkSize;
|
|
|
|
|
|
DoingScrollview.UpdateData();
|
|
|
|
|
|
DoingScrollview = null;
|
2024-06-18 12:26:12 +08:00
|
|
|
|
onComplete?.Invoke();
|
|
|
|
|
|
onComplete = null;
|
2024-06-17 17:50:08 +08:00
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
2024-06-21 17:14:19 +08:00
|
|
|
|
public class PosterFader
|
|
|
|
|
|
{
|
|
|
|
|
|
CancellationTokenSource cts = new CancellationTokenSource();
|
|
|
|
|
|
Image img;
|
|
|
|
|
|
float target;
|
|
|
|
|
|
Action completedCallback;
|
|
|
|
|
|
|
|
|
|
|
|
public void DoFade(Image img,float value, float duration, Action OnCompleted = null)
|
|
|
|
|
|
{
|
|
|
|
|
|
if (cts != null)
|
|
|
|
|
|
{
|
|
|
|
|
|
cts.Cancel();
|
|
|
|
|
|
}
|
|
|
|
|
|
cts = new CancellationTokenSource();
|
|
|
|
|
|
this.img = img;
|
|
|
|
|
|
target = Math.Clamp(value, 0f, 1f);
|
|
|
|
|
|
completedCallback = OnCompleted;
|
|
|
|
|
|
FadeImageAlphaAsync(duration, cts.Token).Forget();
|
|
|
|
|
|
}
|
|
|
|
|
|
async UniTask FadeImageAlphaAsync(float duration,CancellationToken cancellationToken)
|
|
|
|
|
|
{
|
|
|
|
|
|
float time = 0;
|
|
|
|
|
|
float startAlpha = img.color.a;
|
|
|
|
|
|
while (time < duration)
|
|
|
|
|
|
{
|
|
|
|
|
|
if (cts.IsCancellationRequested)
|
|
|
|
|
|
{
|
|
|
|
|
|
return;
|
|
|
|
|
|
}
|
|
|
|
|
|
time += Time.deltaTime;
|
|
|
|
|
|
float t = time / duration;
|
|
|
|
|
|
float a = Mathf.Lerp(startAlpha, target, t);
|
2024-06-17 17:50:08 +08:00
|
|
|
|
|
2024-06-21 17:14:19 +08:00
|
|
|
|
img.color = new Color(img.color.r, img.color.g, img.color.b, a);
|
|
|
|
|
|
await UniTask.Yield();
|
|
|
|
|
|
}
|
|
|
|
|
|
img = null;
|
|
|
|
|
|
completedCallback?.Invoke();
|
|
|
|
|
|
completedCallback = null;
|
|
|
|
|
|
}
|
|
|
|
|
|
public void DoKill()
|
|
|
|
|
|
{
|
|
|
|
|
|
if(cts != null)
|
|
|
|
|
|
{
|
|
|
|
|
|
cts.Cancel();
|
|
|
|
|
|
img = null;
|
|
|
|
|
|
completedCallback = null;
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
public void DoComplete()
|
|
|
|
|
|
{
|
|
|
|
|
|
if (img != null)
|
|
|
|
|
|
{
|
|
|
|
|
|
cts.Cancel(true);
|
|
|
|
|
|
img.color = new Color(img.color.r, img.color.g, img.color.b, target);
|
|
|
|
|
|
img = null;
|
|
|
|
|
|
completedCallback?.Invoke();
|
|
|
|
|
|
completedCallback = null;
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
2024-06-13 16:40:13 +08:00
|
|
|
|
public class ScrollEaseFitter
|
|
|
|
|
|
{
|
|
|
|
|
|
CancellationTokenSource cts;
|
2024-06-17 17:50:08 +08:00
|
|
|
|
PhxhScrollView scrollingRt = null;//用于记录是否正在进行动画
|
|
|
|
|
|
float target;
|
|
|
|
|
|
Action completedCallback;
|
2024-06-13 16:40:13 +08:00
|
|
|
|
|
2024-06-17 17:50:08 +08:00
|
|
|
|
public void DoScrollTo(PhxhScrollView scrollRect, float startPosY, float targetPosY, float duration, Action OnCompleted = null)
|
2024-06-13 16:40:13 +08:00
|
|
|
|
{
|
|
|
|
|
|
if (cts != null)
|
|
|
|
|
|
{
|
|
|
|
|
|
cts.Cancel();
|
|
|
|
|
|
}
|
|
|
|
|
|
cts = new CancellationTokenSource();
|
2024-06-17 17:50:08 +08:00
|
|
|
|
target = targetPosY;
|
|
|
|
|
|
completedCallback = OnCompleted;
|
|
|
|
|
|
VerticalScrollToAsync(scrollRect, startPosY, targetPosY, duration, cts.Token).Forget();
|
2024-06-13 16:40:13 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
2024-06-17 17:50:08 +08:00
|
|
|
|
async UniTask VerticalScrollToAsync(PhxhScrollView scrollRect, float startPosY, float targetPosY, float duration, CancellationToken token)
|
2024-06-13 16:40:13 +08:00
|
|
|
|
{
|
|
|
|
|
|
float time = 0;
|
2024-06-17 17:50:08 +08:00
|
|
|
|
scrollingRt = scrollRect;
|
|
|
|
|
|
while (time < duration)
|
2024-06-13 16:40:13 +08:00
|
|
|
|
{
|
|
|
|
|
|
if (token.IsCancellationRequested)
|
|
|
|
|
|
{
|
|
|
|
|
|
return;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
time += Time.deltaTime;
|
|
|
|
|
|
float t = time / duration;
|
|
|
|
|
|
|
|
|
|
|
|
float pos = Mathf.Lerp(startPosY, targetPosY, t);
|
|
|
|
|
|
|
2024-06-17 17:50:08 +08:00
|
|
|
|
scrollingRt.ScrollToNormalizedPostion(pos, 1);//1 is vertical
|
2024-06-13 16:40:13 +08:00
|
|
|
|
await UniTask.Yield();
|
|
|
|
|
|
}
|
2024-06-17 17:50:08 +08:00
|
|
|
|
|
|
|
|
|
|
scrollingRt.ScrollToNormalizedPostion(targetPosY, 1);
|
|
|
|
|
|
completedCallback?.Invoke();
|
|
|
|
|
|
scrollingRt = null;
|
|
|
|
|
|
completedCallback = null;
|
2024-06-13 16:40:13 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public void DoKill()
|
|
|
|
|
|
{
|
|
|
|
|
|
if (cts != null)
|
2024-06-17 17:50:08 +08:00
|
|
|
|
{
|
2024-06-13 16:40:13 +08:00
|
|
|
|
cts.Cancel();
|
2024-06-17 17:50:08 +08:00
|
|
|
|
scrollingRt = null;
|
|
|
|
|
|
completedCallback = null;
|
|
|
|
|
|
}
|
2024-06-13 16:40:13 +08:00
|
|
|
|
}
|
2024-06-17 17:50:08 +08:00
|
|
|
|
|
|
|
|
|
|
public void DoComplete()
|
|
|
|
|
|
{
|
|
|
|
|
|
if (scrollingRt != null)
|
|
|
|
|
|
{
|
|
|
|
|
|
cts.Cancel();
|
|
|
|
|
|
completedCallback?.Invoke();
|
|
|
|
|
|
scrollingRt.ScrollToNormalizedPostion(target, 1);
|
|
|
|
|
|
scrollingRt = null;
|
|
|
|
|
|
completedCallback = null;
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
2024-06-13 16:40:13 +08:00
|
|
|
|
}
|
2024-06-14 17:01:31 +08:00
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// 包含吸附与缩放的滑动列表类
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
public class IPanelScrollView
|
|
|
|
|
|
{
|
2024-06-18 12:26:12 +08:00
|
|
|
|
public PhxhScrollView _scrollRect;
|
2024-06-14 17:01:31 +08:00
|
|
|
|
public GameObject _scrollContent;
|
2024-06-18 14:32:45 +08:00
|
|
|
|
|
|
|
|
|
|
protected bool canDrag = true;
|
|
|
|
|
|
protected bool centerAnchor = false;//是否居中对齐
|
2024-06-18 12:26:12 +08:00
|
|
|
|
protected bool Self_aligning = true;//自动回正(吸附)
|
2024-06-17 13:54:58 +08:00
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// 滚动列表中有obj的item
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
public Dictionary<int, UIScrollViewItemCell> _shownItemList = new();
|
2024-06-14 17:01:31 +08:00
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// 所有的item
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
public List<UIScrollViewItemCell> _itemCells = new List<UIScrollViewItemCell>();
|
|
|
|
|
|
|
|
|
|
|
|
protected ScrollEaseFitter easeFitter = new ScrollEaseFitter();
|
2024-06-17 17:50:08 +08:00
|
|
|
|
protected ScrollingItemSizeFitter itemSizeFitter = new ScrollingItemSizeFitter();
|
2024-06-14 17:01:31 +08:00
|
|
|
|
|
2024-06-17 17:50:08 +08:00
|
|
|
|
protected RectTransform _itemFullRectTrans;
|
2024-06-14 17:01:31 +08:00
|
|
|
|
public RectTransform ItemFullRectTrans
|
|
|
|
|
|
{
|
|
|
|
|
|
get => _itemFullRectTrans;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
protected RectTransform _itemRectTrans;
|
|
|
|
|
|
public RectTransform ItemRectTrans
|
|
|
|
|
|
{
|
|
|
|
|
|
get => _itemRectTrans;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
protected Vector2 ScrollViewPaddingSize = Vector2.zero;
|
|
|
|
|
|
public Vector2 ScrollPaddingSize
|
|
|
|
|
|
{
|
|
|
|
|
|
get => ScrollViewPaddingSize;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
protected float _scrollMidPosY;
|
|
|
|
|
|
protected int curSelectIndex;
|
|
|
|
|
|
|
|
|
|
|
|
#region public
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// 初始化设置滚动列表
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
/// <param name="scrollRect"></param>
|
|
|
|
|
|
public virtual void SetScrollRect(PhxhScrollView scrollRect)
|
|
|
|
|
|
{
|
|
|
|
|
|
_scrollRect = scrollRect;
|
|
|
|
|
|
_scrollContent = scrollRect.content.gameObject;
|
2024-06-18 14:32:45 +08:00
|
|
|
|
if (!canDrag)
|
|
|
|
|
|
{
|
|
|
|
|
|
_scrollContent.AddComponent<DragForUI>();
|
|
|
|
|
|
}
|
2024-06-14 17:01:31 +08:00
|
|
|
|
|
|
|
|
|
|
_scrollMidPosY = -_scrollRect.GetComponent<RectTransform>().rect.height * 0.5f;
|
|
|
|
|
|
|
|
|
|
|
|
DragForUI drag = _scrollRect.GetComponent<DragForUI>();
|
2024-06-20 14:58:48 +08:00
|
|
|
|
if (drag == null)
|
|
|
|
|
|
{
|
|
|
|
|
|
drag = _scrollRect.gameObject.AddComponent<DragForUI>();
|
|
|
|
|
|
}
|
2024-06-14 17:01:31 +08:00
|
|
|
|
drag.OnDragStarted += OnDragStart;
|
|
|
|
|
|
drag.OnDragCompleted += OnDragEnd;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public virtual void Release()
|
|
|
|
|
|
{
|
|
|
|
|
|
_shownItemList.Clear();
|
|
|
|
|
|
_itemCells.Clear();
|
|
|
|
|
|
}
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// 获取当前viewport内最接近scrollMidPosY(中央)的item的index
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
/// <param name="curIndex"></param>
|
|
|
|
|
|
/// <returns></returns>
|
|
|
|
|
|
public int GetClosestIdx(int curIndex)
|
|
|
|
|
|
{
|
|
|
|
|
|
curSelectIndex = curIndex;
|
|
|
|
|
|
int closest = curSelectIndex;
|
|
|
|
|
|
|
|
|
|
|
|
var minDis = _itemRectTrans.rect.height;
|
|
|
|
|
|
var maxDis = _itemFullRectTrans.rect.height;
|
|
|
|
|
|
|
|
|
|
|
|
var contentOffset = _scrollContent.GetComponent<RectTransform>().localPosition.y;
|
|
|
|
|
|
for (int i = 0; i < _itemCells.Count; i++)
|
|
|
|
|
|
{
|
|
|
|
|
|
var posY = _itemCells[i].localPosY - ScrollViewPaddingSize.y;//去除顶部第一个padding的距离
|
|
|
|
|
|
var start = contentOffset + posY + minDis / 2;
|
|
|
|
|
|
var end = start - minDis;
|
|
|
|
|
|
if (curSelectIndex == i)
|
|
|
|
|
|
{
|
|
|
|
|
|
start = contentOffset + posY + maxDis / 2;
|
|
|
|
|
|
end = start - maxDis;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if (i == 0)
|
|
|
|
|
|
{
|
|
|
|
|
|
start += maxDis;
|
|
|
|
|
|
}
|
|
|
|
|
|
if (i == _itemCells.Count - 1)
|
|
|
|
|
|
{
|
|
|
|
|
|
end -= maxDis;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if (_scrollMidPosY < start && _scrollMidPosY > end)
|
|
|
|
|
|
{
|
|
|
|
|
|
closest = i;
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
2024-06-14 19:06:41 +08:00
|
|
|
|
if (closest < 0 || closest >= _itemCells.Count)
|
|
|
|
|
|
{
|
|
|
|
|
|
DebugUtil.LogError("closest index out of range");
|
|
|
|
|
|
return curIndex;
|
|
|
|
|
|
}
|
2024-06-14 17:01:31 +08:00
|
|
|
|
return closest;
|
|
|
|
|
|
}
|
|
|
|
|
|
public void AddValueChangeListener(UnityAction<Vector2> action) => _scrollRect.onValueChanged.AddListener(action);
|
2024-06-17 13:54:58 +08:00
|
|
|
|
public void SetItemCountFunc(Func<int> func) => _scrollRect.SetItemCountFunc(func);
|
2024-06-14 17:01:31 +08:00
|
|
|
|
public void SetItemSizeFunc(Func<int, Vector2> func) => _scrollRect.SetItemSizeFunc(func);
|
|
|
|
|
|
public void SetUpdateFunc(Action<int, RectTransform> action) => _scrollRect.SetUpdateFunc(action);
|
|
|
|
|
|
public void UpdateData() => _scrollRect.UpdateData();
|
2024-06-18 12:26:12 +08:00
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// 动画滚动到指定index
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
/// <param name="index"></param>
|
2024-06-18 14:32:45 +08:00
|
|
|
|
public void AnimScrollTo(int index, float duration = 0.1f, Action OnComplete = null)
|
2024-06-14 17:01:31 +08:00
|
|
|
|
{
|
|
|
|
|
|
curSelectIndex = index;
|
|
|
|
|
|
easeFitter.DoKill();
|
2024-06-18 14:44:05 +08:00
|
|
|
|
UpdateData();
|
2024-06-18 12:26:12 +08:00
|
|
|
|
float pos = centerAnchor ? _scrollRect.NormalizedPositionByCenter(curSelectIndex) : _scrollRect.NormalizedScrollPosition(curSelectIndex);//
|
2024-06-18 14:32:45 +08:00
|
|
|
|
easeFitter.DoScrollTo(_scrollRect, _scrollRect.normalizedPosition.y, pos, duration, OnComplete);
|
2024-06-18 14:44:05 +08:00
|
|
|
|
|
2024-06-14 17:01:31 +08:00
|
|
|
|
}
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// 跳转到指定index
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
/// <param name="index"></param>
|
|
|
|
|
|
public void ScrollTo(int index)
|
|
|
|
|
|
{
|
|
|
|
|
|
curSelectIndex = index;
|
2024-06-18 15:33:33 +08:00
|
|
|
|
|
|
|
|
|
|
float pos = centerAnchor ? _scrollRect.NormalizedPositionByCenter(curSelectIndex) : _scrollRect.NormalizedScrollPosition(curSelectIndex);
|
|
|
|
|
|
_scrollRect.ScrollToNormalizedPostion(pos, 1);
|
|
|
|
|
|
//_scrollRect.ScrollTo(index);
|
2024-06-14 17:01:31 +08:00
|
|
|
|
UpdateData();
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2024-06-18 12:26:12 +08:00
|
|
|
|
public void DoTwoItemScale(int magnifyIndex, int shrinkIndex, Vector2 magnifySize, Vector2 shrinkSize, float duration, Action OnValueChange, Action OnComplete = null)
|
2024-06-17 17:50:08 +08:00
|
|
|
|
{
|
2024-06-18 12:26:12 +08:00
|
|
|
|
var magnify = _itemCells[magnifyIndex];
|
|
|
|
|
|
var shrink = _itemCells[shrinkIndex];
|
2024-06-17 17:50:08 +08:00
|
|
|
|
itemSizeFitter.DoComplete();
|
2024-06-18 12:26:12 +08:00
|
|
|
|
itemSizeFitter.DOScale(_scrollRect, magnify, shrink, magnifySize, shrinkSize, duration, OnValueChange, OnComplete);
|
|
|
|
|
|
}
|
2024-06-17 17:50:08 +08:00
|
|
|
|
|
2024-06-14 17:01:31 +08:00
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
|
|
|
|
#region protected
|
|
|
|
|
|
protected void SetItemRectTrans(RectTransform itemRectTrans, RectTransform fullRectTrans)
|
|
|
|
|
|
{
|
|
|
|
|
|
_itemRectTrans = itemRectTrans;
|
|
|
|
|
|
_itemFullRectTrans = fullRectTrans;
|
|
|
|
|
|
}
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// 设置空白item作为padding的大小
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
/// <param name="v"></param>
|
|
|
|
|
|
protected void SetPaddingSize(Vector2 v)
|
|
|
|
|
|
{
|
|
|
|
|
|
ScrollViewPaddingSize = v;
|
|
|
|
|
|
}
|
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
|
|
|
|
#region private
|
|
|
|
|
|
void OnDragEnd(PointerEventData data)
|
|
|
|
|
|
{
|
2024-06-18 14:32:45 +08:00
|
|
|
|
if (Self_aligning)
|
2024-06-17 17:50:08 +08:00
|
|
|
|
{
|
|
|
|
|
|
easeFitter.DoKill();
|
2024-06-18 12:26:12 +08:00
|
|
|
|
float pos = centerAnchor ? _scrollRect.NormalizedPositionByCenter(curSelectIndex) :_scrollRect.NormalizedScrollPosition(curSelectIndex);//
|
2024-06-17 17:50:08 +08:00
|
|
|
|
easeFitter.DoScrollTo(_scrollRect, _scrollRect.normalizedPosition.y, pos, 0.1f);
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
2024-06-14 17:01:31 +08:00
|
|
|
|
void OnDragStart(PointerEventData data)
|
|
|
|
|
|
{
|
2024-06-18 14:32:45 +08:00
|
|
|
|
easeFitter.DoKill();
|
2024-06-14 17:01:31 +08:00
|
|
|
|
}
|
|
|
|
|
|
#endregion
|
|
|
|
|
|
}
|