Skip to content

Instantly share code, notes, and snippets.

@flushpot1125
Last active January 28, 2018 02:53
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save flushpot1125/9c95c0aab120cb0c89acffde882cc9aa to your computer and use it in GitHub Desktop.
Save flushpot1125/9c95c0aab120cb0c89acffde882cc9aa to your computer and use it in GitHub Desktop.
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