Last active
October 20, 2022 09:29
-
-
Save nabesi777/623ab7ba43b468b0f9a90153a1723f93 to your computer and use it in GitHub Desktop.
GUISkin Unity&C#
This file contains 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 Layouttest : MonoBehaviour | |
{ | |
private float sliderValue = 1.0f; | |
private float maxSliderValue = 10.0f; | |
private float spaceSize; // | |
public GUISkin customSkin; //GUISkinを格納 | |
void OnGUI() | |
{ | |
GUI.skin = customSkin; //GUISkinを呼び出し? | |
//GUIのすべてを配置コントロールするエリア表示位置x,y、エリアサイズx,y | |
GUILayout.BeginArea(new Rect(10, 20, 100, 480)); | |
//水平グループ | |
GUILayout.BeginHorizontal(); | |
//垂直グループ | |
GUILayout.BeginVertical(); | |
//ボタンを置く | |
if (GUILayout.RepeatButton("アイテム")) | |
{ | |
maxSliderValue += 3.0f * Time.deltaTime; | |
} | |
GUILayout.Space(20); | |
//ボタンを置く | |
if (GUILayout.RepeatButton("マップ")) | |
{ | |
maxSliderValue += 3.0f * Time.deltaTime; | |
} | |
GUILayout.Space(20); | |
//ボタンを置く | |
if (GUILayout.RepeatButton("セーブ")) | |
{ | |
maxSliderValue += 3.0f * Time.deltaTime; | |
} | |
GUILayout.Space(20); | |
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