• 大小: 1.22MB
    文件类型: .zip
    金币: 1
    下载: 0 次
    发布日期: 2023-08-09
  • 语言: 其他
  • 标签: unity  UGUI  优化  

资源简介

UGUI ScrollRect滚动优化:无限循环利用Item,需要优化滚动UI的可以看看

资源截图

代码片段和文件信息

using UnityEngine;
using UnityEngine.UI;
using System.Collections;

public class ScrollIndexCallback1 : MonoBehaviour 
{
    public Image image;
public Text text;

    void ScrollCellIndex (int idx) 
    {
string name = “Cell “ + idx.ToString ();
if (text != null) 
        {
text.text = name;
}
        if (image != null)
        {
            image.color = Rainbow(idx / 50.0f);
        }
gameobject.name = name;
}

    // http://stackoverflow.com/questions/2288498/how-do-i-get-a-rainbow-color-gradient-in-c
    public static Color Rainbow(float progress)
    {
        progress = Mathf.Clamp01(progress);
        float r = 0.0f;
        float g = 0.0f;
        float b = 0.0f;
        int i = (int)(progress * 6);
        float f = progress * 6.0f - i;
        float q = 1 - f;

        switch (i % 6)
        {
            case 0:
                r = 1;
                g = f;
                b = 0;
                break;
            case 1:
                r = q;
                g = 1;
                b = 0;
                break;
            case 2:
                r = 0;
                g = 1;
                b = f;
                break;
            case 3:
                r = 0;
                g = q;
                b = 1;
                break;
            case 4:
                r = f;
                g = 0;
                b = 1;
                break;
            case 5:
                r = 1;
                g = 0;
                b = q;
                break;
        }
        return new Color(r g b);
    }
}

 属性            大小     日期    时间   名称
----------- ---------  ---------- -----  ----
     目录           0  2018-01-10 16:15  LoopScrollRect-master\
     文件         399  2018-01-10 16:15  LoopScrollRect-master\.gitignore
     目录           0  2018-01-10 16:15  LoopScrollRect-master\Assets\
     文件         201  2018-01-10 16:15  LoopScrollRect-master\Assets\Demo.meta
     目录           0  2018-01-10 16:15  LoopScrollRect-master\Assets\Demo\
     文件       65436  2018-01-10 16:15  LoopScrollRect-master\Assets\Demo\DemoScene.unity
     文件         183  2018-01-10 16:15  LoopScrollRect-master\Assets\Demo\DemoScene.unity.meta
     文件         201  2018-01-10 16:15  LoopScrollRect-master\Assets\Demo\Resources.meta
     目录           0  2018-01-10 16:15  LoopScrollRect-master\Assets\Demo\Resources\
     文件        6613  2018-01-10 16:15  LoopScrollRect-master\Assets\Demo\Resources\ScrollCell1.prefab
     文件         188  2018-01-10 16:15  LoopScrollRect-master\Assets\Demo\Resources\ScrollCell1.prefab.meta
     文件        6269  2018-01-10 16:15  LoopScrollRect-master\Assets\Demo\Resources\ScrollCell2.prefab
     文件         188  2018-01-10 16:15  LoopScrollRect-master\Assets\Demo\Resources\ScrollCell2.prefab.meta
     文件        6352  2018-01-10 16:15  LoopScrollRect-master\Assets\Demo\Resources\ScrollCell3.prefab
     文件         188  2018-01-10 16:15  LoopScrollRect-master\Assets\Demo\Resources\ScrollCell3.prefab.meta
     文件         201  2018-01-10 16:15  LoopScrollRect-master\Assets\Demo\scripts.meta
     目录           0  2018-01-10 16:15  LoopScrollRect-master\Assets\Demo\scripts\
     文件        1627  2018-01-10 16:15  LoopScrollRect-master\Assets\Demo\scripts\ScrollIndexCallback1.cs
     文件         275  2018-01-10 16:15  LoopScrollRect-master\Assets\Demo\scripts\ScrollIndexCallback1.cs.meta
     文件         544  2018-01-10 16:15  LoopScrollRect-master\Assets\Demo\scripts\ScrollIndexCallback2.cs
     文件         275  2018-01-10 16:15  LoopScrollRect-master\Assets\Demo\scripts\ScrollIndexCallback2.cs.meta
     文件         333  2018-01-10 16:15  LoopScrollRect-master\Assets\Demo\scripts\ScrollIndexCallback3.cs
     文件         275  2018-01-10 16:15  LoopScrollRect-master\Assets\Demo\scripts\ScrollIndexCallback3.cs.meta
     文件         201  2018-01-10 16:15  LoopScrollRect-master\Assets\scripts.meta
     目录           0  2018-01-10 16:15  LoopScrollRect-master\Assets\scripts\
     文件         201  2018-01-10 16:15  LoopScrollRect-master\Assets\scripts\EasyobjectPool.meta
     目录           0  2018-01-10 16:15  LoopScrollRect-master\Assets\scripts\EasyobjectPool\
     文件        5240  2018-01-10 16:15  LoopScrollRect-master\Assets\scripts\EasyobjectPool\EasyobjectPool.cs
     文件         275  2018-01-10 16:15  LoopScrollRect-master\Assets\scripts\EasyobjectPool\EasyobjectPool.cs.meta
     文件        4600  2018-01-10 16:15  LoopScrollRect-master\Assets\scripts\EasyobjectPool\ResourceManager.cs
     文件         263  2018-01-10 16:15  LoopScrollRect-master\Assets\scripts\EasyobjectPool\ResourceManager.cs.meta
............此处省略47个文件信息

评论

共有 条评论