public class myscript : MonoBehaviour { void Start () { } void Update () { transform.Rotate (1f, 1f, 0.1f); if (Input.GetKeyDown (KeyCode.Space)) { GetComponent<Renderer>().enabled = false; } if (Input.GetKeyUp (KeyCode.Space)) { GetComponent<Renderer>().enabled = true; } } }
color
マテリアルのカラーに関するもの。
Color構造体のインスタンスとして保管されている。
mainTexture
メインテクスチャに関するもの。
マテリアルのインスペクターで「_MainTex」として設定されているもの。
Textureクラスのインスタンスが保管される。
mainTextureOffset
メインテクスチャのオフセットを示すもの。
「Vector2」というクラスのインスタンス。
Vector3の2次元版で、xとyの値だけからなる。
mainTextureScale
メインテクスチャの大きさを示すもの。
Vector2インスタンスで保管されている。
passCount
マテリアルのパスの数を示すもの。
値はint。
主にGLクラスで使用される。
renderQueue
マテリアルのレンダーキューの値。
マテリアルのインスペクターに表示される「Render queue」の値。
int値。
shader
マテリアルで使用するシェーダーを示すもの。
Shaderクラスのインスタンスとして保管される。
shaderKeywords
シェーダーに設定されている来ワード(定数の値)を示すもの。
string配列として保管される。
マテリアルのカラーに関するもの。
Color構造体のインスタンスとして保管されている。
mainTexture
メインテクスチャに関するもの。
マテリアルのインスペクターで「_MainTex」として設定されているもの。
Textureクラスのインスタンスが保管される。
mainTextureOffset
メインテクスチャのオフセットを示すもの。
「Vector2」というクラスのインスタンス。
Vector3の2次元版で、xとyの値だけからなる。
mainTextureScale
メインテクスチャの大きさを示すもの。
Vector2インスタンスで保管されている。
passCount
マテリアルのパスの数を示すもの。
値はint。
主にGLクラスで使用される。
renderQueue
マテリアルのレンダーキューの値。
マテリアルのインスペクターに表示される「Render queue」の値。
int値。
shader
マテリアルで使用するシェーダーを示すもの。
Shaderクラスのインスタンスとして保管される。
shaderKeywords
シェーダーに設定されている来ワード(定数の値)を示すもの。
string配列として保管される。
public class myscript : MonoBehaviour { void Start () { } void Update () { transform.Rotate (1f, 1f, 0.1f); Color c = GetComponent<Renderer>().material.color; if (Input.GetKey (KeyCode.RightArrow)) { c.r += 0.01f; if (c.r > 1.0f) { c.r = 1.0f; } c.b -= -0.01f; if (c.b < 0.0f) { c.b = 0.0f; } GetComponent<Renderer>().material.color = c; } if (Input.GetKey (KeyCode.LeftArrow)) { c.r -= 0.01f; if (c.r < 0.0f) { c.r = 0.0f; } c.b += 0.01f; if (c.b > 1.0f) { c.b = 1.0f; } GetComponent<Renderer>().material.color = c; } } }
Color c = renderer.material.color; // c.r ... 赤の輝度。0.0〜1.0までの実数(float値)で設定されている。 // c.g ... 緑の輝度。0.0〜1.0までの実数(float値)で設定されている。 // c.b ... 青の輝度。0.0〜1.0までの実数(float値)で設定されている。 // c.a ... 透明度 (アルファチャンネル)。0.0〜1.0までの実数(float値)で設定されている。
red ... 赤のColorインスタンス
blue ... 青のColorインスタンス
green ... 緑のColorインスタンス
black ... 黒のColorインスタンス
white ... 白のColorインスタンス
cyan ... シアンのColorインスタンス
magenta ... マゼンタのColorインスタンス
yellow ... 黄色のColorインスタンス
grey (gray) ... グレー(灰色)のColorインスタンス
clear ... RGBAの値すべてをゼロにしたColorインスタンス
blue ... 青のColorインスタンス
green ... 緑のColorインスタンス
black ... 黒のColorインスタンス
white ... 白のColorインスタンス
cyan ... シアンのColorインスタンス
magenta ... マゼンタのColorインスタンス
yellow ... 黄色のColorインスタンス
grey (gray) ... グレー(灰色)のColorインスタンス
clear ... RGBAの値すべてをゼロにしたColorインスタンス
public class myscript : MonoBehaviour { void Start () { GameObject.Find("GUI Text").GetComponent<GUIText>().text = "This is Sample!"; } void Update () { transform.Rotate (1f, 1f, 0.1f); GameObject obj = GameObject.Find ("GUI Text"); Color c = obj.GetComponent<GUIText>().color; if (Input.GetKey (KeyCode.RightArrow)) { c.a += 0.01f; if (c.a > 1.0f) { c.a = 1.0f; } obj.GetComponent<GUIText>().color = c; } if (Input.GetKey (KeyCode.LeftArrow)) { c.a -= 0.01f; if (c.a < 0.0f) { c.a = 0.0f; } obj.GetComponent<GUIText>().color = c; } } }
コメントをかく