Skip to content

Instantly share code, notes, and snippets.

@hota1024
Created April 27, 2022 10:53
Show Gist options
  • Save hota1024/56db721020eef2786eea6cb77de1baa5 to your computer and use it in GitHub Desktop.
Save hota1024/56db721020eef2786eea6cb77de1baa5 to your computer and use it in GitHub Desktop.
using System;
using UnityEngine;
using Unity.VisualScripting;
using TMPro;
public class SetTmpText : Unit
{
[DoNotSerialize]
public ControlInput inputTrigger;
[DoNotSerialize]
public ControlOutput outputTrigger;
[DoNotSerialize]
public ValueInput gameObject;
[DoNotSerialize]
public ValueInput text;
protected override void Definition()
{
// 入力の定義。
inputTrigger = ControlInput("", (flow) => {
// 引数を取得。
var obj = flow.GetValue<GameObject>(gameObject);
var value = flow.GetValue<string>(text);
// TextMeshProUGUI を取得。
var tmp = obj.GetComponent<TextMeshProUGUI>();
// テキストを設定。
tmp.text = value;
return outputTrigger;
});
// 出力の定義。
outputTrigger = ControlOutput("");
// 引数の定義。
gameObject = ValueInput<GameObject>("gameObject");
text = ValueInput<string>("text", String.Empty);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment