mirror of
https://github.com/bdunderscore/modular-avatar.git
synced 2025-02-01 19:22:55 +08:00
Adding some hooks for xdress benefit
This commit is contained in:
parent
d96ee7a718
commit
441865cd22
@ -49,7 +49,7 @@ namespace net.fushizen.modular_avatar.core.editor
|
||||
|
||||
public AnimatorCombiner()
|
||||
{
|
||||
_combined = Util.CreateContainer();
|
||||
_combined = Util.CreateAnimator();
|
||||
}
|
||||
|
||||
public AnimatorController Finish()
|
||||
@ -67,7 +67,8 @@ namespace net.fushizen.modular_avatar.core.editor
|
||||
{
|
||||
if (acp.type != param.type)
|
||||
{
|
||||
throw new Exception($"Parameter {param.name} has different types in {basePath} and {controller.name}");
|
||||
throw new Exception(
|
||||
$"Parameter {param.name} has different types in {basePath} and {controller.name}");
|
||||
}
|
||||
|
||||
continue;
|
||||
@ -161,7 +162,8 @@ namespace net.fushizen.modular_avatar.core.editor
|
||||
AnimationUtility.SetAnimationClipSettings(newClip, AnimationUtility.GetAnimationClipSettings(clip));
|
||||
|
||||
return newClip;
|
||||
} else if (o is Texture)
|
||||
}
|
||||
else if (o is Texture)
|
||||
{
|
||||
return o;
|
||||
}
|
||||
@ -174,7 +176,7 @@ namespace net.fushizen.modular_avatar.core.editor
|
||||
private T deepClone<T>(T original,
|
||||
Func<Object, Object> visitor,
|
||||
Dictionary<Object, Object> cloneMap = null
|
||||
) where T : Object
|
||||
) where T : Object
|
||||
{
|
||||
if (original == null) return null;
|
||||
|
||||
@ -202,6 +204,7 @@ namespace net.fushizen.modular_avatar.core.editor
|
||||
obj = (T) ctor.Invoke(Array.Empty<object>());
|
||||
EditorUtility.CopySerialized(original, obj);
|
||||
}
|
||||
|
||||
cloneMap[original] = obj;
|
||||
|
||||
AssetDatabase.AddObjectToAsset(obj, _combined);
|
||||
|
@ -23,17 +23,19 @@
|
||||
*/
|
||||
|
||||
using System;
|
||||
using System.Reflection;
|
||||
using UnityEditor;
|
||||
using UnityEngine;
|
||||
using VRC.SDK3.Avatars.Components;
|
||||
using VRC.SDKBase.Editor.BuildPipeline;
|
||||
|
||||
namespace net.fushizen.modular_avatar.core.editor
|
||||
{
|
||||
[InitializeOnLoad]
|
||||
internal class AvatarProcessor : IVRCSDKPreprocessAvatarCallback, IVRCSDKPostprocessAvatarCallback
|
||||
public class AvatarProcessor : IVRCSDKPreprocessAvatarCallback, IVRCSDKPostprocessAvatarCallback
|
||||
{
|
||||
public delegate void AvatarProcessorCallback(GameObject obj);
|
||||
|
||||
public static event AvatarProcessorCallback AfterProcessing;
|
||||
|
||||
static AvatarProcessor()
|
||||
{
|
||||
EditorApplication.playModeStateChanged += OnPlayModeStateChanged;
|
||||
@ -82,6 +84,8 @@ namespace net.fushizen.modular_avatar.core.editor
|
||||
{
|
||||
UnityEngine.Object.DestroyImmediate(component);
|
||||
}
|
||||
|
||||
AfterProcessing?.Invoke(avatarGameObject);
|
||||
}
|
||||
}
|
||||
}
|
@ -24,6 +24,7 @@
|
||||
|
||||
using UnityEditor;
|
||||
using UnityEditor.Animations;
|
||||
using UnityEngine;
|
||||
using VRC.SDKBase.Editor.BuildPipeline;
|
||||
|
||||
namespace net.fushizen.modular_avatar.core.editor
|
||||
@ -31,6 +32,7 @@ namespace net.fushizen.modular_avatar.core.editor
|
||||
internal class CleanupTempAssets : IVRCSDKPostprocessAvatarCallback
|
||||
{
|
||||
public int callbackOrder => 99999;
|
||||
|
||||
public void OnPostprocessAvatar()
|
||||
{
|
||||
Util.DeleteTemporaryAssets();
|
||||
@ -40,28 +42,36 @@ namespace net.fushizen.modular_avatar.core.editor
|
||||
[InitializeOnLoad]
|
||||
public static class Util
|
||||
{
|
||||
internal const string generatedAssetsSubdirectory = "999_Modular_Avatar_Generated";
|
||||
internal const string generatedAssetsPath = "Assets/" + generatedAssetsSubdirectory;
|
||||
private const string generatedAssetsSubdirectory = "999_Modular_Avatar_Generated";
|
||||
private const string generatedAssetsPath = "Assets/" + generatedAssetsSubdirectory;
|
||||
|
||||
static Util()
|
||||
{
|
||||
RuntimeUtil.delayCall = (cb) => EditorApplication.delayCall += cb.Invoke;
|
||||
}
|
||||
|
||||
static internal AnimatorController CreateContainer()
|
||||
public static AnimatorController CreateAnimator(AnimatorController toClone = null)
|
||||
{
|
||||
var container = new AnimatorController();
|
||||
AssetDatabase.CreateAsset(container, GenerateAssetPath());
|
||||
AnimatorController controller;
|
||||
if (toClone != null)
|
||||
{
|
||||
controller = Object.Instantiate(toClone);
|
||||
}
|
||||
else
|
||||
{
|
||||
controller = new AnimatorController();
|
||||
}
|
||||
AssetDatabase.CreateAsset(controller, GenerateAssetPath());
|
||||
|
||||
return container;
|
||||
return controller;
|
||||
}
|
||||
|
||||
internal static string GenerateAssetPath()
|
||||
public static string GenerateAssetPath()
|
||||
{
|
||||
return GetGeneratedAssetsFolder() + "/" + GUID.Generate() + ".asset";
|
||||
}
|
||||
|
||||
internal static string GetGeneratedAssetsFolder()
|
||||
private static string GetGeneratedAssetsFolder()
|
||||
{
|
||||
if (!AssetDatabase.IsValidFolder(generatedAssetsPath))
|
||||
{
|
||||
@ -71,7 +81,7 @@ namespace net.fushizen.modular_avatar.core.editor
|
||||
return generatedAssetsPath;
|
||||
}
|
||||
|
||||
static internal void DeleteTemporaryAssets()
|
||||
internal static void DeleteTemporaryAssets()
|
||||
{
|
||||
EditorApplication.delayCall += () =>
|
||||
{
|
||||
|
Loading…
Reference in New Issue
Block a user