Special Icon when naming a MonoBehaviour class GameManager
This is baked into Unity, but it's a fake problem. It arises only when you put your user-written code into the global namespace. Don't do it!
The real answer is that all user-written script code should be in its own namespace -- that's what the feature is there to do. It would help if the Unity templates adopted that convention.
There are special scripts names in Unity. When you use any of those, special icon is applied to that script. GameManager
is one of the special script names. Search
is also another special script name in Unity. Unfortunately, they are not listed somewhere on Unity's website but you will absolutely know when you are using one of the special script names.
If you still want to use those special names to name your script and also want to remove the special icons or behavior, enclose that script with the special name in a namespace.
namespace Ben
{
public class Search : MonoBehaviour
{
}
}
The special icon for the Search
script should now be gone. This also applies to the GameManager
script.
EDIT:
Since people want to know more about this, basically, Unity has these important files that contains its icons:
unity default resources
unity editor resources
unity_builtin_extra
in the <UnityInstallationDirecory>\Editor\Data\Resources
directory. If you copy these files to your <ProjectDirecory>\Assets\Resources
directory and change the files extension of three of them to .asset
, you will be able to see assets and icon in those files when you expand them.
The secret to finding the special icons is that any of those icons that has a named that ends with " Icon"
is likely a special icon. For example, GameManager
has an icon named GameManager Icon
. Naming your script GameManager
will make it use the GameManager Icon
. This is not entirely true for all icon but most of them. Few don't do this.
I made a script to automate the instruction above in the Editor. It works in Unity 2017
but there seems to be issues with it in Unity 2018
and I haven't gotten some time to fix it. It shows many error in Unity 2018
when executed but it still works fine after that.
using System;
using System.Collections.Generic;
using System.Linq;
using UnityEngine;
using UnityEditor;
using System.IO;
/*
Detects possible special script names
By Programmer
https://stackoverflow.com/users/3785314/programmer
*/
public class SpecialIconLister : MonoBehaviour
{
[MenuItem("Programmer/Show Special Icons")]
static void MainProc()
{
if (EditorUtility.DisplayDialog("Log and copy special Icon names?",
"Are you sure you want to log and copy spacial icons to the clipboard?",
"Yes", "Cancel"))
{
if (IsPlayingInEditor())
return;
//"unity default resources" contains models, materials an shaders
//"unity editor resources" contains most icons lile GameManager Search and so on
//"unity_builtin_extra" contains UI images and Shaders
//Files to copy to the Resources folder in the project
string file1 = UnityEditorResourcesFilePath("unity default resources");
string file2 = UnityEditorResourcesFilePath("unity editor resources");
string file3 = UnityEditorResourcesFilePath("unity_builtin_extra");
string dest1 = UnityProjectResourcesPath("unity default resources.asset");
string dest2 = UnityProjectResourcesPath("unity editor resources.asset");
string dest3 = UnityProjectResourcesPath("unity_builtin_extra.asset");
//Create the Resources folder in the Project folder if it doesn't exist
VerifyResourcesFolder(dest1);
VerifyResourcesFolder(dest2);
VerifyResourcesFolder(dest3);
//Copy each file to the resouces folder
if (!File.Exists(dest1))
FileUtil.CopyFileOrDirectoryFollowSymlinks(file1, dest1);
if (!File.Exists(dest2))
FileUtil.CopyFileOrDirectoryFollowSymlinks(file2, dest2);
if (!File.Exists(dest3))
FileUtil.CopyFileOrDirectoryFollowSymlinks(file3, dest3);
Debug.unityLogger.logEnabled = false;
//Refresh Editor
AssetDatabase.Refresh(ImportAssetOptions.ForceSynchronousImport);
//Load every object in that folder
Resources.LoadAll("");
//List the special icons
GetSpecialIcons();
CleanUp(dest1);
CleanUp(dest2);
CleanUp(dest3);
//Refresh Editor
AssetDatabase.Refresh();
Resources.UnloadUnusedAssets();
AssetDatabase.Refresh();
Debug.unityLogger.logEnabled = false;
}
}
static void SelectAsset(string resourcesFilePath)
{
UnityEngine.Object obj = AssetDatabase.LoadAssetAtPath(resourcesFilePath, typeof(UnityEngine.Object));
Selection.activeObject = obj;
}
static string AsoluteToRelative(string absolutePath)
{
string relativePath = null;
if (absolutePath.StartsWith(Application.dataPath))
{
relativePath = "Assets" + absolutePath.Substring(Application.dataPath.Length);
}
return relativePath;
}
static void GetSpecialIcons()
{
//Get All Editor icons
List<UnityEngine.Object> allIcons;
allIcons = new List<UnityEngine.Object>(Resources.FindObjectsOfTypeAll(typeof(Texture)));
allIcons = allIcons.OrderBy(a => a.name, StringComparer.OrdinalIgnoreCase).ToList();
//Get special icons from the icons
List<string> specialIconsList = new List<string>();
string suffix = " Icon";
foreach (UnityEngine.Object icList in allIcons)
{
if (!IsEditorBuiltinIcon(icList))
continue;
//Check if icon name ends with the special suffix
if (icList.name.EndsWith(suffix))
{
//Remove suffix from the icon name then add it to the special icons List if it doesn't exist yet
string sIcon = icList.name.Substring(0, icList.name.LastIndexOf(suffix));
if (!specialIconsList.Contains(sIcon))
specialIconsList.Add(sIcon);
}
}
//Sort special icons from the icons
specialIconsList = specialIconsList.OrderBy(a => a, StringComparer.OrdinalIgnoreCase).ToList();
Debug.unityLogger.logEnabled = true;
Debug.Log("Total # Icons found: " + allIcons.Count);
Debug.Log("Special # Icons found: " + specialIconsList.Count);
//Add new line after each icon for easy display or copying
string specialIcon = string.Join(Environment.NewLine, specialIconsList.ToArray());
Debug.Log(specialIcon);
//Copy the special icon names to the clipboard
GUIUtility.systemCopyBuffer = specialIcon;
Debug.LogWarning("Special Icon names copied to cilpboard");
Debug.LogWarning("Hold Ctrl+V to paste on any Editor");
}
static string UnityEditorResourcesFilePath(string fileName = null)
{
//C:/Program Files/Unity/Editor/Unity.exe
string tempPath = EditorApplication.applicationPath;
//C:/Program Files/Unity/Editor
tempPath = Path.GetDirectoryName(tempPath);
tempPath = Path.Combine(tempPath, "Data");
tempPath = Path.Combine(tempPath, "Resources");
//C:\Program Files\Unity\Editor\Data\Resources
if (fileName != null)
tempPath = Path.Combine(tempPath, fileName);
return tempPath;
}
static string UnityProjectResourcesPath(string fileName = null)
{
string tempPath = Application.dataPath;
tempPath = Path.Combine(tempPath, "Resources");
if (fileName != null)
tempPath = Path.Combine(tempPath, fileName);
return tempPath;
}
static bool IsEditorBuiltinIcon(UnityEngine.Object icon)
{
if (!EditorUtility.IsPersistent(icon))
return false;
return true;
}
static void VerifyResourcesFolder(string resourcesPath)
{
//Create Directory if it does not exist
if (!Directory.Exists(Path.GetDirectoryName(resourcesPath)))
{
Directory.CreateDirectory(Path.GetDirectoryName(resourcesPath));
}
}
static bool IsPlayingInEditor()
{
return (Application.isPlaying && Application.isEditor);
}
static void CleanUp(string resourcesFilePath)
{
FileAttributes attr = File.GetAttributes(resourcesFilePath);
if (!((attr & FileAttributes.Directory) == FileAttributes.Directory)
&& File.Exists(resourcesFilePath))
{
FileUtil.DeleteFileOrDirectory(resourcesFilePath);
}
System.GC.Collect();
}
}
And below here is the Example dump copied to my clipboard when you go to the Programmer ---> Show Special Icons menu. It will show all the possible special characters. Some of them are not but most of them are:
AimConstraint
AnalyticsTracker
AnchorBehaviour
AnchorInputListenerBehaviour
Animation
AnimationClip
AnimationWindowEvent
Animator
AnimatorController
AnimatorOverrideController
AnimatorState
AnimatorStateMachine
AnimatorStateTransition
AnyStateNode
AreaEffector2D
AreaLight
AspectRatioFitter
Assembly
AssemblyDefinitionAsset
AssetStore
AudioChorusFilter
AudioClip
AudioDistortionFilter
AudioEchoFilter
AudioHighPassFilter
AudioListener
AudioLowPassFilter
AudioMixerController
AudioMixerGroup
AudioMixerSnapshot
AudioMixerView
AudioReverbFilter
AudioReverbZone
AudioSource
AudioSpatializerMicrosoft
Avatar
AvatarMask
BillboardAsset
BillboardRenderer
BlendTree
boo Script
BoxCollider
BoxCollider2D
BuoyancyEffector2D
Button
Camera
Canvas
CanvasGroup
CanvasRenderer
CanvasScaler
CapsuleCollider
CapsuleCollider2D
CGProgram
CharacterController
CharacterJoint
ChorusFilter
CircleCollider2D
Cloth
CloudRecoBehaviour
CollabChanges
CollabChangesConflict
CollabChangesDeleted
CollabConflict
CollabCreate
CollabDeleted
CollabEdit
CollabExclude
CollabMoved
CompositeCollider2D
ComputeShader
ConfigurableJoint
ConstantForce
ConstantForce2D
ContentPositioningBehaviour
ContentSizeFitter
cs Script
Cubemap
CylinderTargetBehaviour
DefaultAsset
DefaultSlate
DirectionalLight
DistanceJoint2D
dll Script
Dropdown
d_AimConstraint
d_AnchorBehaviour
d_AnchorInputListenerBehaviour
d_AspectRatioFitter
d_AudioMixerView
d_Canvas
d_CanvasGroup
d_CanvasRenderer
d_CanvasScaler
d_CloudRecoBehaviour
d_CollabChanges
d_CollabChangesConflict
d_CollabChangesDeleted
d_CollabConflict
d_CollabCreate
d_CollabDeleted
d_CollabEdit
d_CollabExclude
d_CollabMoved
d_ContentPositioningBehaviour
d_ContentSizeFitter
d_CylinderTargetBehaviour
d_EventSystem
d_EventTrigger
d_FreeformLayoutGroup
d_GraphicRaycaster
d_GridLayoutGroup
d_HorizontalLayoutGroup
d_ImageTargetBehaviour
d_LayoutElement
d_LightProbeProxyVolume
d_MidAirPositionerBehaviour
d_ModelTargetBehaviour
d_MultiTargetBehaviour
d_ObjectTargetBehaviour
d_ParentConstraint
d_ParticleSystem
d_PhysicalResolution
d_Physics2DRaycaster
d_PhysicsRaycaster
d_PlaneFinderBehaviour
d_PlayableDirector
d_PositionConstraint
d_RectTransform
d_RotationConstraint
d_ScaleConstraint
d_ScrollViewArea
d_SelectionList
d_SelectionListItem
d_SelectionListTemplate
d_SortingGroup
d_StandaloneInputModule
d_TimelineAsset
d_TouchInputModule
d_UserDefinedTargetBuildingBehaviour
d_VerticalLayoutGroup
d_VirtualButtonBehaviour
d_VuforiaBehaviour
d_VuMarkBehaviour
d_WireframeBehaviour
EchoFilter
EdgeCollider2D
EditorSettings
EventSystem
EventTrigger
Favorite
FixedJoint
FixedJoint2D
Flare
FlareLayer
Folder
FolderEmpty
FolderFavorite
Font
FreeformLayoutGroup
FrictionJoint2D
GameManager
GameObject
GraphicRaycaster
Grid
GridBrush
GridLayoutGroup
GUILayer
GUISkin
GUIText
GUITexture
Halo
HighPassFilter
HingeJoint
HingeJoint2D
HoloLensInputModule
HorizontalLayoutGroup
HumanTemplate
Image
ImageTargetBehaviour
InputField
Js Script
LayoutElement
LensFlare
Light
LightingDataAsset
LightingDataAssetParent
LightmapParameters
LightProbeGroup
LightProbeProxyVolume
LightProbes
LineRenderer
LODGroup
LowPassFilter
Mask
Material
Mesh
MeshCollider
MeshFilter
MeshParticleEmitter
MeshRenderer
MetaFile
Microphone
MidAirPositionerBehaviour
ModelTargetBehaviour
Motion
MovieTexture
MultiTargetBehaviour
MuscleClip
NavMeshAgent
NavMeshData
NavMeshObstacle
NetworkAnimator
NetworkDiscovery
NetworkIdentity
NetworkLobbyManager
NetworkLobbyPlayer
NetworkManager
NetworkManagerHUD
NetworkMigrationManager
NetworkProximityChecker
NetworkStartPosition
NetworkTransform
NetworkTransformChild
NetworkTransformVisualizer
NetworkView
ObjectTargetBehaviour
OcclusionArea
OcclusionPortal
OffMeshLink
Outline
ParentConstraint
ParticleAnimator
ParticleEmitter
ParticleRenderer
ParticleSystem
PhysicMaterial
Physics2DRaycaster
PhysicsMaterial2D
PhysicsRaycaster
PlaneFinderBehaviour
PlatformEffector2D
PlayableDirector
PointEffector2D
PolygonCollider2D
PositionAsUV1
PositionConstraint
Prefab
PrefabModel
PrefabNormal
Preset
ProceduralMaterial
Projector
RawImage
RaycastCollider
RectMask2D
RectTransform
ReflectionProbe
RelativeJoint2D
RenderTexture
ReverbFilter
Rigidbody
Rigidbody2D
RotationConstraint
ScaleConstraint
SceneAsset
SceneSet
ScriptableObject
Scrollbar
ScrollRect
Search
Selectable
Shader
ShaderVariantCollection
Shadow
SkinnedMeshRenderer
Skybox
Slider
SliderJoint2D
SoftlockProjectBrowser
SortingGroup
SpatialMappingCollider
SpatialMappingRenderer
SpeedTreeModel
SphereCollider
Spotlight
SpringJoint
SpringJoint2D
Sprite
SpriteAtlas
SpriteCollider
SpriteMask
SpriteRenderer
SpriteShapeRenderer
StandaloneInputModule
StyleSheet
SubstanceArchive
SurfaceEffector2D
TargetJoint2D
Terrain
TerrainCollider
TerrainData
Text
TextAsset
TextMesh
Texture
Texture2D
Tile
Tilemap
TilemapCollider2D
TilemapRenderer
TimelineAsset
Toggle
ToggleGroup
TouchInputModule
TrackedPoseDriver
TrailRenderer
Transform
UserDefinedTargetBuildingBehaviour
UssScript
UxmlScript
VerticalLayoutGroup
VideoClip
VideoEffect
VideoPlayer
VirtualButtonBehaviour
VisualTreeAsset
VuforiaBehaviour
VuMarkBehaviour
WheelCollider
WheelJoint2D
WindZone
WireframeBehaviour
WorldAnchor
WorldParticleCollider