Skip to content

Commit

Permalink
fix: Fixed MissingReferenceException on MacOS
Browse files Browse the repository at this point in the history
Replaced a .png file with base64-encoded string
  • Loading branch information
SolidAlloy committed Oct 22, 2021
1 parent d1a2bc2 commit 16a2fd3
Show file tree
Hide file tree
Showing 5 changed files with 20 additions and 123 deletions.
4 changes: 1 addition & 3 deletions Editor/Extensions/MonoScriptExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,7 @@
public static class MonoScriptExtensions
{
private static readonly Regex _namespaceNameRegex = new Regex(@"(?<=namespace[\s]+)[\w_.-]+", RegexOptions.Compiled);

private static readonly Regex _classRegex =
new Regex(@"(?<=(class )|(struct )).*?(?=(\s|\n)*(:|{))", RegexOptions.Compiled);
private static readonly Regex _classRegex = new Regex(@"(?<=(class )|(struct )).*?(?=(\s|\n)*(:|{))", RegexOptions.Compiled);

/// <summary>
/// Returns the <see cref="Type"/> of the class implemented by this script. Works for types not derived from
Expand Down
8 changes: 0 additions & 8 deletions Editor/Helpers/EditorIcons.cs
Original file line number Diff line number Diff line change
Expand Up @@ -34,14 +34,6 @@ public static class EditorIcons

static EditorIcons()
{
// The icon sometimes reports MissingReferenceException on MacOS for some reason.
if (Database.TriangleRight == null)
{
const string triangleRightGuid = "bb26edf4be136b0459bfdf7ff0c7455b";
string path = AssetDatabase.GUIDToAssetPath(triangleRightGuid);
Database.TriangleRight = AssetDatabase.LoadAssetAtPath<Texture2D>(path);
}

TriangleRight = new EditorIcon(Database.TriangleRight);
TriangleDown = new EditorIcon(Database.TriangleRight.Rotate());

Expand Down
20 changes: 19 additions & 1 deletion Editor/Helpers/EditorIconsRelated/EditorIconsDatabase.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
namespace SolidUtilities.Editor.Helpers.EditorIconsRelated
{
using System;
using JetBrains.Annotations;
using UnityEditor;
using UnityEngine;
Expand All @@ -13,10 +14,27 @@
/// </summary>
internal class EditorIconsDatabase : ScriptableObject
{
private const string TriangleRightData = "iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAABaklEQVQ4jdWRsWrCUBSGT87NrSGQ0WAgT9AH8AV8BXHqpJNDodClQ0GhSwuFLn2DQl/AxaXi0EWKUKhbcHBx65QrNAnnnnKjETW6t/90uNz/u+f/L/x/WUWCXq8HlmVBlmUghEDbtllrzcycnxv1+/1SYCwGc4mIwPf9MymlVkoxAAhEBAM5JXtLQhRKKWo0GvfVajUZj8ePs9nsW2sNlUpFMDMdY2w3YGZrEyHwff+m1Wp9drvdqzAM3TiOKU3TkvkwQp4XETPzWpZlYRAET51O56PZbF7UajWv5N4FrBlWMQghxA8RpVLK83q9/tJuty9L7t0O1inyskz7RESOlBJWq9X7ZDK5m06nbyX3ASDfgJkdUygifs3n84fBYPC6XC7ZcZySeQ/AzHrTQbRYLK5Ho9FzFEWpEAI8z0NtvuOI9gCu68JwOLxVSkGSJOC6LppzItJFPydL3LwOcRybLGhgxVanzH9AAPALQK6xKuQq1X8AAAAASUVORK5CYII=";

[UsedImplicitly]
[SerializeField, Multiline(6)] private string _description;

public Texture2D TriangleRight;
private Texture2D _triangleRight;

public Texture2D TriangleRight
{
get
{
if (_triangleRight == null)
{
var pngBytes = Convert.FromBase64String(TriangleRightData);
_triangleRight = new Texture2D(2, 2);
_triangleRight.LoadImage(pngBytes);
}

return _triangleRight;
}
}

[SerializeField] private Material _activeDarkSkin;
[SerializeField] private Material _activeLightSkin;
Expand Down
3 changes: 0 additions & 3 deletions Editor/Helpers/EditorIconsRelated/triangle_right_16.png

This file was deleted.

108 changes: 0 additions & 108 deletions Editor/Helpers/EditorIconsRelated/triangle_right_16.png.meta

This file was deleted.

0 comments on commit 16a2fd3

Please sign in to comment.