study/first_study/Library/PackageCache/com.unity.visualscripting@191c0d7e3b69/DocCodeExamples/VariableExamples.cs

26 lines
627 B
C#
Raw Normal View History

using Unity.VisualScripting;
using UnityEngine;
class VariableExamples
{
#region PlayerController
public class PlayerController : MonoBehaviour
{
VariableDeclaration m_Velocity;
void Start()
{
var variables = GetComponent<Variables>();
m_Velocity = variables.declarations.GetDeclaration("velocity");
}
void Update()
{
if (Input.GetKeyDown("space"))
{
var currentVelocity = (float)m_Velocity.value;
m_Velocity.value = currentVelocity * 2f;
}
}
}
#endregion
}