mirror of
https://github.com/bdunderscore/modular-avatar.git
synced 2024-12-29 18:55:06 +08:00
Restore Merge Armature locked mode references on prefab instantiation
This commit is contained in:
parent
b889bc7323
commit
5c0b62f295
@ -37,11 +37,17 @@ 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;
|
||||
|
||||
static Util()
|
||||
{
|
||||
RuntimeUtil.delayCall = (cb) => EditorApplication.delayCall += cb.Invoke;
|
||||
}
|
||||
|
||||
static internal AnimatorController CreateContainer()
|
||||
{
|
||||
var container = new AnimatorController();
|
||||
@ -74,7 +80,7 @@ namespace net.fushizen.modular_avatar.core.editor
|
||||
var subdir = generatedAssetsPath;
|
||||
|
||||
AssetDatabase.DeleteAsset(subdir);
|
||||
//FileUtil.DeleteFileOrDirectory(subdir);
|
||||
FileUtil.DeleteFileOrDirectory(subdir);
|
||||
};
|
||||
}
|
||||
}
|
||||
|
@ -23,9 +23,6 @@
|
||||
*/
|
||||
|
||||
using System;
|
||||
#if UNITY_EDITOR
|
||||
using UnityEditor;
|
||||
#endif
|
||||
using UnityEngine;
|
||||
|
||||
namespace net.fushizen.modular_avatar.core
|
||||
@ -40,10 +37,9 @@ namespace net.fushizen.modular_avatar.core
|
||||
public bool locked;
|
||||
|
||||
private bool wasLocked;
|
||||
#if UNITY_EDITOR
|
||||
void OnValidate()
|
||||
{
|
||||
EditorApplication.delayCall += () =>
|
||||
RuntimeUtil.delayCall(() =>
|
||||
{
|
||||
if (this == null) return;
|
||||
if (mergeTarget == null && !string.IsNullOrWhiteSpace(mergeTargetPath))
|
||||
@ -53,7 +49,9 @@ namespace net.fushizen.modular_avatar.core
|
||||
{
|
||||
mergeTarget = avatar.transform.Find(mergeTargetPath)?.gameObject;
|
||||
}
|
||||
if (mergeTarget != null) {
|
||||
|
||||
if (mergeTarget != null)
|
||||
{
|
||||
RuntimeUtil.MarkDirty(this);
|
||||
}
|
||||
}
|
||||
@ -69,9 +67,8 @@ namespace net.fushizen.modular_avatar.core
|
||||
}
|
||||
|
||||
CheckLock();
|
||||
};
|
||||
});
|
||||
}
|
||||
#endif
|
||||
|
||||
void CheckLock()
|
||||
{
|
||||
@ -94,11 +91,23 @@ namespace net.fushizen.modular_avatar.core
|
||||
foreach (var xform in GetComponentsInChildren<Transform>(true))
|
||||
{
|
||||
Transform baseObject = FindCorresponding(xform);
|
||||
if (baseObject != null && xform.gameObject.GetComponent<MAInternalOffsetMarker>() == null)
|
||||
var marker = xform.gameObject.GetComponent<MAInternalOffsetMarker>();
|
||||
|
||||
if (baseObject == null)
|
||||
{
|
||||
var comp = xform.gameObject.AddComponent<MAInternalOffsetMarker>();
|
||||
comp.correspondingObject = baseObject;
|
||||
comp.lockBasePosition = baseObject.gameObject == mergeTarget;
|
||||
if (marker != null)
|
||||
{
|
||||
DestroyImmediate(marker);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (marker == null)
|
||||
{
|
||||
marker = xform.gameObject.AddComponent<MAInternalOffsetMarker>();
|
||||
}
|
||||
marker.correspondingObject = baseObject;
|
||||
marker.lockBasePosition = baseObject.gameObject == mergeTarget;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -33,6 +33,11 @@ namespace net.fushizen.modular_avatar.core
|
||||
{
|
||||
public static class RuntimeUtil
|
||||
{
|
||||
public delegate void NullCallback();
|
||||
|
||||
// Initialized in Util
|
||||
public static Action<NullCallback> delayCall = (_) => { };
|
||||
|
||||
[CanBeNull]
|
||||
public static string RelativePath(GameObject root, GameObject child)
|
||||
{
|
||||
|
Loading…
Reference in New Issue
Block a user