chore: fix warnings

This commit is contained in:
bd_ 2023-07-30 01:15:16 +09:00
parent 05ed734438
commit 21373e13bc
12 changed files with 35 additions and 18 deletions

View File

@ -183,7 +183,10 @@ namespace nadena.dev.modular_avatar.core.editor
Object.DestroyImmediate(component); Object.DestroyImmediate(component);
} }
// Disable deprecation warning for reference to PipelineSaver
#pragma warning disable CS0618
foreach (var component in directChild.GetComponentsInChildren<PipelineSaver>(true)) foreach (var component in directChild.GetComponentsInChildren<PipelineSaver>(true))
#pragma warning restore CS0618
{ {
Object.DestroyImmediate(component); Object.DestroyImmediate(component);
} }
@ -242,7 +245,7 @@ namespace nadena.dev.modular_avatar.core.editor
madeProgress = true; madeProgress = true;
} }
} }
catch (Exception e) catch (Exception)
{ {
retryDestroy.Add(component); retryDestroy.Add(component);
} }

View File

@ -201,7 +201,7 @@ namespace nadena.dev.modular_avatar.editor.ErrorReporting
stacktrace = e.ToString() + additionalStackTrace; stacktrace = e.ToString() + additionalStackTrace;
} }
public string ToString() public override string ToString()
{ {
return "[" + reportLevel + "] " + messageCode + " " + "subst: " + string.Join(", ", substitutions); return "[" + reportLevel + "] " + messageCode + " " + "subst: " + string.Join(", ", substitutions);
} }
@ -248,7 +248,7 @@ namespace nadena.dev.modular_avatar.editor.ErrorReporting
var data = File.ReadAllText(Path); var data = File.ReadAllText(Path);
return JsonConvert.DeserializeObject<BuildReport>(data); return JsonConvert.DeserializeObject<BuildReport>(data);
} }
catch (Exception e) catch (Exception)
{ {
return null; return null;
} }

View File

@ -230,7 +230,6 @@ namespace nadena.dev.modular_avatar.editor.ErrorReporting
{ {
var report = BuildReport.CurrentReport; var report = BuildReport.CurrentReport;
AvatarReport selected = null;
EditorGUILayout.BeginVertical(GUILayout.MaxHeight(150), GUILayout.Width(position.width)); EditorGUILayout.BeginVertical(GUILayout.MaxHeight(150), GUILayout.Width(position.width));
if (report.Avatars.Count == 0) if (report.Avatars.Count == 0)
{ {

View File

@ -191,7 +191,8 @@ namespace nadena.dev.modular_avatar.core.editor
// available. See if we can find one. // available. See if we can find one.
foreach (var installer in _avatar.GetComponentsInChildren<ModularAvatarMenuInstaller>(true)) foreach (var installer in _avatar.GetComponentsInChildren<ModularAvatarMenuInstaller>(true))
{ {
if (installer.installTargetMenu != null && installer.installTargetMenu != menuTree.RootMenuKey) if (installer.installTargetMenu != null &&
!ReferenceEquals(installer.installTargetMenu, menuTree.RootMenuKey))
{ {
continue; continue;
} }

View File

@ -29,7 +29,6 @@ using nadena.dev.modular_avatar.editor.ErrorReporting;
using UnityEditor; using UnityEditor;
using UnityEngine; using UnityEngine;
using UnityEngine.Animations; using UnityEngine.Animations;
using VRC.Core;
using VRC.Dynamics; using VRC.Dynamics;
using VRC.SDK3.Avatars.Components; using VRC.SDK3.Avatars.Components;
using VRC.SDK3.Dynamics.PhysBone.Components; using VRC.SDK3.Dynamics.PhysBone.Components;
@ -125,9 +124,6 @@ namespace nadena.dev.modular_avatar.core.editor
private bool HasAdditionalComponents(GameObject go) private bool HasAdditionalComponents(GameObject go)
{ {
bool hasComponents = false; bool hasComponents = false;
bool needsConstraint = false;
bool hasPositionConstraint = false;
bool hasRotationConstraint = false;
foreach (Component c in go.GetComponents<Component>()) foreach (Component c in go.GetComponents<Component>())
{ {

View File

@ -1,8 +1,9 @@
{ {
"name": "nadena.dev.modular-avatar.core.editor", "name": "nadena.dev.modular-avatar.core.editor",
"references": [ "references": [
"GUID:fc900867c0f47cd49b6e2ae4ef907300", "GUID:fc900867c0f47cd49b6e2ae4ef907300",
"GUID:5718fb738711cd34ea54e9553040911d" "GUID:5718fb738711cd34ea54e9553040911d",
"GUID:3456780c4fb2d324ab9c633d6f1b0ddb"
], ],
"includePlatforms": [ "includePlatforms": [
"Editor" "Editor"

View File

@ -63,7 +63,7 @@ namespace nadena.dev.modular_avatar.core
OnChangeAction?.Invoke(); OnChangeAction?.Invoke();
} }
protected void OnDestroy() protected virtual void OnDestroy()
{ {
OnChangeAction?.Invoke(); OnChangeAction?.Invoke();
} }

View File

@ -9,8 +9,6 @@ namespace nadena.dev.modular_avatar.core
[AddComponentMenu("Modular Avatar/MA Menu Group")] [AddComponentMenu("Modular Avatar/MA Menu Group")]
public class ModularAvatarMenuGroup : MenuSourceComponent public class ModularAvatarMenuGroup : MenuSourceComponent
{ {
private bool recursing = false;
public GameObject targetObject; public GameObject targetObject;
public override void Visit(NodeContext context) public override void Visit(NodeContext context)

View File

@ -58,8 +58,9 @@ namespace nadena.dev.modular_avatar.core
RuntimeUtil.OnHierarchyChanged += Rebind; RuntimeUtil.OnHierarchyChanged += Rebind;
} }
private void OnDestroy() protected override void OnDestroy()
{ {
base.OnDestroy();
RuntimeUtil.OnHierarchyChanged -= Rebind; RuntimeUtil.OnHierarchyChanged -= Rebind;
} }

View File

@ -95,8 +95,9 @@ namespace nadena.dev.modular_avatar.core
public string subPath; public string subPath;
public BoneProxyAttachmentMode attachmentMode = BoneProxyAttachmentMode.Unset; public BoneProxyAttachmentMode attachmentMode = BoneProxyAttachmentMode.Unset;
void OnValidate() protected override void OnValidate()
{ {
base.OnValidate();
ClearCache(); ClearCache();
} }
@ -128,8 +129,9 @@ namespace nadena.dev.modular_avatar.core
} }
} }
private void OnDestroy() protected override void OnDestroy()
{ {
base.OnDestroy();
RuntimeUtil.OnHierarchyChanged -= ClearCache; RuntimeUtil.OnHierarchyChanged -= ClearCache;
} }

View File

@ -24,6 +24,7 @@
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using NUnit.Framework.Constraints;
using UnityEngine; using UnityEngine;
#if UNITY_EDITOR #if UNITY_EDITOR
using UnityEditor; using UnityEditor;
@ -80,8 +81,9 @@ namespace nadena.dev.modular_avatar.core
RuntimeUtil.delayCall(CheckLock); RuntimeUtil.delayCall(CheckLock);
} }
private void OnDestroy() protected override void OnDestroy()
{ {
base.OnDestroy();
#if UNITY_EDITOR #if UNITY_EDITOR
EditorApplication.update -= EditorUpdate; EditorApplication.update -= EditorUpdate;
#endif #endif

View File

@ -56,6 +56,20 @@ namespace nadena.dev.modular_avatar.core
public static OnDemandProcessAvatarDelegate OnDemandProcessAvatar = (_m, _c) => { }; public static OnDemandProcessAvatarDelegate OnDemandProcessAvatar = (_m, _c) => { };
internal static T GetOrAddComponent<T>(this Component self) where T : Component
{
var component = self.GetComponent<T>();
if (component == null) component = self.gameObject.AddComponent<T>();
return component;
}
internal static T GetOrAddComponent<T>(this GameObject self) where T : Component
{
var component = self.GetComponent<T>();
if (component == null) component = self.AddComponent<T>();
return component;
}
[CanBeNull] [CanBeNull]
public static string RelativePath(GameObject root, GameObject child) public static string RelativePath(GameObject root, GameObject child)
{ {