2
2

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

[Unity]自作ShaderのMaterialに値を代入する方法

Posted at

#方法

material.SetFloat(name, float);

これでできる。ほかの型でも同様に可能。
詳しくはここを参照。
#コードの例

using UnityEngine;
using System.Collections;

[ExecuteInEditMode]
public class ShaderScript : MonoBehaviour {
	public Material mat;
	public string name;
	public float floa;
	// Use this for initialization
	void Start () {
	
	}
	
	// Update is called once per frame
	void Update () {
		mat.SetFloat(name, floa);
	}
}

publicの変数の値を毎フレームマテリアルに設定するだけのコードです。

2
2
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
2
2

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?