Browse Source

Changed icon loading to be FungusEditorResources

Added fungus_mushroom to EditorResources
Added Fungus to Editor->Preferences-Fungus
-Added ability to toggle off the fungus icon in the hierarchy in case it conflicts with other tools or is just undesired
master
desktop-maesty/steve 7 years ago
parent
commit
57d2c71341
  1. 3
      Assets/Fungus/EditorResources/FungusEditorResources.asset
  2. BIN
      Assets/Fungus/EditorResources/Icons/Pro/fungus_mushroom.png
  3. 92
      Assets/Fungus/EditorResources/Icons/Pro/fungus_mushroom.png.meta
  4. BIN
      Assets/Fungus/EditorResources/Icons/fungus_mushroom.png
  5. 92
      Assets/Fungus/EditorResources/Icons/fungus_mushroom.png.meta
  6. 43
      Assets/Fungus/Scripts/Editor/FungusEditorPreferences.cs
  7. 12
      Assets/Fungus/Scripts/Editor/FungusEditorPreferences.cs.meta
  8. 2
      Assets/Fungus/Scripts/Editor/FungusEditorResourcesGenerated.cs
  9. 21
      Assets/Fungus/Scripts/Editor/HierarchyIcons.cs

3
Assets/Fungus/EditorResources/FungusEditorResources.asset

@ -27,6 +27,9 @@ MonoBehaviour:
duplicate:
free: {fileID: 2800000, guid: c97f334c466215a4f93eff31de3c1591, type: 3}
pro: {fileID: 2800000, guid: 2f17490d993c84bd7872ef6588ffba47, type: 3}
fungus_mushroom:
free: {fileID: 2800000, guid: 1c99c9bf7557e23469ed5dfce00504c0, type: 3}
pro: {fileID: 2800000, guid: 6368c1c16ebb1694091262337e4f8c44, type: 3}
up:
free: {fileID: 2800000, guid: 8f1242ad894201f43b2b6d52fd990f77, type: 3}
pro: {fileID: 2800000, guid: 2a76a781db2994b33b83cd84b8835da7, type: 3}

BIN
Assets/Fungus/EditorResources/Icons/Pro/fungus_mushroom.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 5.0 KiB

92
Assets/Fungus/EditorResources/Icons/Pro/fungus_mushroom.png.meta

@ -0,0 +1,92 @@
fileFormatVersion: 2
guid: 6368c1c16ebb1694091262337e4f8c44
timeCreated: 1500456217
licenseType: Free
TextureImporter:
fileIDToRecycleName: {}
serializedVersion: 4
mipmaps:
mipMapMode: 0
enableMipMap: 0
sRGBTexture: 0
linearTexture: 0
fadeOut: 0
borderMipMap: 0
mipMapFadeDistanceStart: 1
mipMapFadeDistanceEnd: 3
bumpmap:
convertToNormalMap: 0
externalNormalMap: 0
heightScale: 0.25
normalMapFilter: 0
isReadable: 0
grayScaleToAlpha: 0
generateCubemap: 6
cubemapConvolution: 0
seamlessCubemap: 0
textureFormat: 1
maxTextureSize: 2048
textureSettings:
filterMode: 1
aniso: -1
mipBias: -1
wrapMode: 1
nPOTScale: 0
lightmap: 0
compressionQuality: 50
spriteMode: 1
spriteExtrude: 1
spriteMeshType: 1
alignment: 0
spritePivot: {x: 0.5, y: 0.5}
spriteBorder: {x: 0, y: 0, z: 0, w: 0}
spritePixelsToUnits: 100
alphaUsage: 1
alphaIsTransparency: 1
spriteTessellationDetail: -1
textureType: 2
textureShape: 1
maxTextureSizeSet: 0
compressionQualitySet: 0
textureFormatSet: 0
platformSettings:
- buildTarget: DefaultTexturePlatform
maxTextureSize: 1024
textureFormat: -1
textureCompression: 0
compressionQuality: 50
crunchedCompression: 0
allowsAlphaSplitting: 0
overridden: 0
- buildTarget: Standalone
maxTextureSize: 1024
textureFormat: -1
textureCompression: 0
compressionQuality: 50
crunchedCompression: 0
allowsAlphaSplitting: 0
overridden: 0
- buildTarget: Android
maxTextureSize: 1024
textureFormat: -1
textureCompression: 0
compressionQuality: 50
crunchedCompression: 0
allowsAlphaSplitting: 0
overridden: 0
- buildTarget: WebGL
maxTextureSize: 1024
textureFormat: -1
textureCompression: 0
compressionQuality: 50
crunchedCompression: 0
allowsAlphaSplitting: 0
overridden: 0
spriteSheet:
serializedVersion: 2
sprites: []
outline: []
spritePackingTag:
userData:
assetBundleName:
assetBundleVariant:

BIN
Assets/Fungus/EditorResources/Icons/fungus_mushroom.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 5.0 KiB

92
Assets/Fungus/EditorResources/Icons/fungus_mushroom.png.meta

@ -0,0 +1,92 @@
fileFormatVersion: 2
guid: 1c99c9bf7557e23469ed5dfce00504c0
timeCreated: 1500455974
licenseType: Free
TextureImporter:
fileIDToRecycleName: {}
serializedVersion: 4
mipmaps:
mipMapMode: 0
enableMipMap: 0
sRGBTexture: 0
linearTexture: 0
fadeOut: 0
borderMipMap: 0
mipMapFadeDistanceStart: 1
mipMapFadeDistanceEnd: 3
bumpmap:
convertToNormalMap: 0
externalNormalMap: 0
heightScale: 0.25
normalMapFilter: 0
isReadable: 0
grayScaleToAlpha: 0
generateCubemap: 6
cubemapConvolution: 0
seamlessCubemap: 0
textureFormat: 1
maxTextureSize: 2048
textureSettings:
filterMode: 1
aniso: -1
mipBias: -1
wrapMode: 1
nPOTScale: 0
lightmap: 0
compressionQuality: 50
spriteMode: 1
spriteExtrude: 1
spriteMeshType: 1
alignment: 0
spritePivot: {x: 0.5, y: 0.5}
spriteBorder: {x: 0, y: 0, z: 0, w: 0}
spritePixelsToUnits: 100
alphaUsage: 1
alphaIsTransparency: 1
spriteTessellationDetail: -1
textureType: 2
textureShape: 1
maxTextureSizeSet: 0
compressionQualitySet: 0
textureFormatSet: 0
platformSettings:
- buildTarget: DefaultTexturePlatform
maxTextureSize: 1024
textureFormat: -1
textureCompression: 0
compressionQuality: 50
crunchedCompression: 0
allowsAlphaSplitting: 0
overridden: 0
- buildTarget: Standalone
maxTextureSize: 1024
textureFormat: -1
textureCompression: 0
compressionQuality: 50
crunchedCompression: 0
allowsAlphaSplitting: 0
overridden: 0
- buildTarget: Android
maxTextureSize: 1024
textureFormat: -1
textureCompression: 0
compressionQuality: 50
crunchedCompression: 0
allowsAlphaSplitting: 0
overridden: 0
- buildTarget: WebGL
maxTextureSize: 1024
textureFormat: -1
textureCompression: 0
compressionQuality: 50
crunchedCompression: 0
allowsAlphaSplitting: 0
overridden: 0
spriteSheet:
serializedVersion: 2
sprites: []
outline: []
spritePackingTag:
userData:
assetBundleName:
assetBundleVariant:

43
Assets/Fungus/Scripts/Editor/FungusEditorPreferences.cs

@ -0,0 +1,43 @@
using UnityEngine;
using UnityEditor;
namespace Fungus
{
namespace EditorUtils
{
/// <summary>
/// Shows Fungus section in the Edit->Preferences in unity allows you to configure Fungus behaviour
///
/// ref https://docs.unity3d.com/ScriptReference/PreferenceItem.html
/// </summary>
public class FungusEditorPreferences
{
// Have we loaded the prefs yet
private static bool prefsLoaded = false;
public static bool hideMushroomInHierarchy = false;
// Add preferences section named "My Preferences" to the Preferences Window
[PreferenceItem("Fungus")]
public static void PreferencesGUI()
{
// Load the preferences
if (!prefsLoaded)
{
hideMushroomInHierarchy = EditorPrefs.GetBool("hideMushroomInHierarchy", false);
prefsLoaded = true;
}
// Preferences GUI
hideMushroomInHierarchy = EditorGUILayout.Toggle("Hide Mushroom Flowchart Icon", hideMushroomInHierarchy);
// Save the preferences
if (GUI.changed)
{
EditorPrefs.SetBool("hideMushroomInHierarchy", hideMushroomInHierarchy);
}
}
}
}
}

12
Assets/Fungus/Scripts/Editor/FungusEditorPreferences.cs.meta

@ -0,0 +1,12 @@
fileFormatVersion: 2
guid: cde6865c94505574e8ccf958a03f8463
timeCreated: 1500456646
licenseType: Free
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

2
Assets/Fungus/Scripts/Editor/FungusEditorResourcesGenerated.cs

@ -12,6 +12,7 @@ namespace Fungus.EditorUtils
[SerializeField] private EditorTexture delete;
[SerializeField] private EditorTexture down;
[SerializeField] private EditorTexture duplicate;
[SerializeField] private EditorTexture fungus_mushroom;
[SerializeField] private EditorTexture up;
[SerializeField] private EditorTexture bullet_point;
[SerializeField] private EditorTexture choice_node_off;
@ -30,6 +31,7 @@ namespace Fungus.EditorUtils
public static Texture2D Delete { get { return Instance.delete.Texture2D; } }
public static Texture2D Down { get { return Instance.down.Texture2D; } }
public static Texture2D Duplicate { get { return Instance.duplicate.Texture2D; } }
public static Texture2D FungusMushroom { get { return Instance.fungus_mushroom.Texture2D; } }
public static Texture2D Up { get { return Instance.up.Texture2D; } }
public static Texture2D BulletPoint { get { return Instance.bullet_point.Texture2D; } }
public static Texture2D ChoiceNodeOff { get { return Instance.choice_node_off.Texture2D; } }

21
Assets/Fungus/Scripts/Editor/HierarchyIcons.cs

@ -11,21 +11,22 @@ namespace Fungus
/// a fungus icon infront of all GOs that have a flowchart on them
///
/// Reference; http://answers.unity3d.com/questions/431952/how-to-show-an-icon-in-hierarchy-view.html
///
/// TODO
/// There is what appears like a bug but is currently out of our control. When Unity reloads the built scripts it fires
/// InitializeOnLoad but doesn't then fire HierarchyChanged so icons disappear until a change occurs
/// </summary>
[InitializeOnLoad]
public class HierarchyIcons
{
// the fungus mushroom icon
static Texture2D textureIcon;
static Texture2D TextureIcon { get { return Fungus.EditorUtils.FungusEditorResources.FungusMushroom; } }
//sorted list of the GO instance IDs that have flowcharts on them
static List<int> flowchartIDs = new List<int>();
static HierarchyIcons()
{
//please don't move the fungus icon :(
textureIcon = AssetDatabase.LoadAssetAtPath("Assets/Fungus/Textures/ScriptIcon.png", typeof(Texture2D)) as Texture2D;
{
EditorApplication.hierarchyWindowItemOnGUI += HierarchyIconCallback;
EditorApplication.hierarchyWindowChanged += HierarchyChanged;
}
@ -35,6 +36,9 @@ namespace Fungus
{
flowchartIDs.Clear();
if (EditorUtils.FungusEditorPreferences.hideMushroomInHierarchy)
return;
var flowcharts = GameObject.FindObjectsOfType<Flowchart>();
flowchartIDs = flowcharts.Select(x => x.gameObject.GetInstanceID()).Distinct().ToList();
@ -44,17 +48,20 @@ namespace Fungus
//Draw icon if the isntance id is in our cached list
static void HierarchyIconCallback(int instanceID, Rect selectionRect)
{
if (EditorUtils.FungusEditorPreferences.hideMushroomInHierarchy)
return;
// place the icon to the left of the element
Rect r = new Rect(selectionRect);
r.x = 0;
r.width = r.height;
//GameObject go = EditorUtility.InstanceIDToObject(instanceID) as GameObject;
//binary search as it is much faster to cache and int bin search than GetComponent
// should be less GC too
if (flowchartIDs.BinarySearch(instanceID) >= 0)
GUI.Label(r, textureIcon);
GUI.Label(r, TextureIcon);
}
}
}
Loading…
Cancel
Save