Skip to content

Commit

Permalink
wip
Browse files Browse the repository at this point in the history
  • Loading branch information
bdunderscore committed Nov 17, 2024
1 parent e1cfb4f commit 9dea510
Show file tree
Hide file tree
Showing 2 changed files with 44 additions and 5 deletions.
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using System.Collections.Generic;
using System;
using System.Collections.Generic;
using UnityEngine;

namespace nadena.dev.ndmf.animator
Expand All @@ -10,21 +11,56 @@ public interface IPlatformAnimatorBindings
/// </summary>
/// <param name="m"></param>
/// <returns></returns>
bool IsSpecialMotion(Motion m);
bool IsSpecialMotion(Motion m)
{
return false;
}

/// <summary>
/// Returns any animator controllers that are referenced by platform-specific assets (e.g. VRCAvatarDescriptor).
/// The bool flag indicates whether the controller is overridden (true) or left as default (false).
/// </summary>
/// <param name="root"></param>
/// <returns></returns>
IEnumerable<(object, RuntimeAnimatorController, bool)> GetInnateControllers(GameObject root);
IEnumerable<(object, RuntimeAnimatorController, bool)> GetInnateControllers(GameObject root)
{
return Array.Empty<(object, RuntimeAnimatorController, bool)>();
}

/// <summary>
/// Updates any innate controllers to reference new animator controllers.
/// </summary>
/// <param name="root"></param>
/// <param name="controllers"></param>
void CommitInnateControllers(GameObject root, IDictionary<object, RuntimeAnimatorController> controllers);
void CommitInnateControllers(GameObject root, IDictionary<object, RuntimeAnimatorController> controllers)
{

}

/// <summary>
/// Invoked after a StateMachineBehavior is cloned, to allow for any platform-specific modifications.
/// For example, in VRChat, this is used to replace the layer indexes with virtual layer indexes in the
/// VRChatAnimatorLayerControl behavior.
///
/// Note that, if we're re-activating the virtual animator controller after committing, this will be re-invoked
/// with the same behaviour it had previously cloned. This allows for again converting between virtual and
/// physical layer indexes.
/// </summary>
/// <param name="context"></param>
/// <param name="behaviour"></param>
void VirtualizeStateBehaviour(CloneContext context, StateMachineBehaviour behaviour)
{
}

/// <summary>
/// Invoked when a StateMachineBehavior is being committed, to allow for any platform-specific modifications.
/// For example, in VRChat, this is used to replace the virtual layer indexes with the actual layer indexes in the
/// VRChatAnimatorLayerControl behavior.
/// </summary>
/// <param name="context"></param>
/// <param name="behaviour"></param>
void CommitStateBehaviour(CloneContext context, StateMachineBehaviour behaviour)
{
}
}
}
5 changes: 4 additions & 1 deletion Editor/API/AnimatorServices/VirtualObjects/VirtualClip.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
using JetBrains.Annotations;
using UnityEditor;
using UnityEngine;
using Debug = System.Diagnostics.Debug;
using Object = UnityEngine.Object;

namespace nadena.dev.ndmf.animator
Expand Down Expand Up @@ -156,7 +157,9 @@ AnimationClip clip
return FromMarker(clip);
}

if (cloneContext?.TryGetValue(clip, out VirtualClip clonedClip) == true)
// workaround Rider warning bug
VirtualClip clonedClip = null;
if (cloneContext?.TryGetValue(clip, out clonedClip) == true)
{
return clonedClip;
}
Expand Down

0 comments on commit 9dea510

Please sign in to comment.