CustomAssets
Askowl Custom Assets
AnimatorCustomAssetConnector.cs
1 // Copyright 2018 (C) paul@marrington.net http://www.askowl.net/unity-packages
2 
3 using UnityEditor;
4 using UnityEngine;
5 
6 namespace CustomAsset.Mutable {
7  /// <a href="http://bit.ly/2RhNC0Z">Drive an animation directly from data custom assets</a>
8  public class AnimatorCustomAssetConnector : MonoBehaviour {
9  /// <a href="http://bit.ly/2RhNC0Z">for <see cref="NamedTriggerDriver"/></a>
10  public void SetTrigger(string parameterName) => animator.SetTrigger(parameterName);
11 
12  /// <a href="http://bit.ly/2RhNC0Z"><see cref="NamedIntegerDriver"/></a>
13  public void SetInteger(string parameterName, int value) => animator.SetInteger(parameterName, value);
14 
15  /// <a href="http://bit.ly/2RhNC0Z"><see cref="NamedFloatDriver"/></a>
16  public void SetFloat(string parameterName, float value) => animator.SetFloat(parameterName, value);
17 
18  /// <a href="http://bit.ly/2RhNC0Z"><see cref="NamedBooleanDriver"/></a>
19  public void SetBoolean(string parameterName, bool value) => animator.SetBool(parameterName, value);
20 
21  private Animator animator;
22 
23  private void Awake() => animator = GetComponent<Animator>();
24 
25  #if UNITY_EDITOR
26  [MenuItem("Component/CustomAssets/Animator Connector")]
27  private static void AddConnector() =>
28  Selection.activeTransform.gameObject.AddComponent<AnimatorCustomAssetConnector>();
29  #endif
30  }
31 }
Drive an animation directly from data custom assets
void SetTrigger(string parameterName)
for