From 21373e13bc795b7d37ae61724214d678c7e7588f Mon Sep 17 00:00:00 2001 From: bd_ Date: Sun, 30 Jul 2023 01:15:16 +0900 Subject: [PATCH] chore: fix warnings --- .../Editor/AvatarProcessor.cs | 5 ++++- .../Editor/ErrorReporting/ErrorLog.cs | 4 ++-- .../Editor/ErrorReporting/ErrorReportUI.cs | 1 - .../Editor/Inspector/Menu/AvMenuTreeView.cs | 3 ++- .../Editor/MergeArmatureHook.cs | 4 ---- .../nadena.dev.modular-avatar.core.editor.asmdef | 5 +++-- .../Runtime/AvatarTagComponent.cs | 2 +- .../Runtime/Menu/ModularAvatarMenuGroup.cs | 2 -- .../Runtime/ModularAvatarBlendshapeSync.cs | 3 ++- .../Runtime/ModularAvatarBoneProxy.cs | 6 ++++-- .../Runtime/ModularAvatarMergeArmature.cs | 4 +++- .../Runtime/RuntimeUtil.cs | 14 ++++++++++++++ 12 files changed, 35 insertions(+), 18 deletions(-) diff --git a/Packages/nadena.dev.modular-avatar/Editor/AvatarProcessor.cs b/Packages/nadena.dev.modular-avatar/Editor/AvatarProcessor.cs index d3f498e6..6fd64cbe 100644 --- a/Packages/nadena.dev.modular-avatar/Editor/AvatarProcessor.cs +++ b/Packages/nadena.dev.modular-avatar/Editor/AvatarProcessor.cs @@ -183,7 +183,10 @@ namespace nadena.dev.modular_avatar.core.editor Object.DestroyImmediate(component); } + // Disable deprecation warning for reference to PipelineSaver +#pragma warning disable CS0618 foreach (var component in directChild.GetComponentsInChildren(true)) +#pragma warning restore CS0618 { Object.DestroyImmediate(component); } @@ -242,7 +245,7 @@ namespace nadena.dev.modular_avatar.core.editor madeProgress = true; } } - catch (Exception e) + catch (Exception) { retryDestroy.Add(component); } diff --git a/Packages/nadena.dev.modular-avatar/Editor/ErrorReporting/ErrorLog.cs b/Packages/nadena.dev.modular-avatar/Editor/ErrorReporting/ErrorLog.cs index 5aa74499..eb7884ec 100644 --- a/Packages/nadena.dev.modular-avatar/Editor/ErrorReporting/ErrorLog.cs +++ b/Packages/nadena.dev.modular-avatar/Editor/ErrorReporting/ErrorLog.cs @@ -201,7 +201,7 @@ namespace nadena.dev.modular_avatar.editor.ErrorReporting stacktrace = e.ToString() + additionalStackTrace; } - public string ToString() + public override string ToString() { return "[" + reportLevel + "] " + messageCode + " " + "subst: " + string.Join(", ", substitutions); } @@ -248,7 +248,7 @@ namespace nadena.dev.modular_avatar.editor.ErrorReporting var data = File.ReadAllText(Path); return JsonConvert.DeserializeObject(data); } - catch (Exception e) + catch (Exception) { return null; } diff --git a/Packages/nadena.dev.modular-avatar/Editor/ErrorReporting/ErrorReportUI.cs b/Packages/nadena.dev.modular-avatar/Editor/ErrorReporting/ErrorReportUI.cs index 6049669a..29c8c144 100644 --- a/Packages/nadena.dev.modular-avatar/Editor/ErrorReporting/ErrorReportUI.cs +++ b/Packages/nadena.dev.modular-avatar/Editor/ErrorReporting/ErrorReportUI.cs @@ -230,7 +230,6 @@ namespace nadena.dev.modular_avatar.editor.ErrorReporting { var report = BuildReport.CurrentReport; - AvatarReport selected = null; EditorGUILayout.BeginVertical(GUILayout.MaxHeight(150), GUILayout.Width(position.width)); if (report.Avatars.Count == 0) { diff --git a/Packages/nadena.dev.modular-avatar/Editor/Inspector/Menu/AvMenuTreeView.cs b/Packages/nadena.dev.modular-avatar/Editor/Inspector/Menu/AvMenuTreeView.cs index b4171692..c0b604a9 100644 --- a/Packages/nadena.dev.modular-avatar/Editor/Inspector/Menu/AvMenuTreeView.cs +++ b/Packages/nadena.dev.modular-avatar/Editor/Inspector/Menu/AvMenuTreeView.cs @@ -191,7 +191,8 @@ namespace nadena.dev.modular_avatar.core.editor // available. See if we can find one. foreach (var installer in _avatar.GetComponentsInChildren(true)) { - if (installer.installTargetMenu != null && installer.installTargetMenu != menuTree.RootMenuKey) + if (installer.installTargetMenu != null && + !ReferenceEquals(installer.installTargetMenu, menuTree.RootMenuKey)) { continue; } diff --git a/Packages/nadena.dev.modular-avatar/Editor/MergeArmatureHook.cs b/Packages/nadena.dev.modular-avatar/Editor/MergeArmatureHook.cs index ef8286d9..15184a56 100644 --- a/Packages/nadena.dev.modular-avatar/Editor/MergeArmatureHook.cs +++ b/Packages/nadena.dev.modular-avatar/Editor/MergeArmatureHook.cs @@ -29,7 +29,6 @@ using nadena.dev.modular_avatar.editor.ErrorReporting; using UnityEditor; using UnityEngine; using UnityEngine.Animations; -using VRC.Core; using VRC.Dynamics; using VRC.SDK3.Avatars.Components; using VRC.SDK3.Dynamics.PhysBone.Components; @@ -125,9 +124,6 @@ namespace nadena.dev.modular_avatar.core.editor private bool HasAdditionalComponents(GameObject go) { bool hasComponents = false; - bool needsConstraint = false; - bool hasPositionConstraint = false; - bool hasRotationConstraint = false; foreach (Component c in go.GetComponents()) { diff --git a/Packages/nadena.dev.modular-avatar/Editor/nadena.dev.modular-avatar.core.editor.asmdef b/Packages/nadena.dev.modular-avatar/Editor/nadena.dev.modular-avatar.core.editor.asmdef index f8eb28d2..da2f7ae5 100644 --- a/Packages/nadena.dev.modular-avatar/Editor/nadena.dev.modular-avatar.core.editor.asmdef +++ b/Packages/nadena.dev.modular-avatar/Editor/nadena.dev.modular-avatar.core.editor.asmdef @@ -1,8 +1,9 @@ { "name": "nadena.dev.modular-avatar.core.editor", "references": [ - "GUID:fc900867c0f47cd49b6e2ae4ef907300", - "GUID:5718fb738711cd34ea54e9553040911d" + "GUID:fc900867c0f47cd49b6e2ae4ef907300", + "GUID:5718fb738711cd34ea54e9553040911d", + "GUID:3456780c4fb2d324ab9c633d6f1b0ddb" ], "includePlatforms": [ "Editor" diff --git a/Packages/nadena.dev.modular-avatar/Runtime/AvatarTagComponent.cs b/Packages/nadena.dev.modular-avatar/Runtime/AvatarTagComponent.cs index c01387ec..e3aa44dc 100644 --- a/Packages/nadena.dev.modular-avatar/Runtime/AvatarTagComponent.cs +++ b/Packages/nadena.dev.modular-avatar/Runtime/AvatarTagComponent.cs @@ -63,7 +63,7 @@ namespace nadena.dev.modular_avatar.core OnChangeAction?.Invoke(); } - protected void OnDestroy() + protected virtual void OnDestroy() { OnChangeAction?.Invoke(); } diff --git a/Packages/nadena.dev.modular-avatar/Runtime/Menu/ModularAvatarMenuGroup.cs b/Packages/nadena.dev.modular-avatar/Runtime/Menu/ModularAvatarMenuGroup.cs index c1ec420d..181a6af0 100644 --- a/Packages/nadena.dev.modular-avatar/Runtime/Menu/ModularAvatarMenuGroup.cs +++ b/Packages/nadena.dev.modular-avatar/Runtime/Menu/ModularAvatarMenuGroup.cs @@ -9,8 +9,6 @@ namespace nadena.dev.modular_avatar.core [AddComponentMenu("Modular Avatar/MA Menu Group")] public class ModularAvatarMenuGroup : MenuSourceComponent { - private bool recursing = false; - public GameObject targetObject; public override void Visit(NodeContext context) diff --git a/Packages/nadena.dev.modular-avatar/Runtime/ModularAvatarBlendshapeSync.cs b/Packages/nadena.dev.modular-avatar/Runtime/ModularAvatarBlendshapeSync.cs index c679651b..fbb27947 100644 --- a/Packages/nadena.dev.modular-avatar/Runtime/ModularAvatarBlendshapeSync.cs +++ b/Packages/nadena.dev.modular-avatar/Runtime/ModularAvatarBlendshapeSync.cs @@ -58,8 +58,9 @@ namespace nadena.dev.modular_avatar.core RuntimeUtil.OnHierarchyChanged += Rebind; } - private void OnDestroy() + protected override void OnDestroy() { + base.OnDestroy(); RuntimeUtil.OnHierarchyChanged -= Rebind; } diff --git a/Packages/nadena.dev.modular-avatar/Runtime/ModularAvatarBoneProxy.cs b/Packages/nadena.dev.modular-avatar/Runtime/ModularAvatarBoneProxy.cs index f0bff1ff..f44dd794 100644 --- a/Packages/nadena.dev.modular-avatar/Runtime/ModularAvatarBoneProxy.cs +++ b/Packages/nadena.dev.modular-avatar/Runtime/ModularAvatarBoneProxy.cs @@ -95,8 +95,9 @@ namespace nadena.dev.modular_avatar.core public string subPath; public BoneProxyAttachmentMode attachmentMode = BoneProxyAttachmentMode.Unset; - void OnValidate() + protected override void OnValidate() { + base.OnValidate(); ClearCache(); } @@ -128,8 +129,9 @@ namespace nadena.dev.modular_avatar.core } } - private void OnDestroy() + protected override void OnDestroy() { + base.OnDestroy(); RuntimeUtil.OnHierarchyChanged -= ClearCache; } diff --git a/Packages/nadena.dev.modular-avatar/Runtime/ModularAvatarMergeArmature.cs b/Packages/nadena.dev.modular-avatar/Runtime/ModularAvatarMergeArmature.cs index 933e8797..4d77c6cf 100644 --- a/Packages/nadena.dev.modular-avatar/Runtime/ModularAvatarMergeArmature.cs +++ b/Packages/nadena.dev.modular-avatar/Runtime/ModularAvatarMergeArmature.cs @@ -24,6 +24,7 @@ using System; using System.Collections.Generic; +using NUnit.Framework.Constraints; using UnityEngine; #if UNITY_EDITOR using UnityEditor; @@ -80,8 +81,9 @@ namespace nadena.dev.modular_avatar.core RuntimeUtil.delayCall(CheckLock); } - private void OnDestroy() + protected override void OnDestroy() { + base.OnDestroy(); #if UNITY_EDITOR EditorApplication.update -= EditorUpdate; #endif diff --git a/Packages/nadena.dev.modular-avatar/Runtime/RuntimeUtil.cs b/Packages/nadena.dev.modular-avatar/Runtime/RuntimeUtil.cs index 0d58bff0..08eeb902 100644 --- a/Packages/nadena.dev.modular-avatar/Runtime/RuntimeUtil.cs +++ b/Packages/nadena.dev.modular-avatar/Runtime/RuntimeUtil.cs @@ -56,6 +56,20 @@ namespace nadena.dev.modular_avatar.core public static OnDemandProcessAvatarDelegate OnDemandProcessAvatar = (_m, _c) => { }; + internal static T GetOrAddComponent(this Component self) where T : Component + { + var component = self.GetComponent(); + if (component == null) component = self.gameObject.AddComponent(); + return component; + } + + internal static T GetOrAddComponent(this GameObject self) where T : Component + { + var component = self.GetComponent(); + if (component == null) component = self.AddComponent(); + return component; + } + [CanBeNull] public static string RelativePath(GameObject root, GameObject child) {