当前位置: 首页 > news >正文

网络营销建设网站实训珠海百度seo

网络营销建设网站实训,珠海百度seo,wordpress登录页logo修改,传奇辅助网站怎么做展示效果 原理: 当停止滑动时 判断Contet的horizontalNormalizedPosition 与子Item的缓存值 相减,并得到最小值#xff0c;然后将Content horizontalNormalizedPosition滚动过去 使用方式#xff1a; 直接将脚本挂到ScrollRect上 注意#xff1a;在创建Content子物体时…展示效果 原理: 当停止滑动时 判断Contet的horizontalNormalizedPosition 与子Item的缓存值 相减,并得到最小值然后将Content  horizontalNormalizedPosition滚动过去 使用方式 直接将脚本挂到ScrollRect上 注意在创建Content子物体时 或子物体数量变更需要调用Refresh 代码 namespace ShangShangQian.Component {using System.Collections;using System.Collections.Generic;using UnityEngine;using UnityEngine.UI;using UnityEngine.EventSystems;using System.Linq;using UnityEngine.Events;[RequireComponent(typeof(ScrollRect))]public class SnapScrollRect : MonoBehaviour, IBeginDragHandler, IDragHandler, IEndDragHandler{private RectTransform content;private ScrollRect rect;/// summary/// content 的位置应该滚到什么/// /summarypublic float target 1;/// summary/// 回滚的速度 0-1 越小越快/// /summarypublic float smooting 0.25f;public float currentVelocity;public float horizontalNormalizedPosition;public Listfloat values new Listfloat();public Listfloat distances new Listfloat();public ListRectTransform items new ListRectTransform();/// summary/// 是否拖拽中/// /summarypublic bool isDrag false;/// summary/// 到最近item的距离/// /summarypublic float distanceMin;/// summary/// 到最近item的索引/// /summarypublic int selectIndex;/// summary/// 是否匹配滑动中/// /summarypublic bool Snaping false;/// summary/// 回滚完毕后调用/// /summarypublic UnityEventint OnSnap;void Start(){rect GetComponentScrollRect();content rect.content;}/// summary/// 刷新数据content的子物体数量变更时需要调用此函数/// /summarypublic void Refresh(){items.Clear();values.Clear();for (int i 0; i content.childCount; i){if (content.GetChild(i).gameObject.activeInHierarchy){items.Add(content.GetChild(i).GetComponentRectTransform());}}//累加的变量values.Add(0);//每一个格子的所占比多少 float v 1f / (items.Count - 1);for (int i 1; i items.Count; i){values.Add(i * v);}//不同子元素数量 item 对应 的content horizontalNormalizedPosition 数值//1 0 //2 0 1 //3 0 0.5 1//4 0 0.33 0.66 1}void Update(){ #if UNITY_EDITORif (Input.GetKeyDown(KeyCode.A)){Refresh();} #endif}void FixedUpdate(){horizontalNormalizedPosition rect.horizontalNormalizedPosition;if (isDrag){return;}if (Snaping){rect.horizontalNormalizedPosition Mathf.SmoothDamp(rect.horizontalNormalizedPosition, target, ref currentVelocity, smooting);if (Mathf.Abs(rect.horizontalNormalizedPosition - values[selectIndex]) 0.001f){Snaping false;Debug.Log(回滚: selectIndex);OnSnap.Invoke(selectIndex);}}}public void OnBeginDrag(PointerEventData eventData){isDrag true;}public void OnDrag(PointerEventData eventData){isDrag true;}public void OnEndDrag(PointerEventData eventData){isDrag false;Snaping true;distances.Clear();//当松手后判断那个距离最近for (int i 0; i values.Count; i){distances.Add(Mathf.Abs(rect.horizontalNormalizedPosition - values[i]));}distanceMin distances.Min();selectIndex distances.FindIndex(b b distanceMin);target values[selectIndex];rect.StopMovement();}/// summary/// 滚到到指定位置/// /summary/// param nameindex/parampublic void SnapToIndex(int index){Snaping true;selectIndex index;target values[selectIndex];}} }
http://www.tj-hxxt.cn/news/131976.html

相关文章:

  • 动易网站制作教程wordpress文章背景音乐
  • 发布课程的网站模板网站开发接入支付宝
  • 东莞模块网站建设淄博网站制作方案
  • 专门做婚庆的网站有哪些如何建造企业网站
  • 做视频资源网站有哪些类似百度的网站
  • 电商网站建设毕业设计海珠区 网站设计
  • python+网站开发+prf网页设计专业公司
  • wordpress首页搭建烟台优化网站建设
  • ts431p 做网站wordpress 值得买主题
  • 网站维护主要需要会什么做指甲的网站叫什么名字来着
  • 长春网站建设外包wordpress管理员表
  • 柳州做网站优化门户网站后台建设模块
  • 黄金网站大全免费列表主题wordpress
  • 宣城网站 建设网站程序调试模式怎么做
  • 个人设计师的网站wordpress分类下的所有文章加密
  • 沈阳网站建设的公司哪家好池州市建设管理处网站
  • 网站一定要服务器吗wordpress dz 整合
  • 国外怎么做网站柯桥做网站
  • 会网站开发如何自己赚wordpress 设置邮箱
  • 手机网站的特效网站安装百度商桥
  • 刚接触网站建设有哪些问题app界面设计模板免费下载
  • 湛江网站优化详细介绍网站建设的整个流程
  • 企业网站宽度it项目网站开发的需求文档
  • 一般网站建设的流程图网站备案时长
  • 如何访问国外网站能在线做实验的网站
  • 外贸用什么平台自建站较好安徽网站优化好不好
  • 威县网站建设报价上海闵行建设局官方网站
  • 横泉水库建设管理局网站建设网站需要哪些材料
  • 做兼职的网站都有哪些工作网站名百度搜不到
  • 爱站网关键词排名开网店的步骤和流程