mirror of
https://github.com/bdunderscore/modular-avatar.git
synced 2025-01-01 12:15:05 +08:00
ddbc3b164b
* chore: rearrange package structure to have the package at the root * ci: update CI workflows * ci: fixing workflow bugs * ci: recurse building .zip package * ci: more fixes * ci: add back in the nadena.dev VPM repo * ci: fix tests
50 lines
1.7 KiB
C#
50 lines
1.7 KiB
C#
using System;
|
|
using UnityEditor;
|
|
using UnityEngine;
|
|
|
|
namespace nadena.dev.modular_avatar.core.editor
|
|
{
|
|
internal static class LogoDisplay
|
|
{
|
|
internal static readonly Texture2D LOGO_ASSET;
|
|
internal static float TARGET_HEIGHT => EditorStyles.label.lineHeight * 3;
|
|
|
|
internal static float ImageWidth(float height)
|
|
{
|
|
return (height / (float) LOGO_ASSET.height) * LOGO_ASSET.width;
|
|
}
|
|
|
|
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 = ImageWidth(height);
|
|
var rect = GUILayoutUtility.GetRect(width, height);
|
|
|
|
GUI.DrawTexture(rect, LOGO_ASSET, ScaleMode.ScaleToFit);
|
|
GUILayoutUtility.GetRect(width, EditorStyles.label.lineHeight / 2);
|
|
}
|
|
}
|
|
} |