ugh
This commit is contained in:
parent
6031db6620
commit
4809e7cfa0
17 changed files with 276 additions and 159 deletions
51
PlatformSpecificFX/Editor/PlatformSpecificFXPlugin.cs
Normal file
51
PlatformSpecificFX/Editor/PlatformSpecificFXPlugin.cs
Normal file
|
|
@ -0,0 +1,51 @@
|
|||
using System;
|
||||
using System.Linq;
|
||||
using gay.lilyy.platformspecificfx;
|
||||
using nadena.dev.ndmf;
|
||||
using nadena.dev.ndmf.vrchat;
|
||||
using UnityEditor;
|
||||
using UnityEngine;
|
||||
using VRC.SDK3.Avatars.Components;
|
||||
|
||||
[assembly: ExportsPlugin(typeof(PlatformSpecificFXPlugin))]
|
||||
|
||||
namespace gay.lilyy.platformspecificfx
|
||||
{
|
||||
public class PlatformSpecificFXPlugin : Plugin<PlatformSpecificFXPlugin>
|
||||
{
|
||||
public override string DisplayName => "Platform Specific FX";
|
||||
public override string QualifiedName => "gay.lilyy.platformspecificfx";
|
||||
|
||||
protected override void Configure()
|
||||
{
|
||||
InPhase(BuildPhase.FirstChance).Run("PlatformSpecificFX", ctx =>
|
||||
{
|
||||
var configs = ctx.AvatarRootObject.GetComponentsInChildren<PlatformSpecificFX>(true);
|
||||
if (configs == null || configs.Length == 0)
|
||||
return;
|
||||
|
||||
var targetAnimator = EditorUserBuildSettings.activeBuildTarget == BuildTarget.StandaloneWindows
|
||||
|| EditorUserBuildSettings.activeBuildTarget == BuildTarget.StandaloneWindows64 ?
|
||||
configs[0].desktop : configs[0].mobile;
|
||||
if (targetAnimator == null) throw new Exception("Target animator not found");
|
||||
|
||||
var baseAnimationLayers = ctx.VRChatAvatarDescriptor().baseAnimationLayers.ToList();
|
||||
// replace the fx layer with the target animator
|
||||
var foundFXLayer = false;
|
||||
for (int i = 0; i < baseAnimationLayers.Count; i++)
|
||||
{
|
||||
var layer = baseAnimationLayers[i];
|
||||
if (layer.type == VRCAvatarDescriptor.AnimLayerType.FX) {
|
||||
Debug.Log($"Found FX Layer, Replacing with {targetAnimator.name}");
|
||||
layer.animatorController = targetAnimator;
|
||||
baseAnimationLayers[i] = layer;
|
||||
foundFXLayer = true;
|
||||
}
|
||||
}
|
||||
if (!foundFXLayer) throw new Exception("FX Layer not found");
|
||||
ctx.VRChatAvatarDescriptor().baseAnimationLayers = baseAnimationLayers.ToArray();
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Loading…
Add table
Add a link
Reference in a new issue