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的更多相关文章

  1. 【水滴石穿】react-native-app

    项目地址:https://github.com/WQone/react-native-app 这个是一个非常优秀的小姐姐写的,希望大家能够以她为榜样,一起加油进步呀- 先看效果 分析package.j ...

  2. React-Native学习系列(二) Image和ScrollView

    接下来,我们接着(一)继续讲,今天我们学习的是Image组件和ScrollView组件. Image组件 Image:一个用于显示多种不同类型图片的React组件.那么要如何使用呢? 引入本地图片: ...

  3. scrollView的讲解

    今天就讲下UIScrollView的一些事情,这个可以拖动的组件无论在应用还是游戏开发都会经常用到,所以我们就一定要更加熟悉它了.下面我们开始下手咯. (1)初始化 一般的组件初始化都可以alloc和 ...

  4. SwipeRefreshLayout嵌套ScrollView包裹复杂头布局和RecyclerView

    布局如下:上面是一个描述有:头像和部分信息的布局,底部是一个RecyclerView: 想法:想实现RecyclerView向上滚动的时候,隐藏上面的头像布局信息:使用了 CoordinatorLay ...

  5. iOS开发——项目篇—高仿百思不得姐 05——发布界面、发表文字界面、重识 bounds、frame、scrollView

    加号界面(发布模块) 一.点击加号modal出发布模块,创建控件,布局控件1)使用xib加载view,如果在viewDidLoad创建控件并设置frame 那么self.view 的宽高 拿到的是xi ...

  6. RecyclerView和ScrollView嵌套使用

    我们的recyclerView有多个layoutmanager,通过重写layoutmanager的方法就可以让recyclerView和ScrollView嵌套了.但是请注意,如果recyclerV ...

  7. ScrollView图片分页显示-简单

    用到的控件: 1>UIScrollView:宽度和图片的宽度一样,因为分页的代码就一句 // 设置分页,这个分页的原理实际上是按照ScrollView的宽进行分页的,这里的图片的宽由于和Scro ...

  8. ScrollView嵌套recyclerView出现的滑动问题

    记得以前在解决scrollView与ListView嵌套问题时,那个时候是自定义了listView去测量listView高度,今天项目中刚 好碰到了要用recycerView,同样也是嵌套在scrol ...

  9. 制作滚动视图(ScrollView)

    怎样判断是否应当使用滚动视图 所谓的滚动视图,是指一个可以滑动的视窗,视窗大小和位置固定不变,视窗内的内容用户可以通过手指滑动或者拖动滚动天来进行滚动浏览. 滚动视图的目的是为了解决同类内容过多,一个 ...

随机推荐

  1. Netty 学习笔记(1)通信原理

    前言 本文主要从 select 和 epoll 系统调用入手,来打开 Netty 的大门,从认识 Netty 的基础原理 —— I/O 多路复用模型开始.   Netty 的通信原理 Netty 底层 ...

  2. 框架源码系列十一:事务管理(Spring事务管理的特点、事务概念学习、Spring事务使用学习、Spring事务管理API学习、Spring事务源码学习)

    一.Spring事务管理的特点 Spring框架为事务管理提供一套统一的抽象,带来的好处有:1. 跨不同事务API的统一的编程模型,无论你使用的是jdbc.jta.jpa.hibernate.2. 支 ...

  3. GDC2017【神秘海域 4】中所使用的顶点着色器技术

    原文链接 http://game.watch.impress.co.jp/docs/news/1047802.html   会場:San Francisco Moscone Convention Ce ...

  4. VS IISExpress REST DELETE 405 Method Not Allowed

    [参考].net IIS MVC Rest api 跨域 PUT DELETE 404 无法使用问题解决方案 今日在使用泛型處理常式處理檔案上傳時,使用了 HTTP 動詞的 PUT.DELETE 進行 ...

  5. spring-boot子模块打包去掉BOOT-INF文件夹

    1.spring-boot maven打包,一般pom.xml文件里会加 <plugin> <groupId>org.springframework.boot</grou ...

  6. 使用docker安装tomcat服务

    1. 拉取官方tomcat镜像 docker pull tomcat 2. 创建tomcat容器目录 [root@WSyHRQ171356 /]# mkdir /tomcat/test 3. 创建测试 ...

  7. A new session could not be created. (Original error: Requested a new session but one was in progress) (WARNING: The server did not provide any stacktrace information)

    出现这个问题,是因为关毕了appium,或者是关毕了appium再次打开,那么session就不是一样的了所以报错. 一般是因为测试的时候报错了,appium自动关毕了,再次打出现的报错 解决方法:重 ...

  8. thymeleaf入门和学习

    springboot框架不推荐使用jsp,一方面是兼容性的技术问题,一方面也是其前后端整合在一起,很难适合当下大规模的网站开发环境.HTML只是一种标记语言,并不具有获取model中数据的功能,所以视 ...

  9. M - COURSES

    Consider a group of N students and P courses. Each student visits zero, one or more than one courses ...

  10. php项目,别人无法访问自己(windows 系统)上Apache服务器原因(转载)

    别人无法访问自己电脑上的Apache服务器,其中最大的原因是因为Windows防火墙的因素. 1.有安装防火墙的,把防火墙关闭 2.windows默认带防火墙的,进入 控制面板-系统和安全-Windo ...