Add logo rendering logic

This commit is contained in:
bd_ 2022-10-22 13:31:10 -07:00
parent d82df1f371
commit 03bb8d85a6
10 changed files with 71 additions and 0 deletions

View File

@ -19,6 +19,17 @@ jobs:
- name: Checkout
uses: actions/checkout@v3
- name: Checkout logo assets
uses: actions/checkout@v3
if: startsWith(github.ref, 'refs/tags/')
with:
repository: bdunderscore/modular-avatar-images
path: image-assets
- name: Inject logo assets
if: startsWith(github.ref, 'refs/tags/')
run: |
cp -f image-assets/img/logo/ma_logo.png Packages/net.fushizen.modular-avatar/Editor/Images/logo.png
- name: get version
id: version

View File

@ -0,0 +1 @@
ma_*

View File

@ -412,6 +412,8 @@ namespace net.fushizen.modular_avatar.core.editor
public override void OnInspectorGUI()
{
LogoDisplay.DisplayLogo();
EditorGUI.BeginChangeCheck();
_devMode = EditorGUILayout.Toggle(G("params.devmode"), _devMode);
if (EditorGUI.EndChangeCheck() || _reorderableList == null || _needsRebuild) SetupList();

View File

@ -98,6 +98,8 @@ namespace net.fushizen.modular_avatar.core.editor
public override void OnInspectorGUI()
{
LogoDisplay.DisplayLogo();
serializedObject.Update();
_list.DoLayoutList();

View File

@ -28,6 +28,8 @@ namespace net.fushizen.modular_avatar.core.editor
public override void OnInspectorGUI()
{
LogoDisplay.DisplayLogo();
GameObject parentAvatar = null;
bool suppressTarget = false;

View File

@ -0,0 +1,44 @@
using System;
using UnityEditor;
using UnityEngine;
namespace net.fushizen.modular_avatar.core.editor
{
internal static class LogoDisplay
{
private static Texture2D LOGO_ASSET;
private static float TARGET_HEIGHT => EditorStyles.label.lineHeight * 3;
private static GUIStyle STYLE => new GUIStyle()
{
fixedHeight = TARGET_HEIGHT,
fixedWidth = TARGET_HEIGHT * (LOGO_ASSET.width / (float)LOGO_ASSET.height),
stretchHeight = false,
stretchWidth = false,
imagePosition = ImagePosition.ImageOnly
};
static LogoDisplay()
{
var placeholderPath = AssetDatabase.GUIDToAssetPath("2a2bb4e0b8e906743890ef10c778e65c");
var path = placeholderPath.Substring(0, placeholderPath.LastIndexOf("/", StringComparison.Ordinal));
path += "/ma_logo.png";
var real_logo = AssetDatabase.LoadAssetAtPath<Texture2D>(path);
if (real_logo != null) LOGO_ASSET = real_logo;
else LOGO_ASSET = AssetDatabase.LoadAssetAtPath<Texture2D>(placeholderPath);
}
internal static void DisplayLogo()
{
if (LOGO_ASSET == null) return;
var height = TARGET_HEIGHT;
var width = (height / (float)LOGO_ASSET.height) * LOGO_ASSET.width;
var rect = GUILayoutUtility.GetRect(width, height);
GUI.DrawTexture(rect, LOGO_ASSET, ScaleMode.ScaleToFit);
}
}
}

View File

@ -0,0 +1,3 @@
fileFormatVersion: 2
guid: 44a66efb3c5244688dc712e961abf6df
timeCreated: 1666469072

View File

@ -49,6 +49,8 @@ namespace net.fushizen.modular_avatar.core.editor
public override void OnInspectorGUI()
{
LogoDisplay.DisplayLogo();
SetupMenuEditor();
var installTo = serializedObject.FindProperty(nameof(ModularAvatarMenuInstaller.installTargetMenu));

View File

@ -48,6 +48,8 @@ namespace net.fushizen.modular_avatar.core.editor
public override void OnInspectorGUI()
{
LogoDisplay.DisplayLogo();
serializedObject.Update();
EditorGUILayout.PropertyField(prop_animator, G("merge_animator.animator"));

View File

@ -32,6 +32,8 @@ namespace net.fushizen.modular_avatar.core.editor
public override void OnInspectorGUI()
{
LogoDisplay.DisplayLogo();
var target = (ModularAvatarMergeArmature) this.target;
var priorMergeTarget = target.mergeTargetObject;