学习FancyScrollView笔记

控制 Cell 批量生成的代码在哪里?

protected sealed override GameObject CellPrefab => cellGroupTemplate;

        protected sealed override GameObject CellPrefab => cellGroupTemplate;

        
        //等价于上面的代码
        public GameObject GetCellPrefab()
        {
            return cellGroupTemplate;
        }

        GameObject cellGroupTemplate;

Mathf.Ceil()        向上取整

Mathf.Ceil(10.1f);//返回11

Mathf.Ceil(-10.1f);//返回-10

Mathf.CeilToInt()        返回大于或等于 f 的最小整数

using UnityEngine;
using System.Collections;

public class ExampleClass : MonoBehaviour
{
    void Start()
    {
        // Prints 10
        Debug.Log(Mathf.CeilToInt(10.0f));
        // Prints 11
        Debug.Log(Mathf.CeilToInt(10.2f));
        // Prints 11
        Debug.Log(Mathf.CeilToInt(10.7f));

        // Prints -10
        Debug.Log(Mathf.CeilToInt(-10.0f));
        // Prints -10
        Debug.Log(Mathf.CeilToInt(-10.2f));
        // Prints -10
        Debug.Log(Mathf.CeilToInt(-10.7f));
    }
}

Debug.Assert()        检查条件 ;如果条件为 false,打出调用堆栈

泛型约束

public abstract class FancyGridViewCell<TItemData, TContext> : FancyScrollRectCell<TItemData, TContext> where TContext : class, IFancyGridViewContext, new()

Where T:Class,new()的使用
 当我们使用泛型的时候,有时候就会提示我们 T 必须是 引用类型 而无法进行下去,其实我们学泛型的时候也应该了解到这个 T 的使用场合,他可以是 值类型 也可以是 引用类型 ,但是我们某些场合就只能使用 引用类型 比如 EF 中的集合,所以我们就需要 强制标识这个 T 只能用于引用类型,这里就用到了 Where T :class这就是标识这个 T 为引用类型;而 new() 则表示这个 泛型必须有构造函数 否则不能使用。

  • 2
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值