游戏 scrollView

Unity中使用GUI实现滚动视图
本文介绍了一个简单的Unity脚本,用于实现GUI滚动视图功能。通过修改初始滚动位置,并利用Unity内置的GUI.BeginScrollView方法来创建一个可以滚动的内容区域。此脚本适用于希望在Unity项目中快速实现基本滚动视图功能的开发者。
using UnityEngine;
using System.Collections;

public class LLL : MonoBehaviour {

    Vector2 scrollPosition;

    // Use this for initialization
    void Start () {
        scrollPosition [0] = 50;
        scrollPosition [1] = 50;
    }
    
    // Update is called once per frame
    void Update () {
    
    }

    void OnGUI()
    {
        scrollPosition = GUI.BeginScrollView (new Rect (0, 0, 200, 200), scrollPosition, new Rect (0, 0, Screen.width, 300), true, true);

        GUI.Label (new Rect (100, 40, Screen.width, 30), "测试滚动试图,测试滚动试图,测试滚动试图,测试滚动试图。");

        GUI.EndScrollView ();
    }
}

 

转载于:https://www.cnblogs.com/yufenghou/p/3537912.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值