竖倾斜ScrollView
using UnityEngine;
using UnityEngine.EventSystems; public class ObliqueScroll : MonoBehaviour,IDragHandler
{
public RectTransform viewport;
public ObliqueScrollContent content; private Transform target;
private float space_min;
private float space_max; private Vector3 position_c; private void OnValidate()
{
if (content != null)
{
target = content.transform;
space_min = ;
space_max = target.childCount * (content.v_cell.y + content.v_space) - viewport.rect.height;
if (space_max < )
{
space_max = ;
}
}
} public void OnDrag(PointerEventData eventData)
{
float move_c = eventData.delta.y;
position_c = target.localPosition;
position_c.y += move_c;
position_c = CheckOut(position_c);
target.localPosition = position_c;
} private Vector3 CheckOut(Vector3 position)
{
if (position.y <= space_min)
{
position.y = space_min;
}
if (position.y >= space_max)
{
position.y = space_max;
}
return position;
}
}
using UnityEngine; public class ObliqueScrollContent : MonoBehaviour
{
public Vector2 v_cell;
public float v_space;
public float v_offset; private Vector2 half = new Vector2(0.5f, 0.5f); private void OnValidate()
{
Refresh();
} private void Refresh()
{
for (int i = ; i < transform.childCount; i++)
{
Transform cell = transform.GetChild(i);
float pos_x = -i * v_offset;
float pos_y = -i * (v_cell.y + v_space);
RefreshCell(cell, new Vector3(pos_x, pos_y, ));
}
} private void RefreshCell(Transform cell, Vector3 position)
{
RectTransform rt = (RectTransform)cell;
rt.anchorMin = half;
rt.anchorMax = half;
rt.pivot = half;
rt.SetSizeWithCurrentAnchors(RectTransform.Axis.Horizontal, v_cell.x);
rt.SetSizeWithCurrentAnchors(RectTransform.Axis.Vertical, v_cell.y);
rt.localPosition = position;
}
}
只是一个思路,拖动很生硬
Scroll(加ObliqueScroll, 倾斜X度)
viewport(加mask)
content(加ObliqueScrollContent, 倾斜-X度)
item1
item2
item3
竖倾斜ScrollView的更多相关文章
- 【水滴石穿】react-native-app
项目地址:https://github.com/WQone/react-native-app 这个是一个非常优秀的小姐姐写的,希望大家能够以她为榜样,一起加油进步呀- 先看效果 分析package.j ...
- React-Native学习系列(二) Image和ScrollView
接下来,我们接着(一)继续讲,今天我们学习的是Image组件和ScrollView组件. Image组件 Image:一个用于显示多种不同类型图片的React组件.那么要如何使用呢? 引入本地图片: ...
- scrollView的讲解
今天就讲下UIScrollView的一些事情,这个可以拖动的组件无论在应用还是游戏开发都会经常用到,所以我们就一定要更加熟悉它了.下面我们开始下手咯. (1)初始化 一般的组件初始化都可以alloc和 ...
- SwipeRefreshLayout嵌套ScrollView包裹复杂头布局和RecyclerView
布局如下:上面是一个描述有:头像和部分信息的布局,底部是一个RecyclerView: 想法:想实现RecyclerView向上滚动的时候,隐藏上面的头像布局信息:使用了 CoordinatorLay ...
- iOS开发——项目篇—高仿百思不得姐 05——发布界面、发表文字界面、重识 bounds、frame、scrollView
加号界面(发布模块) 一.点击加号modal出发布模块,创建控件,布局控件1)使用xib加载view,如果在viewDidLoad创建控件并设置frame 那么self.view 的宽高 拿到的是xi ...
- RecyclerView和ScrollView嵌套使用
我们的recyclerView有多个layoutmanager,通过重写layoutmanager的方法就可以让recyclerView和ScrollView嵌套了.但是请注意,如果recyclerV ...
- ScrollView图片分页显示-简单
用到的控件: 1>UIScrollView:宽度和图片的宽度一样,因为分页的代码就一句 // 设置分页,这个分页的原理实际上是按照ScrollView的宽进行分页的,这里的图片的宽由于和Scro ...
- ScrollView嵌套recyclerView出现的滑动问题
记得以前在解决scrollView与ListView嵌套问题时,那个时候是自定义了listView去测量listView高度,今天项目中刚 好碰到了要用recycerView,同样也是嵌套在scrol ...
- 制作滚动视图(ScrollView)
怎样判断是否应当使用滚动视图 所谓的滚动视图,是指一个可以滑动的视窗,视窗大小和位置固定不变,视窗内的内容用户可以通过手指滑动或者拖动滚动天来进行滚动浏览. 滚动视图的目的是为了解决同类内容过多,一个 ...
随机推荐
- halcon之 distance_transform
Compute the distance transformation of a region 该算子的作用是计算对region转换距离.该算子的形式为distance_transform(Reg ...
- IOS-电话拦截
IOS10的电话拦截理念与android不一样,基于隐私保护的理念IOS没把对方号码送给应用,因此需要反过来由app把需要识别或拦截的电话存入系统数据库.这一功能通过Call Directory Ex ...
- docker容器添加微软雅黑字体
添加中文字体其实很简单,往容器里COPY一个ttf字体文件就生效了,不需要执行fc-cache. 基于debian 8的tomcat容器,Dockerfile: COPY msyh.ttf /usr/ ...
- nginx学习与使用
安装与运行 (从源码安装,这里OS为Ubuntu,参考资料:https://nginx.org/en/docs/configure.html) 1.下载并解压:https://nginx.org/en ...
- ABBYY PDF Transformer+ 给你好看
ABBYY PDF Transformer+是一个新的.全面的巧妙解决PDF文档的工具,它将泰比的光学字符识别(OCR)技术和Adobe®PDF技术完美结合,以确保实现便捷地处理任何类型的PDF文件, ...
- shell脚本学习笔记(符号)
shell脚本的学习: 1.Shell的作用是解释运行用户的命令,用户输入一条命令,Shell就解释运行一条,这样的方式称为交互式(Interactive),Shell还有 一种运行命令的方式称为批处 ...
- mysql 字符串 拼接 截取 替换
一. 字符串拼接 concat('asdf',str); 说明: 拼接asdf 和 str 二. 字符串截取 从左开始截取字符串 left(str, length) 说明:) as abstract ...
- 【转】最新版PyCharm(2018.2)破解
源链接 1.下载jar包 我突然发现这个包是通用的!IDEA,PyCharm都可以用 链接:http://idea.lanyus.com/ 上篇IDEA破解依旧是这个jar包 2.jar包放置位置将j ...
- PHP(Dom操作)
jsDOM操作组成: ECMAscript:语法核心 BOM:浏览器对象模型 window:窗口 open close 定时器 dingsh history:历史记录 go back location ...
- Python学习之旅(三十六)
Python基础知识(35):电子邮件(Ⅱ) 收取邮件就是编写一个MUA作为客户端,从MDA把邮件获取到用户的电脑或者手机上 收取邮件最常用的协议是POP协议,目前版本号是3,俗称POP3 Pytho ...