From d32c31aa746d60af5754965f1adb3bc6177c3d11 Mon Sep 17 00:00:00 2001 From: desktop-maesty/steve Date: Sat, 15 Jul 2017 21:19:25 +1000 Subject: [PATCH 1/2] Added script to show fungus icon in the hierarchy --- .../Fungus/Scripts/Editor/HierarchyIcons.cs | 60 +++++++++++++++++++ .../Scripts/Editor/HierarchyIcons.cs.meta | 12 ++++ 2 files changed, 72 insertions(+) create mode 100644 Assets/Fungus/Scripts/Editor/HierarchyIcons.cs create mode 100644 Assets/Fungus/Scripts/Editor/HierarchyIcons.cs.meta diff --git a/Assets/Fungus/Scripts/Editor/HierarchyIcons.cs b/Assets/Fungus/Scripts/Editor/HierarchyIcons.cs new file mode 100644 index 00000000..138cb83f --- /dev/null +++ b/Assets/Fungus/Scripts/Editor/HierarchyIcons.cs @@ -0,0 +1,60 @@ +using System.Collections; +using System.Collections.Generic; +using UnityEngine; +using UnityEditor; +using System.Linq; + +namespace Fungus +{ + /// + /// Static class that hooks into the hierachy changed and item gui callbacks to put + /// 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 + /// + [InitializeOnLoad] + public class HierarchyIcons + { + // the fungus mushroom icon + static Texture2D textureIcon; + + //sorted list of the GO instance IDs that have flowcharts on them + static List flowchartIDs = new List(); + + 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; + } + + //track all gameobjectIds that have flowcharts on them + static void HierarchyChanged() + { + flowchartIDs.Clear(); + + var flowcharts = GameObject.FindObjectsOfType(); + + flowchartIDs = flowcharts.Select(x => x.gameObject.GetInstanceID()).Distinct().ToList(); + flowchartIDs.Sort(); + } + + //Draw icon if the isntance id is in our cached list + static void HierarchyIconCallback(int instanceID, Rect selectionRect) + { + // 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); + } + } +} \ No newline at end of file diff --git a/Assets/Fungus/Scripts/Editor/HierarchyIcons.cs.meta b/Assets/Fungus/Scripts/Editor/HierarchyIcons.cs.meta new file mode 100644 index 00000000..ed0611fa --- /dev/null +++ b/Assets/Fungus/Scripts/Editor/HierarchyIcons.cs.meta @@ -0,0 +1,12 @@ +fileFormatVersion: 2 +guid: a347e274da09aa44dbb68f1375508d11 +timeCreated: 1500115754 +licenseType: Free +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: From 57d2c7134119d6556d4edb3accb0a172ec0f5ca1 Mon Sep 17 00:00:00 2001 From: desktop-maesty/steve Date: Wed, 19 Jul 2017 19:49:48 +1000 Subject: [PATCH 2/2] 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 --- .../FungusEditorResources.asset | 3 + .../Icons/Pro/fungus_mushroom.png | Bin 0 -> 5159 bytes .../Icons/Pro/fungus_mushroom.png.meta | 92 ++++++++++++++++++ .../EditorResources/Icons/fungus_mushroom.png | Bin 0 -> 5159 bytes .../Icons/fungus_mushroom.png.meta | 92 ++++++++++++++++++ .../Scripts/Editor/FungusEditorPreferences.cs | 43 ++++++++ .../Editor/FungusEditorPreferences.cs.meta | 12 +++ .../Editor/FungusEditorResourcesGenerated.cs | 2 + .../Fungus/Scripts/Editor/HierarchyIcons.cs | 21 ++-- 9 files changed, 258 insertions(+), 7 deletions(-) create mode 100644 Assets/Fungus/EditorResources/Icons/Pro/fungus_mushroom.png create mode 100644 Assets/Fungus/EditorResources/Icons/Pro/fungus_mushroom.png.meta create mode 100644 Assets/Fungus/EditorResources/Icons/fungus_mushroom.png create mode 100644 Assets/Fungus/EditorResources/Icons/fungus_mushroom.png.meta create mode 100644 Assets/Fungus/Scripts/Editor/FungusEditorPreferences.cs create mode 100644 Assets/Fungus/Scripts/Editor/FungusEditorPreferences.cs.meta diff --git a/Assets/Fungus/EditorResources/FungusEditorResources.asset b/Assets/Fungus/EditorResources/FungusEditorResources.asset index 05ea3abc..0e6ef67d 100644 --- a/Assets/Fungus/EditorResources/FungusEditorResources.asset +++ b/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} diff --git a/Assets/Fungus/EditorResources/Icons/Pro/fungus_mushroom.png b/Assets/Fungus/EditorResources/Icons/Pro/fungus_mushroom.png new file mode 100644 index 0000000000000000000000000000000000000000..ab22ce9c6d929c255239cafcbd2487f1369e0345 GIT binary patch literal 5159 zcmV+?6xi#DP)X+uL$Nkc;* zP;zf(X>4Tx07wm;mUmQB*%pV-y*Itk5+Wca^cs2zAksTX6$DXM^`x7XQc?|s+0 z08spb1j2M!0f022SQPH-!CVp(%f$Br7!UytSOLJ{W@ZFO_(THK{JlMynW#v{v-a*T zfMmPdEWc1DbJqWVks>!kBnAKqMb$PuekK>?0+ds;#ThdH1j_W4DKdsJG8Ul;qO2n0 z#IJ1jr{*iW$(WZWsE0n`c;fQ!l&-Anmjx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6mM%IF?+TI&)@_T(d&2{beaE1dGw)I5N9_n9h) z@-tFXlj4B@pG8GIc~WLE(-;GdCdBW)EnCQnf+Gb$d#b8P8yX@3PlB(%PS>%g!nkN`xw$&Zp%QLv)KDl$>FSaILSP{V#AX0uiNTu) zjI(zNLXi+oIDwc8u)t#zwd;u|w4Vpe9I&=1uPugd!Uq3DT zwbzVrM@KA%O>`6?oB$>E)?3O5GTmKWtqRbxKMGClDAIHUip*Q5{>GoAt)`-~SW1 z+wwP}KFKzAV#XXONHq%pCcCh(I5jsnD=9VAVX@n7CRMfQJv~-cRW&o`12*NXPYA9m zd1o*PHWnHk9SIK)cZLQAh9dp_qtV{pn|`AHPNJ(gAOFC*242ghIKjZ39}0X?q(M3G zsZf7)c}49ncKq_^RwS$+A0}~KS9CDL8)FE-8P9q$Rs=s;h#hrgSapG4P;=2YE zP8K%KA1CrM;)e=MM*fQNFBVRap>dU~ixw@uJa@qYggJ@A;V|+|;EPC}bW%7}kQBr` z6pqm1s%5)|Kx4!YoiFehT zHWA_Kb-Ue83+OitT?YT#4EQ!3a7h_B-&%TxgNqC^!zEDl-LWT+B}86EiOyYG?4fWt z$mMiSWdKYydv&MqI}kuT$C2ikK4E)m%R~eNs;s!6=0>G%{;{3e4>28;sOLH6^ zDlj4wj*~8-Og(E9rQ4chr72UUiCc7AE5Xem&rG=X5rQC@?S() VY0eDYTI~P;002ovPDHLkV1hlO(vkoG literal 0 HcmV?d00001 diff --git a/Assets/Fungus/EditorResources/Icons/Pro/fungus_mushroom.png.meta b/Assets/Fungus/EditorResources/Icons/Pro/fungus_mushroom.png.meta new file mode 100644 index 00000000..360d5b0d --- /dev/null +++ b/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: diff --git a/Assets/Fungus/EditorResources/Icons/fungus_mushroom.png b/Assets/Fungus/EditorResources/Icons/fungus_mushroom.png new file mode 100644 index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DHLkV1hlO(vkoG literal 0 HcmV?d00001 diff --git a/Assets/Fungus/EditorResources/Icons/fungus_mushroom.png.meta b/Assets/Fungus/EditorResources/Icons/fungus_mushroom.png.meta new file mode 100644 index 00000000..6433d929 --- /dev/null +++ b/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: diff --git a/Assets/Fungus/Scripts/Editor/FungusEditorPreferences.cs b/Assets/Fungus/Scripts/Editor/FungusEditorPreferences.cs new file mode 100644 index 00000000..50a0a881 --- /dev/null +++ b/Assets/Fungus/Scripts/Editor/FungusEditorPreferences.cs @@ -0,0 +1,43 @@ +using UnityEngine; +using UnityEditor; + +namespace Fungus +{ + namespace EditorUtils + { + /// + /// Shows Fungus section in the Edit->Preferences in unity allows you to configure Fungus behaviour + /// + /// ref https://docs.unity3d.com/ScriptReference/PreferenceItem.html + /// + 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); + } + } + } + } +} \ No newline at end of file diff --git a/Assets/Fungus/Scripts/Editor/FungusEditorPreferences.cs.meta b/Assets/Fungus/Scripts/Editor/FungusEditorPreferences.cs.meta new file mode 100644 index 00000000..8d0eedb8 --- /dev/null +++ b/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: diff --git a/Assets/Fungus/Scripts/Editor/FungusEditorResourcesGenerated.cs b/Assets/Fungus/Scripts/Editor/FungusEditorResourcesGenerated.cs index f7a0641b..1bfd555a 100644 --- a/Assets/Fungus/Scripts/Editor/FungusEditorResourcesGenerated.cs +++ b/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; } } diff --git a/Assets/Fungus/Scripts/Editor/HierarchyIcons.cs b/Assets/Fungus/Scripts/Editor/HierarchyIcons.cs index 138cb83f..60171bbb 100644 --- a/Assets/Fungus/Scripts/Editor/HierarchyIcons.cs +++ b/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 /// [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 flowchartIDs = new List(); 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(); 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); } } } \ No newline at end of file