1.Image组件—“Source Image”,Set Native Size.

2.Image组件—“Image Type”——Sliced

编辑要放大缩小的图片,Sprite Editor,采用九宫格切图。

3.创建空物体(作为父物体),添加Componment—Layout—Grid Layout Group(是下面的子物体自动排列)

创建空物体和创建Panel作为父物体是由区别的!

4.锚点问题,是GUI中容易忽视但却十分重要的点。

5.Prefabs的有效使用,后期通过更改Prefabs来进行完整的映射修改。

6.滚动图片列表的制作

(1)选项卡图标排列整齐

(2)创建一个Image组件—“背景图”,命名为ScrollPanel(作为父物体,作为Mask),此时将选项卡托至此背景图下作为子物体。

(3)在“背景图”上添加“Scroll Rect”滑动组建,Content对象为选项卡图标集合,来控制子物体。

(4)在“背景图”上添加"Mask"组建。

(5)按页数进行滑动(分页)脚本

(6)单选按钮,进入制定页面,并与鼠标滑动脚本相关联。

 using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.EventSystems;
using UnityEngine.UI; public class LevelButtonScrollRect : MonoBehaviour ,IBeginDragHandler,IEndDragHandler{ // Use this for initialization
private ScrollRect scrollRect;
private float[] pageArrayFloats = new[] {, 0.33333f, 0.66666f, };
void Start ()
{
scrollRect = GetComponent<ScrollRect>();
} // Update is called once per frame
void Update () { }
public void OnBeginDrag(PointerEventData eventData)
{ }
public void OnEndDrag(PointerEventData eventData)
{
//Vector2 offsetTemp = scrollRect.normalizedPosition;
float offsetTemp = scrollRect.horizontalNormalizedPosition;
print(offsetTemp);
}
}

父物体添加过"ToggleGroup"组件

 using System.Collections;
using System.Collections.Generic;
using UnityEditor;
using UnityEngine;
using UnityEngine.EventSystems;
using UnityEngine.UI; public class LevelButtonScrollRect : MonoBehaviour ,IBeginDragHandler,IEndDragHandler{ // Use this for initialization
private ScrollRect scrollRect;
private float[] pageArrayFloats = new[] {, 0.33333f, 0.66666f, };
private float targetHorizontalPosition = ; //默认为第一页
private bool isDrag = false;
public float speed = 5f;
void Start ()
{
scrollRect = GetComponent<ScrollRect>(); //寻找组件,物体间的通信
} // Update is called once per frame
void Update () {
if (isDrag==false)
{
scrollRect.horizontalNormalizedPosition = Mathf.Lerp(scrollRect.horizontalNormalizedPosition,
targetHorizontalPosition, speed * Time.deltaTime);
}
} public void OnBeginDrag(PointerEventData eventData)
{
isDrag = true;
} public void OnEndDrag(PointerEventData eventData)
{
isDrag = false;
float posX = scrollRect.horizontalNormalizedPosition;
int index = ;
float offset = Mathf.Abs(pageArrayFloats[index] - posX);
for (int i = ; i < pageArrayFloats.Length; i++)
{
float offsetTemp = Mathf.Abs(pageArrayFloats[i] - posX);
if (offsetTemp < offset)
{
index = i;
offset = offsetTemp;
}
} //哪一页的位置与当前页的位置差最小,就定在哪一页上
//scrollRect.horizontalNormalizedPosition = pageArrayFloats[index];
targetHorizontalPosition = pageArrayFloats[index];
}
}
//注:最后一次鼠标滑动的位置是确定的,让这个位置与每一页的位置(4页的位置)比较,差值最小的,则固定在(4页位置)中的哪一页上
//多次判断语句,用到for循环(特别是for{if(){}})

UGUI_关卡选项界面的更多相关文章

  1. android判断adb调试是否打开及代码跳转到开发者选项界面

    boolean enableAdb = (Settings.Secure.getInt(getContentResolver(), Settings.Secure.ADB_ENABLED, 0) &g ...

  2. ubuntu和windows系统双系统的开机选项界面有很多无关选项

    我的电脑是双系统,在进入系统选项的时候有很多无关的选项, 例如: 解决的方法是在终端输入 sudo gedit /boot/grub/grub.cfg 把文件多余的开机选项删除例如: 保存就可以,开机 ...

  3. 在iOS应用程序中打开设备设置界面及其中某指定的选项界面

    摘自:http://stackoverflow.com/questions/8246070/ios-launching-settings-restrictions-url-scheme [[UIApp ...

  4. CCScrollView 实现帮助界面、关卡选择

    本文出自[无间落叶]:http://blog.leafsoar.com/archives/2013/07-27.html 本文介绍了 CCScrollView 来编写帮助界面和关卡选择界面的方法,在编 ...

  5. 吐槽版︱MRO-Microsoft R Open快捷键+界面识别+功能设置

    下载了之后,发现连运行(RUN键)在哪都不知道,蒙逼的在哪倒弄半天,都执行不了...问了别人,都说"ctrl+enter",但是我的电脑执行不了,于是今天就狠狠的一个一个按钮的点一 ...

  6. 不同版本的IDE ,对应的选项 有变化

    xx.dproj对应的项目级选项 也不同,所以,要分别保存为不同的文件. 如果不同的IDE,打开同一个 .dproj文件,会因为 选项界面的选项不同,提示一些错误.

  7. 【比赛打分展示双屏管理系统-专业版】Other.ini 配置文件解读以及排行榜界面及专家评语提交展示等具体配置

    第一个问题:Other.ini配置文件的解读: 在软件根目录下,找到Other.ini配置文件,打开如下: 配置文件解读: iOrderIDOrXSID:默认为0,按照软件 选项/排行榜和奖项 的设置 ...

  8. 安卓界面之Viewpager和Tablayout实现滑动界面

    摘要:六部实现选项卡界面 一. 在gradle文件添加以下代码: implementation 'com.android.support:design:28.0.0' 在gradle文件添加以上代码后 ...

  9. android的系统设置界面

    Intent 的 意图: Intent intent = new Inetnt(Setings); Setings:   1. ACTION_ACCESSIBILITY_SETTINGS : // 跳 ...

随机推荐

  1. String关键字

    关于String和new String()见我写的前一篇博客 String和new String()的区别 1.String的"+"运算 a.String str = " ...

  2. hadoop2.7之作业提交详解(下)

    接着作业提交详解(上)继续写:在上一篇(hadoop2.7之作业提交详解(上))中已经讲到了YARNRunner.submitJob() [WordCount.main() -> Job.wai ...

  3. 图数据库 Nebula Graph 的数据模型和系统架构设计

    Nebula Graph:一个开源的分布式图数据库.作为唯一能够存储万亿个带属性的节点和边的在线图数据库,Nebula Graph 不仅能够在高并发场景下满足毫秒级的低时延查询要求,而且能够提供极高的 ...

  4. SpringBoot进阶教程(六十一)intellij idea project下建多个module搭建架构(下)

    在上一篇文章<SpringBoot进阶教程(六十)intellij idea project下建多个module(上)>中,我们已经介绍了在intellij idea中创建project之 ...

  5. shiro 定义realm

    public class UserRealm extends AuthorizingRealm { private UserService userService = new UserServiceI ...

  6. 《Java 8 in Action》Chapter 5:使用流

    流让你从外部迭代转向内部迭代,for循环显示迭代不用再写了,流内部管理对集合数据的迭代.这种处理数据的方式很有用,因为你让Stream API管理如何处理数据.这样Stream API就可以在背后进行 ...

  7. Cat应用告警实战

    1. Cat应用告警实战 1.1. 前言 好像是中间件设计者的通病,文档写的都是面向有一定使用各种中间件经验的人,告警模块中每个参数其实都可以详细解释一下,要不然我们理解起来真的很吃力还容易采坑 1. ...

  8. 一文道尽JavaScript 20年的发展史

      作者介绍:Andrew Montalenti是Parse.ly的CTO, 一个长期的Python爱好者,以及初创公司和其他项目的创始人. 原文链接:https://amontalenti.com/ ...

  9. 自制微信小程序 提示插件 -- noticeUitis.js

    /* noticeMsg.js by: FEer_llx Modify 2016/08/24 */ function weNotice(obj) { this.fadeFlag = true; thi ...

  10. Oracle数据库之六 单行函数

    六.单行函数 6.1.认识单行函数 ​ 函数就是和 Java 语言之中的方法的功能是一样的,都是为了完成某些特定操作的功能支持,而在 Oracle 数据库里面也包含了大量的单行函数,这些函数掌握了以后 ...