Skip to content

Commit

Permalink
change: MA Info is now a normal editor window (#850)
Browse files Browse the repository at this point in the history
  • Loading branch information
bdunderscore committed May 12, 2024
1 parent 61a70fe commit bc12e3a
Show file tree
Hide file tree
Showing 23 changed files with 239 additions and 472 deletions.
8 changes: 6 additions & 2 deletions Editor/AvatarProcessor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -22,25 +22,29 @@
* SOFTWARE.
*/

#region

using System;
using System.Runtime.CompilerServices;
using nadena.dev.modular_avatar.ui;
using UnityEditor;
using UnityEngine;

#endregion

[assembly: InternalsVisibleTo("Tests")]

namespace nadena.dev.modular_avatar.core.editor
{
public class AvatarProcessor
{
[MenuItem("GameObject/ModularAvatar/Manual bake avatar", true, 100)]
[MenuItem(UnityMenuItems.GameObject_ManualBake, true, UnityMenuItems.GameObject_ManualBakeOrder)]
static bool ValidateApplyToCurrentAvatarGameobject()
{
return ValidateApplyToCurrentAvatar();
}

[MenuItem("GameObject/ModularAvatar/Manual bake avatar", false, 100)]
[MenuItem(UnityMenuItems.GameObject_ManualBake, false, UnityMenuItems.GameObject_ManualBakeOrder)]
static void ApplyToCurrentAvatarGameobject()
{
ApplyToCurrentAvatar();
Expand Down
4 changes: 2 additions & 2 deletions Editor/EasySetupOutfit.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

using System.Collections.Generic;
using System.Linq;
using nadena.dev.modular_avatar.ui;
using UnityEditor;
using UnityEngine;
using Object = UnityEngine.Object;
Expand Down Expand Up @@ -114,11 +115,10 @@ private void OnGUI()

internal static class EasySetupOutfit
{
private const int PRIORITY = 49;
private static string[] errorMessageGroups;
private static string errorHeader;

[MenuItem("GameObject/ModularAvatar/Setup Outfit", false, PRIORITY)]
[MenuItem(UnityMenuItems.GameObject_SetupOutfit, false, UnityMenuItems.GameObject_SetupOutfitOrder)]
internal static void SetupOutfit(MenuCommand cmd)
{
if (!ValidateSetupOutfit())
Expand Down
102 changes: 0 additions & 102 deletions Editor/HarmonyPatches/InjectParamsUsageUI.cs

This file was deleted.

3 changes: 0 additions & 3 deletions Editor/HarmonyPatches/InjectParamsUsageUI.cs.meta

This file was deleted.

1 change: 0 additions & 1 deletion Editor/HarmonyPatches/PatchLoader.cs
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ internal class PatchLoader
#if UNITY_2022_3_OR_NEWER
HandleUtilityPatches.Patch_FilterInstanceIDs,
PickingObjectPatch.Patch,
InjectParamsUsageUI.Patch,
#endif
};

Expand Down
21 changes: 6 additions & 15 deletions Editor/Inspector/Common/LogoElement.cs
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
using System.Collections.Generic;
#region

using System.Collections.Generic;
using System.Linq;
using UnityEditor;
using UnityEditor.UIElements;
using UnityEngine;
using UnityEngine.TestTools;
using UnityEngine.UIElements;

#endregion

namespace nadena.dev.modular_avatar.core.editor
{
public class LogoElement : VisualElement
Expand Down Expand Up @@ -85,19 +87,8 @@ void WalkTree(VisualElement visualElement)

public LogoElement()
{
_inner = new VisualElement();

_inner = new LogoImage();
_inner.style.display = DisplayStyle.None;
_inner.style.flexDirection = FlexDirection.Row;
_inner.style.alignItems = Align.Center;
_inner.style.justifyContent = Justify.Center;

var image = new Image();
image.image = LogoDisplay.LOGO_ASSET;
image.style.width = new Length(LogoDisplay.ImageWidth(LogoDisplay.TARGET_HEIGHT), LengthUnit.Pixel);
image.style.height = new Length(LogoDisplay.TARGET_HEIGHT, LengthUnit.Pixel);

_inner.Add(image);
this.Add(_inner);

RegisterCallback<GeometryChangedEvent>(OnGeomChanged);
Expand Down
38 changes: 38 additions & 0 deletions Editor/Inspector/Common/LogoImage.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
#region

using UnityEngine.UIElements;

#endregion

namespace nadena.dev.modular_avatar.core.editor
{
public class LogoImage : VisualElement
{
VisualElement _inner;

public new class UxmlFactory : UxmlFactory<LogoImage, UxmlTraits>
{
}

public new class UxmlTraits : VisualElement.UxmlTraits
{
}

public LogoImage()
{
_inner = new VisualElement();

_inner.style.flexDirection = FlexDirection.Row;
_inner.style.alignItems = Align.Center;
_inner.style.justifyContent = Justify.Center;

var image = new Image();
image.image = LogoDisplay.LOGO_ASSET;
image.style.width = new Length(LogoDisplay.ImageWidth(LogoDisplay.TARGET_HEIGHT), LengthUnit.Pixel);
image.style.height = new Length(LogoDisplay.TARGET_HEIGHT, LengthUnit.Pixel);

_inner.Add(image);
Add(_inner);
}
}
}
3 changes: 3 additions & 0 deletions Editor/Inspector/Common/LogoImage.cs.meta

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 6 additions & 2 deletions Editor/Inspector/LogoDisplay.cs
Original file line number Diff line number Diff line change
@@ -1,7 +1,11 @@
using System;
#region

using System;
using UnityEditor;
using UnityEngine;

#endregion

namespace nadena.dev.modular_avatar.core.editor
{
internal static class LogoDisplay
Expand Down Expand Up @@ -37,7 +41,7 @@ static LogoDisplay()

internal static void DisplayLogo()
{
if (LOGO_ASSET == null) return;
if (LOGO_ASSET == null || EditorStyles.label == null) return;

var height = TARGET_HEIGHT;
var width = ImageWidth(height);
Expand Down
3 changes: 2 additions & 1 deletion Editor/Localization/en-US.json
Original file line number Diff line number Diff line change
Expand Up @@ -246,5 +246,6 @@
"ma_info.param_usage_ui.header": "Expressions Parameter Usage",
"ma_info.param_usage_ui.other_objects": "Other objects on this avatar",
"ma_info.param_usage_ui.free_space": "Unused parameter space ({0} bits)",
"ma_info.param_usage_ui.bits_template": "{0} ({1} bits)"
"ma_info.param_usage_ui.bits_template": "{0} ({1} bits)",
"ma_info.param_usage_ui.no_data": "[ NO DATA ]"
}
3 changes: 2 additions & 1 deletion Editor/Localization/ja-JP.json
Original file line number Diff line number Diff line change
Expand Up @@ -242,5 +242,6 @@
"ma_info.param_usage_ui.header": "Expressions Parameter 使用状況",
"ma_info.param_usage_ui.other_objects": "このアバター内の他のオブジェクト",
"ma_info.param_usage_ui.free_space": "未使用領域 ({0} 個のビット)",
"ma_info.param_usage_ui.bits_template": "{0} ({1} 個のビットを使用中)"
"ma_info.param_usage_ui.bits_template": "{0} ({1} 個のビットを使用中)",
"ma_info.param_usage_ui.no_data": "[ NO DATA ]"
}
20 changes: 12 additions & 8 deletions Editor/Menu/MenuExtractor.cs
Original file line number Diff line number Diff line change
@@ -1,19 +1,23 @@
#if MA_VRCSDK3_AVATARS

#region

using System;
using System.IO;
using System.Linq;
using nadena.dev.modular_avatar.ui;
using UnityEditor;
using UnityEngine;
using VRC.SDK3.Avatars.Components;
using VRC.SDK3.Avatars.ScriptableObjects;

#endregion

namespace nadena.dev.modular_avatar.core.editor
{
internal class MenuExtractor
{
private const int PRIORITY = 49;

[MenuItem("GameObject/ModularAvatar/Extract menu", false, PRIORITY)]
[MenuItem(UnityMenuItems.GameObject_ExtractMenu, false, UnityMenuItems.GameObject_ExtractMenuOrder)]
static void ExtractMenu(MenuCommand menuCommand)
{
if (!(menuCommand.context is GameObject gameObj)) return;
Expand All @@ -32,18 +36,18 @@ static void ExtractMenu(MenuCommand menuCommand)

var assetPath = AssetDatabase.GetAssetPath(avatar.expressionsMenu);
var dummyAssetPathBase = assetPath.Replace(".asset", " placeholder");
if (dummyAssetPathBase.StartsWith("Packages" + System.IO.Path.DirectorySeparatorChar))
if (dummyAssetPathBase.StartsWith("Packages" + Path.DirectorySeparatorChar))
{
var filename = System.IO.Path.GetFileName(dummyAssetPathBase);
dummyAssetPathBase = System.IO.Path.Combine("Assets", filename);
var filename = Path.GetFileName(dummyAssetPathBase);
dummyAssetPathBase = Path.Combine("Assets", filename);
}

// Check that a similarly-named file doesn't already exist
int i = 0;
do
{
var fullPath = dummyAssetPathBase + (i > 0 ? " " + i : "") + ".asset";
if (System.IO.File.Exists(fullPath))
if (File.Exists(fullPath))
{
var asset = AssetDatabase.LoadAssetAtPath<VRCExpressionsMenu>(fullPath);
if (asset != null && asset.controls.Count == 0)
Expand All @@ -52,7 +56,7 @@ static void ExtractMenu(MenuCommand menuCommand)
break;
}
}
else if (!System.IO.File.Exists(fullPath))
else if (!File.Exists(fullPath))
{
var dummyAsset = ScriptableObject.CreateInstance<VRCExpressionsMenu>();
AssetDatabase.CreateAsset(dummyAsset, fullPath);
Expand Down
23 changes: 0 additions & 23 deletions Editor/ParamsUsage/ModularAvatarInformation.cs

This file was deleted.

11 changes: 0 additions & 11 deletions Editor/ParamsUsage/ModularAvatarInformation.cs.meta

This file was deleted.

0 comments on commit bc12e3a

Please sign in to comment.