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

济南网站建站推广python做软件的网站

济南网站建站推广,python做软件的网站,网站建设费科目,中国进入全国紧急状态展示效果 原理: 当停止滑动时 判断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.hkea.cn/news/14266921/

相关文章:

  • 网站备案证书下载密码忘了网站开发设计语言
  • wordpress最新淘宝客程序优化网站浏览量怎么看
  • 做网站中怎么设置单张图片如何用家用电脑做网站
  • 做国外网站用什么颜色河北智能网站建设平台
  • 网站 为什么要备案wordpress怎么编写用户中心
  • 织梦做的网站自己建一个电商网站吗
  • 政务网站建设信息wordpress ip 地址修改密码
  • 广州做网站信科网络网站建设公司首选
  • 网站建设 需要注意什么管理咨询师
  • 中国变装网站教你如何做女人网架生产厂家联系方式
  • wordpress程序建站网站经常出现502
  • 做装修的有那些网站云匠网官网
  • 专业做公司宣传网站网站建设报价清单内容
  • 龙岗网站制作效果微信网站制作企业
  • 厦门做模板网站的公司网站后台上传文章格式
  • 一流的聊城做网站费用自贡做响应式网站开发公司
  • 网站集约化平台建设专注赣州网站建设
  • 网站建设运维情况2019做网站需要营业执照吗
  • 怎么在自己做的网站上发视频教程做家装网站源码
  • 上海网站建设口碑好大同网络公司
  • 淮安新港建设有限公司网站wordpress主题公园
  • 阿里云服务器 放多个网站装饰工程施工流程步骤
  • 电子商务网站建设实训报告文章孩子学编程一年要多少钱
  • 西乡专业做网站公司给客户做一个网站ppt怎么做
  • redis做网站保定网站建设浩森宇特
  • 那个网站的域名便宜营销自己的网站
  • 石家庄建设一个网站多少钱网页设计心得体会100
  • 网站的基本知识怎样做一个公司网站
  • 沈阳点金网站建设网站后台用什么
  • 网站优化哪里可以做爱有声小说网站捡个校花做老婆