Created
February 2, 2020 16:08
-
-
Save redglasses67/64a85a2d2b914a47c28f3fd8acb4370d to your computer and use it in GitHub Desktop.
SubstanceGraphのカラーパラメーターを5秒おきに変更するスクリプト
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System.Collections; | |
using UnityEngine; | |
using Substance.Game; | |
public class ChangeSubstanceParam : MonoBehaviour | |
{ | |
public SubstanceGraph targetSubGraph; | |
public string inputColorName; | |
public Color color1 = new Color(0.2f, 0.8f, 0.1f, 1.0f); | |
public Color color2 = new Color(0.6f, 0.3f, 0.9f, 1.0f); | |
void Start () | |
{ | |
StartCoroutine("UpdateSubstance"); | |
} | |
public IEnumerator UpdateSubstance() | |
{ | |
while (true) | |
{ | |
if (targetSubGraph == null || targetSubGraph.HasInput(inputColorName) == false) { break; } | |
var currentColor = targetSubGraph.GetInputColor(inputColorName, (int)NativeTypes.UnityInputType.Color); | |
// Debug.Log("currentColor = " + currentColor.r + ", " + currentColor.g + ", " + currentColor.b + ", " + currentColor.a); | |
var setColor = (currentColor == color1) ? color2 : color1; | |
targetSubGraph.SetInputColor(inputColorName, setColor); | |
targetSubGraph.QueueForRender(); | |
Substance.Game.Substance.RenderSubstancesAsync(); | |
yield return new WaitForSeconds(5.0f); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment