海拔图和小地图
This commit is contained in:
1 parent
42fa59d103
commit
8ad36c965d
521 files changed
+1985033
-439
No files matched your search
@@ -0,0 +1,74 @@
|
||||
/************************************************/
|
||||
/* */
|
||||
/* Copyright (c) 2018 - 2021 monitor1394 */
|
||||
/* https://github.com/monitor1394 */
|
||||
/* */
|
||||
/************************************************/
|
||||
|
||||
using UnityEngine;
|
||||
using UnityEngine.UI;
|
||||
|
||||
namespace XChartsDemo
|
||||
{
|
||||
internal static class UIUtil
|
||||
{
|
||||
|
||||
public static RectTransform GetRectTransform(Transform transform, string path)
|
||||
{
|
||||
if (!string.IsNullOrEmpty(path))
|
||||
{
|
||||
transform = transform.Find(path);
|
||||
}
|
||||
if (transform != null)
|
||||
{
|
||||
return transform.gameObject.GetComponent<RectTransform>();
|
||||
}
|
||||
return null;
|
||||
}
|
||||
public static void SetRectTransformWidth(Transform transform, float width, string path = null)
|
||||
{
|
||||
var rect = GetRectTransform(transform, path);
|
||||
if (rect != null)
|
||||
{
|
||||
rect.sizeDelta = new Vector2(width, rect.sizeDelta.y);
|
||||
}
|
||||
}
|
||||
public static void SetRectTransformHeight(Transform transform, float height, string path = null)
|
||||
{
|
||||
var rect = GetRectTransform(transform, path);
|
||||
if (rect != null)
|
||||
{
|
||||
rect.sizeDelta = new Vector2(rect.sizeDelta.x, height);
|
||||
}
|
||||
}
|
||||
public static void SetRectTransformLeft(Transform transform, float width, string path = null)
|
||||
{
|
||||
var rect = GetRectTransform(transform, path);
|
||||
if (rect != null)
|
||||
{
|
||||
rect.anchoredPosition = new Vector2(width, rect.anchoredPosition.y);
|
||||
}
|
||||
}
|
||||
|
||||
public static void SetGridLayoutGroup(Transform transform, Vector2 cellSize, Vector2 spacing, string path = null)
|
||||
{
|
||||
if (!string.IsNullOrEmpty(path))
|
||||
{
|
||||
transform = transform.Find(path);
|
||||
}
|
||||
if (transform != null)
|
||||
{
|
||||
var com = transform.gameObject.GetComponent<GridLayoutGroup>();
|
||||
if (com != null)
|
||||
{
|
||||
com.cellSize = cellSize;
|
||||
com.spacing = spacing;
|
||||
}
|
||||
else
|
||||
{
|
||||
Debug.LogError("SetGridLayoutGroupSize ERROR:can't find GridLayoutGroup: " + (transform.name + "/" + path));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user