110 lines
3.7 KiB
C#
110 lines
3.7 KiB
C#
using UnityEngine;
|
|
|
|
//星星特效属性
|
|
namespace Thousandto.Code.Logic
|
|
{
|
|
public class PFAssetDefines
|
|
{
|
|
//标题栏内容
|
|
public static string[] TitleArray = new string[]
|
|
{
|
|
"开始加载",
|
|
"结束加载",
|
|
"加载耗时",
|
|
"使用次数",
|
|
"卸载时间",
|
|
"卸载次数",
|
|
"生存时间",
|
|
};
|
|
|
|
public static Texture WhiteBlank;
|
|
public static Texture BlackBlank;
|
|
public static Texture BlackBlankAll;
|
|
public static Texture ColorTex;
|
|
|
|
//名字区域
|
|
public static Rect NameAreaRect = new Rect(0, 0, 300, 150);
|
|
//标题栏区域
|
|
public static Rect HeadTitleRect = new Rect(0, 0, 600, 40);
|
|
//内容滑动区域
|
|
public static Rect ScrollRect = new Rect(0, 0, 600, 150);
|
|
//内容滑动位置
|
|
public static Vector2 ScrollPos = new Vector2(0, 0);
|
|
//名字区域滑动位置
|
|
public static Vector2 NameScrollPos = new Vector2(0, 0);
|
|
//窗体尺寸
|
|
public static Rect WindowSize = new Rect(0, 0, 0, 0);
|
|
//内容滑动偏移量
|
|
public static float ScrollOffsetX = 0;
|
|
//单元格宽度
|
|
public static float CellWidth = 0;
|
|
public static float CellHeight = 40;
|
|
|
|
static PFAssetDefines()
|
|
{
|
|
|
|
}
|
|
|
|
//根据窗口大小,调整各个区域的位置和大小
|
|
public static void ResetRectData(Rect windowSize)
|
|
{
|
|
WindowSize = windowSize;
|
|
|
|
NameAreaRect.y = HeadTitleRect.height + HeadTitleRect.y;
|
|
NameAreaRect.height = WindowSize.height - NameAreaRect.y - 100;
|
|
//标题栏起始位置要加上左侧名字区域的宽度
|
|
HeadTitleRect.x = NameAreaRect.width + NameAreaRect.x;
|
|
HeadTitleRect.width = WindowSize.width - HeadTitleRect.x - 20;
|
|
//内容滑动区域的起始位置也要加上左侧名字区域的宽度
|
|
ScrollRect.x = NameAreaRect.width + NameAreaRect.x;
|
|
//内容滑动区域y方向起始位置要加上标题栏位置和高度
|
|
ScrollRect.y = HeadTitleRect.y + HeadTitleRect.height;
|
|
//内容宽度和标题栏一样
|
|
ScrollRect.width = HeadTitleRect.width;
|
|
//内容高度和名字区域一样
|
|
ScrollRect.height = NameAreaRect.height;
|
|
|
|
//单元格宽度等于标题栏宽度/标题个数
|
|
CellWidth = HeadTitleRect.width / TitleArray.Length;
|
|
}
|
|
|
|
public static Texture2D CreateColorTex(Color color, int w, int h)
|
|
{
|
|
Texture2D tex = new Texture2D(w, h);
|
|
for (int i = 0; i < w; ++i)
|
|
{
|
|
for (int n = 0; n < h; ++n)
|
|
{
|
|
tex.SetPixel(i, n, color);
|
|
}
|
|
}
|
|
tex.Apply();
|
|
|
|
return tex;
|
|
}
|
|
|
|
public static void InitTexBlank()
|
|
{
|
|
WhiteBlank = CreateColorTex(new Color(1, 1, 1, 0.1f), 10, 10);
|
|
BlackBlank = CreateColorTex(new Color(0, 0, 0, 0.1f), 10, 10);
|
|
BlackBlankAll = CreateColorTex(new Color(0, 0, 0, 1f), 10, 10);
|
|
ColorTex = CreateColorTex(new Color((60f / 255f), (113f / 255f), 0, 1f), (int)HeadTitleRect.width, (int)HeadTitleRect.height);
|
|
}
|
|
|
|
public static void DestroyTexture()
|
|
{
|
|
DestoryTexture(WhiteBlank);
|
|
DestoryTexture(BlackBlank);
|
|
DestoryTexture(BlackBlankAll);
|
|
DestoryTexture(ColorTex);
|
|
}
|
|
|
|
private static void DestoryTexture(Texture tex)
|
|
{
|
|
if (tex != null)
|
|
GameObject.Destroy(tex);
|
|
}
|
|
}
|
|
}
|
|
|