- Surround example code with UNITY_EDITOR condition - Change assembly definition to depend on VRC - Improve Example 3: Make it animate a wedge - Improve ExampleManual Placing States: Add zero argument overload
54 lines
2.0 KiB
C#
54 lines
2.0 KiB
C#
#if UNITY_EDITOR
|
|
using UnityEngine;
|
|
using VRC.SDK3.Avatars.Components;
|
|
using UnityEditor;
|
|
using UnityEditor.Animations;
|
|
|
|
namespace AnimatorAsCodeFramework.Examples
|
|
{
|
|
public class GenExampleManual_PlacingStates : MonoBehaviour
|
|
{
|
|
public VRCAvatarDescriptor avatar;
|
|
public AnimatorController assetContainer;
|
|
public string assetKey;
|
|
}
|
|
|
|
[CustomEditor(typeof(GenExampleManual_PlacingStates), true)]
|
|
public class GenExampleManual_PlacingStatesEditor : Editor
|
|
{
|
|
private const string SystemName = "Example Manual - Placing States";
|
|
|
|
public override void OnInspectorGUI()
|
|
{
|
|
AacExample.InspectorTemplate(this, serializedObject, "assetKey", Create, Remove);
|
|
}
|
|
|
|
private void Create()
|
|
{
|
|
var my = (GenExampleManual_PlacingStates) target;
|
|
var aac = AacExample.AnimatorAsCode(SystemName, my.avatar, my.assetContainer, my.assetKey);
|
|
|
|
var fx = aac.CreateMainFxLayer();
|
|
|
|
var init = fx.NewState("Init"); // This is the first state. By default it is at (0, 0)
|
|
var a = fx.NewState("A"); // This will be placed under Init.
|
|
var b = fx.NewState("B"); // This will be placed under A.
|
|
var c = fx.NewState("C").RightOf(a); // This will be placed right of A.
|
|
var d = fx.NewState("D"); // This will be placed under C.
|
|
var e = fx.NewState("E").RightOf(); // This will be placed right of D.
|
|
var alternate = fx.NewState("Alternate").Over(c); // This will be placed over C.
|
|
|
|
// This will be placed relative to Alternate: 2 blocks over, and 1 to the right.
|
|
var reset = fx.NewState("Reset").Shift(alternate, 1, -2);
|
|
}
|
|
|
|
private void Remove()
|
|
{
|
|
var my = (GenExampleManual_PlacingStates) target;
|
|
var aac = AacExample.AnimatorAsCode(SystemName, my.avatar, my.assetContainer, my.assetKey);
|
|
|
|
aac.RemoveAllMainLayers();
|
|
}
|
|
}
|
|
}
|
|
#endif |