32 lines
1.2 KiB
C#
32 lines
1.2 KiB
C#
using System;
|
|
using System.Collections;
|
|
using System.Collections.Generic;
|
|
using TMPro;
|
|
using UnityEngine;
|
|
using UnityEngine.Serialization;
|
|
using UnityEngine.UI;
|
|
|
|
namespace Ichni.Editor
|
|
{
|
|
public class DynamicUIContainer : MonoBehaviour
|
|
{
|
|
|
|
Inspector Inspector => EditorManager.instance.uiManager.inspector;
|
|
public TMP_Text title;
|
|
public GridLayoutGroup gridLayoutGroup;
|
|
public List<DynamicUIElement> dynamicUIElements = new List<DynamicUIElement>();
|
|
[FormerlySerializedAs("container")] public RectTransform rect;
|
|
|
|
public void SetDeviver(int num){//rect 500
|
|
gridLayoutGroup.cellSize=new Vector2(Inspector.inspectorRect.rect.width/num,gridLayoutGroup.cellSize.y);
|
|
|
|
bool CanCompress=true;//这是是想着如果没有按钮以外的东西就把y值调小一点的
|
|
|
|
foreach(var i in GetComponentsInChildren<DynamicUIElement>()){
|
|
i.DeviverSet(num);
|
|
if(i.GetType()!=typeof(DynamicUIButton))CanCompress=false;
|
|
}
|
|
if(CanCompress)gridLayoutGroup.cellSize=new Vector2(gridLayoutGroup.cellSize.x,gridLayoutGroup.cellSize.y/2);
|
|
}
|
|
}
|
|
} |