This commit is contained in:
geondo55
2025-05-12 09:35:23 +09:00
parent be2aa42500
commit 83d2d17542
6 changed files with 113 additions and 108 deletions

View File

@@ -39,7 +39,7 @@ RectTransform:
m_AnchorMin: {x: 0, y: 0}
m_AnchorMax: {x: 0, y: 0}
m_AnchoredPosition: {x: 0, y: 0}
m_SizeDelta: {x: 0, y: 36}
m_SizeDelta: {x: 0, y: 70}
m_Pivot: {x: 0.5, y: 0.5}
--- !u!114 &8577872390119345382
MonoBehaviour:
@@ -85,7 +85,7 @@ GameObject:
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
m_IsActive: 1
m_IsActive: 0
--- !u!224 &7265355731575817915
RectTransform:
m_ObjectHideFlags: 0
@@ -342,6 +342,7 @@ GameObject:
- component: {fileID: 6516329988442884210}
- component: {fileID: 499100886614822048}
- component: {fileID: 197987882297848403}
- component: {fileID: 2434642568171694670}
m_Layer: 5
m_Name: Text (TMP)
m_TagString: Untagged
@@ -363,10 +364,10 @@ RectTransform:
m_Children: []
m_Father: {fileID: 8835006081575840586}
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
m_AnchorMin: {x: 0, y: 1}
m_AnchorMax: {x: 0, y: 1}
m_AnchoredPosition: {x: 150, y: -18}
m_SizeDelta: {x: 200, y: 15}
m_AnchorMin: {x: 0.5, y: 1}
m_AnchorMax: {x: 0.5, y: 1}
m_AnchoredPosition: {x: 0, y: -62}
m_SizeDelta: {x: 0, y: 0}
m_Pivot: {x: 0.5, y: 0.5}
--- !u!222 &499100886614822048
CanvasRenderer:
@@ -423,14 +424,14 @@ MonoBehaviour:
m_faceColor:
serializedVersion: 2
rgba: 4294967295
m_fontSize: 14
m_fontSizeBase: 14
m_fontSize: 12
m_fontSizeBase: 12
m_fontWeight: 400
m_enableAutoSizing: 0
m_fontSizeMin: 18
m_fontSizeMax: 72
m_fontStyle: 0
m_HorizontalAlignment: 1
m_HorizontalAlignment: 2
m_VerticalAlignment: 512
m_textAlignment: 65535
m_characterSpacing: 0
@@ -467,6 +468,20 @@ MonoBehaviour:
m_hasFontAssetChanged: 0
m_baseMaterial: {fileID: 0}
m_maskOffset: {x: 0, y: 0, z: 0, w: 0}
--- !u!114 &2434642568171694670
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 3173428625324700048}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: 3245ec927659c4140ac4f8d17403cc18, type: 3}
m_Name:
m_EditorClassIdentifier:
m_HorizontalFit: 2
m_VerticalFit: 2
--- !u!1 &3184001677813492081
GameObject:
m_ObjectHideFlags: 0
@@ -602,10 +617,10 @@ RectTransform:
- {fileID: 3057577346065872911}
m_Father: {fileID: 0}
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
m_AnchorMin: {x: 0, y: 1}
m_AnchorMax: {x: 1, y: 1}
m_AnchorMin: {x: 0.5, y: 1}
m_AnchorMax: {x: 0.5, y: 1}
m_AnchoredPosition: {x: 0, y: 0}
m_SizeDelta: {x: 0, y: 40}
m_SizeDelta: {x: 90, y: 80}
m_Pivot: {x: 0.5, y: 0.5}
--- !u!222 &9006872392457284266
CanvasRenderer:
@@ -684,7 +699,7 @@ MonoBehaviour:
m_Name:
m_EditorClassIdentifier:
nameText: {fileID: 197987882297848403}
iconImage: {fileID: 8523083271074557203}
thumbnail: {fileID: 8697110781996111556}
loadProgress: {fileID: 9157065393132299556}
expandButton: {fileID: 459961761490458298}
paddingRT: {fileID: 1659788767784672500}
@@ -720,17 +735,6 @@ MonoBehaviour:
lowerLine: {fileID: 4764771198905317747}
lineColor: {r: 1, g: 0, b: 0, a: 0.47058824}
highLight: {fileID: 4406185178758208484}
itemSprites:
- type: 1
sprite: {fileID: 21300000, guid: aeb5d9c57606d4dfe8a6b9fbf2f02724, type: 3}
- type: 2
sprite: {fileID: 21300000, guid: 11d239518c86e4f1a96c2548526f2d01, type: 3}
- type: 3
sprite: {fileID: 21300000, guid: 89898a01151c19c4580b1470257609cd, type: 3}
- type: 4
sprite: {fileID: 21300000, guid: 2a742499639b14fb6b84e6ee26c79416, type: 3}
- type: 5
sprite: {fileID: 21300000, guid: 7ba72824288e08d4cb3289c7b83c4fb5, type: 3}
isSelected: 0
--- !u!1 &3809916293675722094
GameObject:
@@ -954,7 +958,7 @@ RectTransform:
m_AnchorMin: {x: 0, y: 0.5}
m_AnchorMax: {x: 1, y: 0.5}
m_AnchoredPosition: {x: 0, y: 0}
m_SizeDelta: {x: 0, y: 40}
m_SizeDelta: {x: 0, y: 80}
m_Pivot: {x: 0.5, y: 0.5}
--- !u!222 &8712382800546322696
CanvasRenderer:
@@ -1037,7 +1041,7 @@ GameObject:
m_Component:
- component: {fileID: 2851634799881106517}
- component: {fileID: 5193183312611458682}
- component: {fileID: 8523083271074557203}
- component: {fileID: 8697110781996111556}
m_Layer: 5
m_Name: IconImage
m_TagString: Untagged
@@ -1059,10 +1063,10 @@ RectTransform:
m_Children: []
m_Father: {fileID: 8835006081575840586}
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
m_AnchorMin: {x: 0, y: 1}
m_AnchorMax: {x: 0, y: 1}
m_AnchoredPosition: {x: 30.5, y: -18}
m_SizeDelta: {x: 15, y: 15}
m_AnchorMin: {x: 0.5, y: 0.5}
m_AnchorMax: {x: 0.5, y: 0.5}
m_AnchoredPosition: {x: 0, y: 4}
m_SizeDelta: {x: 80, y: 50}
m_Pivot: {x: 0.5, y: 0.5}
--- !u!222 &5193183312611458682
CanvasRenderer:
@@ -1072,7 +1076,7 @@ CanvasRenderer:
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 6795736773272050223}
m_CullTransparentMesh: 1
--- !u!114 &8523083271074557203
--- !u!114 &8697110781996111556
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
@@ -1081,7 +1085,7 @@ MonoBehaviour:
m_GameObject: {fileID: 6795736773272050223}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: fe87c0e1cc204ed48ad3b37840f39efc, type: 3}
m_Script: {fileID: 11500000, guid: 1344c3c82d62a2a41a3576d8abb8e3ea, type: 3}
m_Name:
m_EditorClassIdentifier:
m_Material: {fileID: 0}
@@ -1092,16 +1096,13 @@ MonoBehaviour:
m_OnCullStateChanged:
m_PersistentCalls:
m_Calls: []
m_Sprite: {fileID: 0}
m_Type: 0
m_PreserveAspect: 0
m_FillCenter: 1
m_FillMethod: 4
m_FillAmount: 1
m_FillClockwise: 1
m_FillOrigin: 0
m_UseSpriteMesh: 0
m_PixelsPerUnitMultiplier: 1
m_Texture: {fileID: 0}
m_UVRect:
serializedVersion: 2
x: 0
y: 0
width: 1
height: 1
--- !u!1 &7801651291590131016
GameObject:
m_ObjectHideFlags: 0

View File

@@ -187,8 +187,8 @@ MonoBehaviour:
m_OnClick:
m_PersistentCalls:
m_Calls:
- m_Target: {fileID: 0}
m_TargetAssemblyTypeName: ScrollItemUI, Assembly-CSharp
- m_Target: {fileID: -5127072004719193365}
m_TargetAssemblyTypeName: XED.HierarchyTree.HierarchyScrollItemUI, Assembly-CSharp
m_MethodName: ToggleExpandCollapse
m_Mode: 1
m_Arguments:

View File

@@ -5,8 +5,6 @@ namespace XED.Manage
public PopupCanvasHandler(Canvas_Popup canvas_Popup)
{
canvas_Popup.panel_assetlibrary.scrollView.onSelect.AddListener(canvas_Popup.panel_assetproperties.Open);
canvas_Popup.panel_assetlibrary.scrollView.onHover.AddListener(canvas_Popup.panel_thumbnail.HandleOpenClose);
canvas_Popup.panel_assetlibrary.scrollRect.onExit.AddListener(canvas_Popup.panel_thumbnail.HandleOpenClose);
canvas_Popup.panel_assetproperties.onClickPreview += canvas_Popup.panel_predefinedtype.Open;
canvas_Popup.panel_thumbnail.onGetPosition += canvas_Popup.panel_assetlibrary.GetPositionX;
}

View File

@@ -65,11 +65,11 @@ namespace XED.AssetLibraryTree
scrollRect.onValueChanged.AddListener(OnScrollValueChanged);
scrollRect.setToChildItem.AddListener(SetToChildItem);
scrollRect.setToPriorSiblingItem.AddListener(SetToPriorSiblingItem);
scrollRect.setToNextSiblingItem.AddListener(SetToNextSiblingItem);
scrollRect.setToNextSiblingItem.AddListener(SetToNextSiblingItem);
//아이템 하나당 높이값 저장
itemHeight = itemPrefab.GetComponent<RectTransform>().rect.height;
//뷰포트에 몇개의 아이템이 보이는지 한개의 여유분을 두고 계산
visibleItemCount = Mathf.CeilToInt(scrollRect.GetComponent<RectTransform>().sizeDelta.y / itemHeight) + 1;
float rowHeight = itemHeight + 10f; // row 간격 포함 (spacingY)
visibleItemCount = Mathf.CeilToInt(scrollRect.GetComponent<RectTransform>().sizeDelta.y / rowHeight) + 1;
searchInput.onValueChanged.AddListener(SearchData);
//searchCancelButton.onClick.RemoveAllListeners();
@@ -167,70 +167,74 @@ namespace XED.AssetLibraryTree
private void RebuildVisibleItems()
{
float rowHeight = itemHeight + 10f;
float scrollY = content.anchoredPosition.y;
int newIndex = Mathf.FloorToInt(scrollY / itemHeight);
if (newIndex < 0)
{
scrollY = 0;
newIndex = 0;
}
int newRowIndex = Mathf.FloorToInt(scrollY / rowHeight);
if (newRowIndex < 0) newRowIndex = 0;
// If the visible index hasn't changed, do nothing.
if (newIndex == currentIndex) return;
if (newRowIndex == currentIndex) return;
currentIndex = newRowIndex;
currentIndex = newIndex;
// Clear and recycle active items.
foreach (var item in activeItems)
{
pool.Release(item);
}
foreach (var item in activeItems) pool.Release(item);
activeItems.Clear();
if (data.Count == 0)
return;
int startIndex = Mathf.Clamp(currentIndex, 0, data.Count - 1);
int endIndex = Mathf.Clamp(currentIndex + visibleItemCount, 0, data.Count);
int itemsPerRow = 3;
int startIndex = Mathf.Clamp(currentIndex * itemsPerRow, 0, data.Count);
int endIndex = Mathf.Clamp((currentIndex + visibleItemCount) * itemsPerRow, 0, data.Count);
SetScrollItemUI(startIndex, endIndex);
}
private void RebuildVisibleItems(AssetLibraryItem focusItem)
{
int newIndex = data.FindIndex((x) => x == focusItem);
currentIndex = newIndex;
content.anchoredPosition = new Vector2(content.anchoredPosition.x, currentIndex * itemHeight);
int itemIndex = data.FindIndex((x) => x == focusItem);
currentIndex = itemIndex / 3;
// Clear and recycle active items.
foreach (var item in activeItems)
{
pool.Release(item);
}
float rowHeight = itemHeight + 10f;
content.anchoredPosition = new Vector2(content.anchoredPosition.x, currentIndex * rowHeight);
foreach (var item in activeItems) pool.Release(item);
activeItems.Clear();
if (data.Count == 0)
return;
int startIndex = Mathf.Clamp(currentIndex, 0, data.Count - 1);
int endIndex = Mathf.Clamp(currentIndex + visibleItemCount, 0, data.Count);
int itemsPerRow = 3;
int startIndex = Mathf.Clamp(currentIndex * itemsPerRow, 0, data.Count);
int endIndex = Mathf.Clamp((currentIndex + visibleItemCount) * itemsPerRow, 0, data.Count);
SetScrollItemUI(startIndex, endIndex);
}
private void SetScrollItemUI(int startIndex, int endIndex)
{
int maxWidth = Mathf.RoundToInt(scrollRect.GetComponent<RectTransform>().sizeDelta.x);
int itemsPerRow = 3;
float spacingX = 10f;
float spacingY = 10f;
RectTransform viewport = scrollRect.GetComponent<RectTransform>();
float contentWidth = viewport.sizeDelta.x;
float itemWidth = (contentWidth - spacingX * (itemsPerRow - 1)) / itemsPerRow;
int rowCount = Mathf.CeilToInt((float)data.Count / itemsPerRow);
float totalHeight = rowCount * (itemHeight + spacingY);
content.sizeDelta = new Vector2(contentWidth, totalHeight);
for (int i = startIndex; i < endIndex; i++)
{
AssetLibraryItem item = data[i];
AssetLibraryScrollItemUI itemUI = GetItemUI();
int w = itemUI.SetItemData(item);
itemUI.SetItemData(item);
itemUI.SetSelected(selectedItems);
if (w > maxWidth) maxWidth = w;
itemUI.transform.SetParent(content, false);
float yPos = -((float)i + 0.5f) * itemHeight;
itemUI.GetComponent<RectTransform>().anchoredPosition = new Vector2(0, yPos);
int row = i / itemsPerRow;
int col = i % itemsPerRow;
float x = col * (itemWidth + spacingX) - ((itemsPerRow - 1) * (itemWidth + spacingX)) / 2f;
float y = -row * (itemHeight + spacingY) - itemHeight / 2f;
RectTransform rt = itemUI.GetComponent<RectTransform>();
rt.sizeDelta = new Vector2(itemWidth, itemHeight);
rt.anchoredPosition = new Vector2(x, y);
activeItems.Add(itemUI);
}
content.sizeDelta = new Vector2(maxWidth, data.Count * itemHeight); // Set content height.
}
private AssetLibraryScrollItemUI GetItemUI()
{
@@ -243,7 +247,7 @@ namespace XED.AssetLibraryTree
itemUI.onClickMultiple.AddListener(OnSelectMultiple);
itemUI.onToggleExpand.RemoveAllListeners();
itemUI.onToggleExpand.AddListener(OnToggleExpand);
itemUI.onHover.AddListener(OnHover);
//itemUI.onHover.AddListener(OnHover);
return itemUI;
}
public void OnSelect(List<AssetLibraryItem> items)
@@ -272,10 +276,10 @@ namespace XED.AssetLibraryTree
lastSelectedItem = item;
onSelect?.Invoke(selectedItems);
}
public void OnHover(AssetLibraryItem item)
{
onHover?.Invoke(item);
}
//public void OnHover(AssetLibraryItem item)
//{
// onHover?.Invoke(item);
//}
public void OnSelectAnother(AssetLibraryItem item)
{
if (selectedItems.Count == 1 && selectedItems[0] == item)

View File

@@ -7,13 +7,16 @@ using UnityEngine.EventSystems;
using UnityEngine.Events;
using System;
using XRLib;
using XED.Manage;
using XED.Util;
using static Unity.Cinemachine.CinemachineSplineRoll;
namespace XED.AssetLibraryTree
{
public class AssetLibraryScrollItemUI : UnityEngine.MonoBehaviour, IPointerClickHandler, IPointerEnterHandler, IPointerExitHandler//, IBeginDragHandler, IEndDragHandler,
{
public TMP_Text nameText;
public Image iconImage;
public RawImage thumbnail;
public Image loadProgress;
public Button expandButton;
public RectTransform paddingRT;
@@ -34,11 +37,12 @@ namespace XED.AssetLibraryTree
public Image lowerLine;
public Color lineColor;
public GameObject highLight;
public List<HierarchyItemSprite> itemSprites;
private Image backgroundImage;
public bool isSelected;
private FBXFileManager fbxFileManager;
private void Awake()
{
fbxFileManager = ManagerHub.instance.Get<FBXFileManager>();
backgroundImage = GetComponent<Image>();
}
public int SetItemData(AssetLibraryItem item)
@@ -49,11 +53,15 @@ namespace XED.AssetLibraryTree
item.onLoadProgress.RemoveAllListeners();
item.onLoadProgress.AddListener(OnLoadProgress);
loadProgress.gameObject.SetActive(false);
HierarchyItemSprite itemSprite = itemSprites.Find((x) => x.type == item.type);
if (itemSprite != null) iconImage.sprite = itemSprite.sprite;
CustomAssetData data = fbxFileManager.GetCustomAssetData(item.name);
thumbnail.gameObject.SetActive(data != null);
thumbnail.texture = data != null ? data.thumbnail : null;
//if (texture != null) thumbnail.texture = texture;
expandButton.image.sprite = currentItem.isExpanded == true ? spriteExpanded : spriteCollapsed;
float width = nameText.GetComponent<RectTransform>().sizeDelta.x + iconImage.GetComponent<RectTransform>().sizeDelta.x;
float width = nameText.GetComponent<RectTransform>().sizeDelta.x + thumbnail.GetComponent<RectTransform>().sizeDelta.x;
float paddingSize = item.layerNum * expandButton.GetComponent<RectTransform>().sizeDelta.x;
if (item.children.Count > 0)
{
@@ -206,10 +214,4 @@ namespace XED.AssetLibraryTree
loadProgress.fillAmount = ratio;
}
}
[Serializable]
public class HierarchyItemSprite
{
public AssetLibraryItemType type;
public Sprite sprite;
}
}

View File

@@ -9,7 +9,7 @@ using XED.UI;
namespace XED.AssetLibraryTree
{
public class AssetLibraryScrollRect : ScrollRect, IPointerDownHandler, IPointerUpHandler, IPointerExitHandler
public class AssetLibraryScrollRect : ScrollRect, IPointerDownHandler
{
public bool passDragToChildren = true;
public UnityEvent<AssetLibraryItem, AssetLibraryItem> setToChildItem;
@@ -212,9 +212,9 @@ namespace XED.AssetLibraryTree
yield return null;
}
public void OnPointerExit(PointerEventData eventData)
{
onExit?.Invoke(null);
}
//public void OnPointerExit(PointerEventData eventData)
//{
// onExit?.Invoke(null);
//}
}
}