Gameplay Ingredients是一组用于 Unity 游戏的运行时和编辑器工具:一组脚本的集合,可在制作游戏和原型时简化简单的任务。
您最多选择25个主题 主题必须以中文或者字母或数字开头,可以包含连字符 (-),并且长度不得超过35个字符

73 行
2.0 KiB

using NaughtyAttributes;
using System;
using UnityEngine;
namespace GameplayIngredients.Rigs
{
public class GenericBindingRig : Rig
{
public enum BindingType
{
Bool,
Int,
UInt,
Float,
Vector2,
Vector3,
Vector4,
Quaternion,
Color
}
[SerializeField]
BindingType bindingType = BindingType.Float;
[InfoBox("Reads the value of SOURCE property and stores it into TARGET property")]
[SerializeField, ReflectedMember("typeForBinding")]
ReflectedMember source;
[SerializeField, ReflectedMember("typeForBinding")]
ReflectedMember target;
Type typeForBinding
{
get
{
switch (bindingType)
{
case BindingType.Bool:
return typeof(bool);
case BindingType.Int:
return typeof(int);
case BindingType.UInt:
return typeof(uint);
case BindingType.Float:
return typeof(float);
case BindingType.Vector2:
return typeof(Vector2);
case BindingType.Vector3:
return typeof(Vector3);
case BindingType.Vector4:
return typeof(Vector4);
case BindingType.Quaternion:
return typeof(Quaternion);
case BindingType.Color:
return typeof(Color);
default:
throw new NotImplementedException();
}
}
}
public override UpdateMode defaultUpdateMode => UpdateMode.Update;
public override int defaultPriority => 0;
public override void UpdateRig(float deltaTime)
{
target.SetValue(source.GetValue());
}
}
}