Created
September 22, 2018 09:44
-
-
Save nabesi777/d4e17e9b77f00a7756a898d5611ea13d to your computer and use it in GitHub Desktop.
Unity&C# GUILayoutTUT
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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