Skip to content

Instantly share code, notes, and snippets.

@nabesi777
Created September 20, 2018 04:19
Show Gist options
  • Save nabesi777/a3d645366b3f8b98ea09bf9822d352ff to your computer and use it in GitHub Desktop.
Save nabesi777/a3d645366b3f8b98ea09bf9822d352ff to your computer and use it in GitHub Desktop.
ScrollBar Unity&C#
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class ScrollTut : MonoBehaviour {
private float hScrollbarValue;
public Vector2 scrollPosition = Vector2.zero;
private string innerText = "Found me!";
void OnGUI()
{ //水平スクロールバーの位置x,y、サイズx,y
hScrollbarValue = GUI.HorizontalScrollbar(new Rect(100, 300, 100, 30), hScrollbarValue, 1.0f, 0.0f, 10.0f); //Sliderの中にあるつまみ部分のサイズ、始まり値、終わり値、
//テキストの周りのスクロールバーの位置x,y、サイズx,y
scrollPosition = GUI.BeginScrollView(new Rect(100, 320, 150, 150), scrollPosition, new Rect(0, 0, 220, 220)); //スクロール始まり(位置)x,y、スクロール最大値x,y
//中に記入できるテキストBoxの位置x,y、サイズx,y、
innerText = GUI.TextArea(new Rect(0, 0, 200, 200), innerText);
GUI.EndScrollView();
}
// Use this for initialization
void Start () {
}
// Update is called once per frame
void Update () {
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment