chore: fix non-editor buil

This commit is contained in:
bd_ 2024-11-24 18:20:09 -08:00
parent 8adc0dd1c6
commit 679fbf51c0
2 changed files with 16 additions and 3 deletions

View File

@ -4,9 +4,11 @@ using Unity.Burst;
using Unity.Collections; using Unity.Collections;
using Unity.Collections.LowLevel.Unsafe; using Unity.Collections.LowLevel.Unsafe;
using Unity.Jobs; using Unity.Jobs;
using UnityEditor;
using UnityEngine; using UnityEngine;
using UnityEngine.Jobs; using UnityEngine.Jobs;
#if UNITY_EDITOR
using UnityEditor;
#endif
namespace nadena.dev.modular_avatar.core.armature_lock namespace nadena.dev.modular_avatar.core.armature_lock
{ {
@ -32,8 +34,9 @@ namespace nadena.dev.modular_avatar.core.armature_lock
_anyDirty = new NativeArray<bool>(1, Allocator.Persistent); _anyDirty = new NativeArray<bool>(1, Allocator.Persistent);
_nativeMemoryManager.OnSegmentMove += MoveTransforms; _nativeMemoryManager.OnSegmentMove += MoveTransforms;
#if UNITY_EDITOR
AssemblyReloadEvents.beforeAssemblyReload += OnDomainUnload; AssemblyReloadEvents.beforeAssemblyReload += OnDomainUnload;
#endif
} }
private void OnDomainUnload() private void OnDomainUnload()
@ -45,7 +48,9 @@ namespace nadena.dev.modular_avatar.core.armature_lock
{ {
_lastJob.Complete(); _lastJob.Complete();
#if UNITY_EDITOR
AssemblyReloadEvents.beforeAssemblyReload -= OnDomainUnload; AssemblyReloadEvents.beforeAssemblyReload -= OnDomainUnload;
#endif
if (_virtualParents.isCreated) DeferDestroy.DeferDestroyObj(_virtualParents); if (_virtualParents.isCreated) DeferDestroy.DeferDestroyObj(_virtualParents);
if (_trueParents.isCreated) DeferDestroy.DeferDestroyObj(_trueParents); if (_trueParents.isCreated) DeferDestroy.DeferDestroyObj(_trueParents);
@ -257,7 +262,9 @@ namespace nadena.dev.modular_avatar.core.armature_lock
{ {
if (_mappingStates[i].RequestWriteback) if (_mappingStates[i].RequestWriteback)
{ {
#if UNITY_EDITOR
Undo.RecordObject(_targets[i], "Move Independently"); Undo.RecordObject(_targets[i], "Move Independently");
#endif
prefabRecord.Add(_targets[i]); prefabRecord.Add(_targets[i]);
} }
} }
@ -281,7 +288,9 @@ namespace nadena.dev.modular_avatar.core.armature_lock
{ {
foreach (var transform in prefabRecord) foreach (var transform in prefabRecord)
{ {
#if UNITY_EDITOR
PrefabUtility.RecordPrefabInstancePropertyModifications(transform); PrefabUtility.RecordPrefabInstancePropertyModifications(transform);
#endif
} }
} }

View File

@ -1,7 +1,9 @@
using System; using System;
using nadena.dev.modular_avatar.core.armature_lock; using nadena.dev.modular_avatar.core.armature_lock;
using UnityEditor;
using UnityEngine; using UnityEngine;
#if UNITY_EDITOR
using UnityEditor;
#endif
#if MA_VRCSDK3_AVATARS #if MA_VRCSDK3_AVATARS
using VRC.SDKBase; using VRC.SDKBase;
#endif #endif
@ -31,6 +33,7 @@ namespace nadena.dev.modular_avatar.core
private void OnValidate() private void OnValidate()
{ {
#if UNITY_EDITOR
if (!PrefabUtility.IsPartOfPrefabAsset(this)) if (!PrefabUtility.IsPartOfPrefabAsset(this))
{ {
EditorApplication.delayCall += () => EditorApplication.delayCall += () =>
@ -38,6 +41,7 @@ namespace nadena.dev.modular_avatar.core
if (this != null) MaMoveIndependentlyManager.Instance.Activate(this); if (this != null) MaMoveIndependentlyManager.Instance.Activate(this);
}; };
} }
#endif
} }
private void OnEnable() private void OnEnable()