Skip to content

Instantly share code, notes, and snippets.

@nabesi777
Created September 16, 2018 02:22
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/060deddf3a359b75c0510133864c287b to your computer and use it in GitHub Desktop.
Save nabesi777/060deddf3a359b75c0510133864c287b to your computer and use it in GitHub Desktop.
NumberDisplay_2 C# unity
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class GUIButtonTUT : MonoBehaviour
{
public TextMesh textMesh; //3DTextを格納
public Texture2D button; //buttonイメージを格納
public GameObject spider; //蜘蛛オブジェクトを格納
private bool spiderOn = false; //spiderOnはfalse
// Use this for initialization
void Start()
{
}
// Update is called once per frame
void Update()
{
}
void OnGUI()
{//ボタンの位置とサイズ、ボタンへDisplay 10と表示させる
if (GUI.Button(new Rect(10, 70, 100, 20), "display:10"))
{//textを10と表示する
textMesh.text = "10";
}
//ボタンの位置とサイズ、ボタンへDisplay 5と表示させる
if (GUI.Button(new Rect(10, 95, 100, 20), "display:5"))
{//textを5と表示する
textMesh.text = "5";
}
if (GUI.Button(new Rect(10, 120, 100, 20), "Spider Button"))
{//spiderOnの真偽でオブジェクトの表示の切り替え
if (spiderOn == false)
{
spider.SetActive(true);
spiderOn = true;
}
else
{
spider.SetActive(false);
spiderOn = false;
}
}
}
}mbe
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment