Skip to content

Instantly share code, notes, and snippets.

@nabesi777
Last active October 20, 2022 09:29
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save nabesi777/623ab7ba43b468b0f9a90153a1723f93 to your computer and use it in GitHub Desktop.
Save nabesi777/623ab7ba43b468b0f9a90153a1723f93 to your computer and use it in GitHub Desktop.
GUISkin Unity&C#
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