言語: 日本語
  • C#
  • JS
  • Boo

スクリプト言語

お好みのスクリプト言語を選択すると、サンプルコードがその言語で表示されます。

Shader.Find

Suggest a change

Success!

Thank you for helping us improve the quality of Unity Documentation. Although we cannot accept all submissions, we do read each suggested change from our users and will make updates where applicable.

Close

Sumbission failed

For some reason your suggested change could not be submitted. Please try again in a few minutes. And thank you for taking the time to help us improve the quality of Unity Documentation.

Close

Cancel

public static function Find(name: string): Shader;
public static Shader Find(string name);
public static def Find(name as string) as Shader

Description

名前からシェーダーを検索します

Shader.Find can be used to switch to another shader without having to keep a reference to the shader. /name/ is the name you can see in the shader popup of any material. Common names are: "Diffuse", "Bumped Diffuse", "VertexLit", "Transparent/Diffuse" etc. When building a player, a shader will only be included if it is assigned to a material that is used in any scene or if the shader is placed in a "Resources" folder. See Also: Material クラス

	// Switch the shader from code

	function Start () {
		// Switch to the transparent diffuse shader
		renderer.material.shader = Shader.Find ("Transparent/Diffuse");
	}
using UnityEngine;
using System.Collections;

public class ExampleClass : MonoBehaviour {
    void Start() {
        renderer.material.shader = Shader.Find("Transparent/Diffuse");
    }
}
import UnityEngine
import System.Collections

public class ExampleClass(MonoBehaviour):

	def Start() as void:
		renderer.material.shader = Shader.Find('Transparent/Diffuse')

他の例:

	// Create a material from code

	function Start () {
		// Create a material with transparent diffuse shader
		var material = new Material (Shader.Find ("Transparent/Diffuse"));
		material.color = Color.green;
		// assign the material to the renderer
		renderer.material = material;
	}
using UnityEngine;
using System.Collections;

public class ExampleClass : MonoBehaviour {
    void Start() {
        Material material = new Material(Shader.Find("Transparent/Diffuse"));
        material.color = Color.green;
        renderer.material = material;
    }
}
import UnityEngine
import System.Collections

public class ExampleClass(MonoBehaviour):

	def Start() as void:
		material as Material = Material(Shader.Find('Transparent/Diffuse'))
		material.color = Color.green
		renderer.material = material