5
3

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.

グラデーションをInspectorで作成する[Unity]

Posted at

ParticleのColor Over Liftime等でグラデーションを設定するのに使うツールですが,こちらはMonoBehaviourを継承したクラスでも使うことができます.

スクリーンショット 2018-02-06 23.24.16.png

サンプル Imageの色を変える

gradient.gif

public class GradientTest : MonoBehaviour {

	public Gradient gradient;

	[Range(0, 1)]
	public float time = 0;

	void OnValidate(){
		this.GetComponent<Graphic> ().color = gradient.Evaluate (time);
	}
}

Gradientクラスの変数を宣言することでInspectorに表示されます.
AnimationCurveと同じ様に,Evaluateに0~1の値を渡すことによって色を取得することができます.

GradationMapに使われることが多いようですが,Timelineとかと組み合わせても面白い表現ができるかもしれません.

参考

5
3
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
5
3

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?