Created
November 15, 2017 13:28
-
-
Save bibinba/91b1c79d2c1407e7b50894acf30302b8 to your computer and use it in GitHub Desktop.
キー入力でテキストや画像を変更したり、マテリアルの色を変えたりする。
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.Generic; | |
using UnityEngine; | |
using UnityEngine.UI; | |
public class key : MonoBehaviour { | |
public GameObject spoon; | |
public GameObject kagi; | |
public GameObject hasami; | |
public Text text; | |
public Image image; | |
public Sprite cock; | |
public Sprite kagisi; | |
public Sprite designer; | |
public GameObject one; | |
public GameObject two; | |
public GameObject three; | |
// Use this for initialization | |
void Start () { | |
//GetComponent<Renderer> | |
} | |
// Update is called once per frame | |
void Update () { | |
if (Input.GetKey (KeyCode.Space)) { | |
three.GetComponent<Renderer> ().material.color = Color.red; | |
text.text = "料理家"; | |
image.sprite = cock; | |
} | |
else if(Input.GetKeyUp(KeyCode.Space)){ | |
three.GetComponent<Renderer>().material.color = Color.white; | |
} | |
if(Input.GetKeyDown(KeyCode.LeftArrow)){ | |
//kagi.GetComponent<Renderer>().material.shader = Shader.Find( "Custom/OutlineSurfaceShader" ); | |
one.GetComponent<Renderer>().material.color = Color.red; | |
text.text = "解錠師"; | |
image.sprite = kagisi; | |
} | |
else if(Input.GetKeyUp(KeyCode.LeftArrow)){ | |
one.GetComponent<Renderer>().material.color = Color.white; | |
} | |
if(Input.GetKeyDown(KeyCode.RightArrow)){ | |
//hasami.GetComponent<Renderer>().material.shader = Shader.Find( "Custom/OutlineSurfaceShader" ); | |
two.GetComponent<Renderer>().material.color = Color.red; | |
text.text = "デザイナー"; | |
image.sprite = designer; | |
} | |
else if(Input.GetKeyUp(KeyCode.RightArrow)){ | |
two.GetComponent<Renderer>().material.color = Color.white; | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment