Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.Playables;
// A behaviour that is attached to a playable
public class donut_behaviour : PlayableBehaviour
{
Material [] mats;
// Called when the owning graph starts playing
public override void OnGraphStart(Playable playable) {
mats = GameObject.Find("donut").GetComponent<Renderer>().sharedMaterials;
}
// Called when the owning graph stops playing
public override void OnGraphStop(Playable playable) {
}
// Called when the state of the playable is set to Play
public override void OnBehaviourPlay(Playable playable, FrameData info) {
//クリップ開始時に呼ばれる
//いちご風味に色を変更
mats[0].EnableKeyword("_EMISSION");
mats[0].SetColor("_EmissionColor", new Color(0.88f,0.31f,0.41f));
}
// Called when the state of the playable is set to Paused
public override void OnBehaviourPause(Playable playable, FrameData info) {
//クリップ終了時に呼ばれる
//チョコレート風味に色を戻す
mats[0].EnableKeyword("_EMISSION");
mats[0].SetColor("_EmissionColor", new Color(0,0,0));
}
// Called each frame while the state is set to Play
public override void PrepareFrame(Playable playable, FrameData info) {
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment