浏览代码

Added Generic Binding Rig

/feature-generic-animation-rigs
Thomas ICHÉ 4 年前
当前提交
8b72e2ee
共有 3 个文件被更改,包括 64 次插入1 次删除
  1. 2
      Editor/PropertyDrawers/ReflectedMemberyPropertyDrawer.cs
  2. 52
      Runtime/Ingredients/Rigs/GenericAnimation/GenericBindingRig.cs
  3. 11
      Runtime/Ingredients/Rigs/GenericAnimation/GenericBindingRig.cs.meta

2
Editor/PropertyDrawers/ReflectedMemberyPropertyDrawer.cs


float width = EditorGUIUtility.currentViewWidth;
var filterType = typeof(object);
var p = property.serializedObject.targetObject.GetType().GetMember(property.name, BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Instance | BindingFlags.GetProperty | BindingFlags.GetField).First();
var p = property.serializedObject.targetObject.GetType().GetMember(property.name, BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Instance | BindingFlags.GetProperty | BindingFlags.GetField | BindingFlags.FlattenHierarchy).First();
var attr = p.GetCustomAttribute<ReflectedMemberAttribute>();
if (attr != null) // If using a ReflectedMemberAttribute for filtering type

52
Runtime/Ingredients/Rigs/GenericAnimation/GenericBindingRig.cs


using NaughtyAttributes;
using System;
using UnityEngine;
namespace GameplayIngredients.Rigs
{
public class GenericBindingRig : Rig
{
public enum BindingType
{
Float,
Vector3
}
[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.Float:
return typeof(float);
case BindingType.Vector3:
return typeof(Vector3);
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());
}
}
}

11
Runtime/Ingredients/Rigs/GenericAnimation/GenericBindingRig.cs.meta


fileFormatVersion: 2
guid: d544ada91e4229b4aa7b7d1f01f7110d
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
正在加载...
取消
保存