1. using UnityEngine;
  2. using UnityEngine.EventSystems;
  3.  
  4. public class ObliqueScroll : MonoBehaviour,IDragHandler
  5. {
  6. public RectTransform viewport;
  7. public ObliqueScrollContent content;
  8.  
  9. private Transform target;
  10. private float space_min;
  11. private float space_max;
  12.  
  13. private Vector3 position_c;
  14.  
  15. private void OnValidate()
  16. {
  17. if (content != null)
  18. {
  19. target = content.transform;
  20. space_min = ;
  21. space_max = target.childCount * (content.v_cell.y + content.v_space) - viewport.rect.height;
  22. if (space_max < )
  23. {
  24. space_max = ;
  25. }
  26. }
  27. }
  28.  
  29. public void OnDrag(PointerEventData eventData)
  30. {
  31. float move_c = eventData.delta.y;
  32. position_c = target.localPosition;
  33. position_c.y += move_c;
  34. position_c = CheckOut(position_c);
  35. target.localPosition = position_c;
  36. }
  37.  
  38. private Vector3 CheckOut(Vector3 position)
  39. {
  40. if (position.y <= space_min)
  41. {
  42. position.y = space_min;
  43. }
  44. if (position.y >= space_max)
  45. {
  46. position.y = space_max;
  47. }
  48. return position;
  49. }
  50. }
  1. using UnityEngine;
  2.  
  3. public class ObliqueScrollContent : MonoBehaviour
  4. {
  5. public Vector2 v_cell;
  6. public float v_space;
  7. public float v_offset;
  8.  
  9. private Vector2 half = new Vector2(0.5f, 0.5f);
  10.  
  11. private void OnValidate()
  12. {
  13. Refresh();
  14. }
  15.  
  16. private void Refresh()
  17. {
  18. for (int i = ; i < transform.childCount; i++)
  19. {
  20. Transform cell = transform.GetChild(i);
  21. float pos_x = -i * v_offset;
  22. float pos_y = -i * (v_cell.y + v_space);
  23. RefreshCell(cell, new Vector3(pos_x, pos_y, ));
  24. }
  25. }
  26.  
  27. private void RefreshCell(Transform cell, Vector3 position)
  28. {
  29. RectTransform rt = (RectTransform)cell;
  30. rt.anchorMin = half;
  31. rt.anchorMax = half;
  32. rt.pivot = half;
  33. rt.SetSizeWithCurrentAnchors(RectTransform.Axis.Horizontal, v_cell.x);
  34. rt.SetSizeWithCurrentAnchors(RectTransform.Axis.Vertical, v_cell.y);
  35. rt.localPosition = position;
  36. }
  37. }

只是一个思路,拖动很生硬

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. 微信jssdk常见错误及解决方法

    调用config 接口的时候传入参数 debug: true 可以开启debug模式,页面会alert出错误信息.以下为常见错误及解决方法: invalid url domain当前页面所在域名与使用 ...

  2. 此请求已被阻止,因为当用在 GET 请求中时,会将敏感信息透漏给第三方网站。若要允许 GET 请求,请将 JsonRequestBehavior 设置为 AllowGet。

    1.问题描述 mvc从一个路径获取所有的图片信息,ajax方法如下: function getimages(day) { var year = $("#selYear").val( ...

  3. Zookeeper客户端介绍

    客户端是开发人员使用Zookeeper的主要的途径,以下内容将对Zookeeper的内部原理进行详细的学习和讲解.ZooKeeper的客户端主要有一下几个核心组件组成: Zookeeper:提供客户端 ...

  4. java.exe和javaw.exe的区别

    相同点:二者都是Java的虚拟机,用来执行Java程序 区别: 1. javaw.exe运行程序时不会输出控制台信息 (注:“w”就是window的意思). 使用案例  start.bat(y以下代码 ...

  5. 使用docker安装mysql服务

    使用docker官方镜像安装mysql服务 1 拉取mysql镜像,采用网易加速地址 docker pull hub.c.163.com/library/mysql:5.7 2 重命名镜像名 dock ...

  6. Flutter & Dart 安装在window系统

    一.系统环境 flutter最低要求 1,windows7 SP1 64位版本以上,我的系统就是windows 7 sp1 64bit 2,git for windows ,没有安装的需要到这里下载  ...

  7. 禅道迁移(windows_to_linux)

    需求分析 随着禅道数据的增加,原来通过虚拟机提供的mysql服务器相应速度跟不上需求.且原来禅道的前端与数据库分离安装在windows与linux中,现在提供实体服务器,需要将禅道环境迁移. 确认环境 ...

  8. 关于4A网络安全管控平台控件加载失败的解决方法

    最近电脑重装系统后,到公司登录4A管控平台提示"控件加载失败","无效的参数为:Null","点击资源无任何反映"等等问题 别人的电脑用的好 ...

  9. mui---获取设备的网络状态

    在用mui做音乐或视频播放器的时候,往往会考虑当前音乐+视频的播放环境.例如是4G ,WIFI,无网络,给出特定的提示: 具体做法:根据 getCurrentType来进行获取当前网络的类型: plu ...

  10. Retrofit2 项目配置

    在项目的 app  build.gradle 文件中加入 dependencies { // Retrofit2implementation 'com.squareup.retrofit2:retro ...