mirror of
https://github.com/bdunderscore/modular-avatar.git
synced 2025-01-04 13:45:04 +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
|
public static class Util
|
||||||
{
|
{
|
||||||
internal const string generatedAssetsSubdirectory = "999_Modular_Avatar_Generated";
|
internal const string generatedAssetsSubdirectory = "999_Modular_Avatar_Generated";
|
||||||
internal const string generatedAssetsPath = "Assets/" + generatedAssetsSubdirectory;
|
internal const string generatedAssetsPath = "Assets/" + generatedAssetsSubdirectory;
|
||||||
|
|
||||||
|
static Util()
|
||||||
|
{
|
||||||
|
RuntimeUtil.delayCall = (cb) => EditorApplication.delayCall += cb.Invoke;
|
||||||
|
}
|
||||||
|
|
||||||
static internal AnimatorController CreateContainer()
|
static internal AnimatorController CreateContainer()
|
||||||
{
|
{
|
||||||
var container = new AnimatorController();
|
var container = new AnimatorController();
|
||||||
@ -74,7 +80,7 @@ namespace net.fushizen.modular_avatar.core.editor
|
|||||||
var subdir = generatedAssetsPath;
|
var subdir = generatedAssetsPath;
|
||||||
|
|
||||||
AssetDatabase.DeleteAsset(subdir);
|
AssetDatabase.DeleteAsset(subdir);
|
||||||
//FileUtil.DeleteFileOrDirectory(subdir);
|
FileUtil.DeleteFileOrDirectory(subdir);
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -23,9 +23,6 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
using System;
|
using System;
|
||||||
#if UNITY_EDITOR
|
|
||||||
using UnityEditor;
|
|
||||||
#endif
|
|
||||||
using UnityEngine;
|
using UnityEngine;
|
||||||
|
|
||||||
namespace net.fushizen.modular_avatar.core
|
namespace net.fushizen.modular_avatar.core
|
||||||
@ -40,10 +37,9 @@ namespace net.fushizen.modular_avatar.core
|
|||||||
public bool locked;
|
public bool locked;
|
||||||
|
|
||||||
private bool wasLocked;
|
private bool wasLocked;
|
||||||
#if UNITY_EDITOR
|
|
||||||
void OnValidate()
|
void OnValidate()
|
||||||
{
|
{
|
||||||
EditorApplication.delayCall += () =>
|
RuntimeUtil.delayCall(() =>
|
||||||
{
|
{
|
||||||
if (this == null) return;
|
if (this == null) return;
|
||||||
if (mergeTarget == null && !string.IsNullOrWhiteSpace(mergeTargetPath))
|
if (mergeTarget == null && !string.IsNullOrWhiteSpace(mergeTargetPath))
|
||||||
@ -53,7 +49,9 @@ namespace net.fushizen.modular_avatar.core
|
|||||||
{
|
{
|
||||||
mergeTarget = avatar.transform.Find(mergeTargetPath)?.gameObject;
|
mergeTarget = avatar.transform.Find(mergeTargetPath)?.gameObject;
|
||||||
}
|
}
|
||||||
if (mergeTarget != null) {
|
|
||||||
|
if (mergeTarget != null)
|
||||||
|
{
|
||||||
RuntimeUtil.MarkDirty(this);
|
RuntimeUtil.MarkDirty(this);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -69,9 +67,8 @@ namespace net.fushizen.modular_avatar.core
|
|||||||
}
|
}
|
||||||
|
|
||||||
CheckLock();
|
CheckLock();
|
||||||
};
|
});
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
|
|
||||||
void CheckLock()
|
void CheckLock()
|
||||||
{
|
{
|
||||||
@ -94,11 +91,23 @@ namespace net.fushizen.modular_avatar.core
|
|||||||
foreach (var xform in GetComponentsInChildren<Transform>(true))
|
foreach (var xform in GetComponentsInChildren<Transform>(true))
|
||||||
{
|
{
|
||||||
Transform baseObject = FindCorresponding(xform);
|
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>();
|
if (marker != null)
|
||||||
comp.correspondingObject = baseObject;
|
{
|
||||||
comp.lockBasePosition = baseObject.gameObject == mergeTarget;
|
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 static class RuntimeUtil
|
||||||
{
|
{
|
||||||
|
public delegate void NullCallback();
|
||||||
|
|
||||||
|
// Initialized in Util
|
||||||
|
public static Action<NullCallback> delayCall = (_) => { };
|
||||||
|
|
||||||
[CanBeNull]
|
[CanBeNull]
|
||||||
public static string RelativePath(GameObject root, GameObject child)
|
public static string RelativePath(GameObject root, GameObject child)
|
||||||
{
|
{
|
||||||
|
Loading…
Reference in New Issue
Block a user