-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
4 changed files
with
80 additions
and
15 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.IO; | ||
using System.Linq; | ||
using com.github.pandrabox.emoteprefab.editor; | ||
using com.github.pandrabox.emoteprefab.runtime; | ||
using nadena.dev.modular_avatar.core; | ||
using nadena.dev.modular_avatar.core.editor; | ||
using nadena.dev.ndmf; | ||
using UnityEditor; | ||
using UnityEditor.Animations; | ||
using UnityEngine; | ||
using VRC.SDK3.Avatars.Components; | ||
using VRC.SDK3.Dynamics.PhysBone.Components; | ||
using static com.github.pandrabox.emoteprefab.runtime.Generic; | ||
using static com.github.pandrabox.emoteprefab.editor.EmoteManager; | ||
|
||
namespace com.github.pandrabox.emoteprefab.editor | ||
{ | ||
public static class RelativeResolver | ||
{ | ||
public enum ResolveMode | ||
{ | ||
Absolute, | ||
AutoByRelative, | ||
AutoByAbsolute | ||
} | ||
public static AnimationClip RelativeResolve(Transform Root, AnimationClip Original, ResolveMode mode) | ||
{ | ||
var original = UnityEngine.Object.Instantiate(Original); | ||
var clip = UnityEngine.Object.Instantiate(Original); | ||
if (mode == ResolveMode.Absolute) return original; | ||
var RootPath = FindPathRecursive(Descriptor.transform, Root); | ||
|
||
// CleanUp | ||
foreach (var binding in AnimationUtility.GetCurveBindings(clip)) | ||
{ | ||
AnimationUtility.SetEditorCurve(clip, binding, null); | ||
} | ||
|
||
// Create ResolvedAnim | ||
foreach (var binding in AnimationUtility.GetCurveBindings(original)) | ||
{ | ||
AnimationCurve curve = AnimationUtility.GetEditorCurve(original, binding); | ||
var path = binding.path; | ||
if (Root.Find(path) && path.Length > 0) | ||
{ | ||
path = $@"{RootPath}/{path}"; | ||
} | ||
clip.SetCurve(path, binding.type, binding.propertyName, curve); | ||
} | ||
|
||
return clip; | ||
} | ||
} | ||
} |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters