Skip to content

Instantly share code, notes, and snippets.

@nabesi777
Created September 22, 2018 09:44
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save nabesi777/d4e17e9b77f00a7756a898d5611ea13d to your computer and use it in GitHub Desktop.
Save nabesi777/d4e17e9b77f00a7756a898d5611ea13d to your computer and use it in GitHub Desktop.
Unity&C# GUILayoutTUT
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class GUILayoutTUT : MonoBehaviour
{
private float sliderValue = 1.0f;
private float maxSliderValue = 10.0f;
void OnGUI()
{//GUIのすべてを配置コントロールするエリア表示位置x,y、エリアサイズx,y 
GUILayout.BeginArea(new Rect(0, 0, 200, 60));
//水平グループ
GUILayout.BeginHorizontal();
//ボタンを置く
if (GUILayout.RepeatButton("Increase max\nSlider Value"))
{
maxSliderValue += 3.0f * Time.deltaTime;
}
//垂直にボタンを増やす
GUILayout.BeginVertical();
GUILayout.Box("Slider Value:" + Mathf.Round(sliderValue));
sliderValue = GUILayout.HorizontalSlider(sliderValue, 0.0f, maxSliderValue);
//エリアの終わり
GUILayout.EndVertical();
GUILayout.EndHorizontal();
GUILayout.EndArea();
}
// 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