internal static Object LoadResource(string pathName, System.Type type, bool lookForRetinaAssets)
        {
            Object resource  = null;
            string hiResPath = string.Empty;

            lookForRetinaAssets &= (type == typeof(Texture2D));

            if (lookForRetinaAssets)
            {
                string ext         = Path.GetExtension(pathName);
                string fileRenamed = Path.GetFileNameWithoutExtension(pathName) + "@2x" + ext;
                hiResPath           = Path.Combine(Path.GetDirectoryName(pathName), fileRenamed);
                lookForRetinaAssets = !string.IsNullOrEmpty(hiResPath);
            }

            if (lookForRetinaAssets)
            {
                resource = EditorGUIUtility.Load(hiResPath);
            }

            if (resource == null)
            {
                resource = EditorGUIUtility.Load(pathName);
            }

            if (resource == null && lookForRetinaAssets)
            {
                resource = Resources.Load(hiResPath, type);
            }

            if (resource == null)
            {
                resource = Resources.Load(pathName, type);
            }

            if (resource == null && lookForRetinaAssets)
            {
                resource = AssetDatabase.LoadMainAssetAtPath(hiResPath);
            }

            if (resource == null)
            {
                resource = AssetDatabase.LoadMainAssetAtPath(pathName);
            }

            if (resource != null)
            {
                Debug.Assert(type.IsAssignableFrom(resource.GetType()), "Resource type mismatch");

                // Add to post processor for tracking asset moves/deletes.
                var absoluteAssetPath = AssetDatabase.GetAssetPath(resource);
                if (type != typeof(UnityEngine.StyleSheets.StyleSheet) && !absoluteAssetPath.StartsWith("Library"))
                {
                    StyleSheetAssetPostprocessor.AddReferencedAssetPath(absoluteAssetPath);
                }
            }

            return(resource);
        }
        internal static UnityEngine.Object LoadResource(string pathName, Type type, bool lookForRetinaAssets)
        {
            UnityEngine.Object @object = null;
            string             text    = string.Empty;

            lookForRetinaAssets &= (type == typeof(Texture2D));
            if (lookForRetinaAssets)
            {
                string extension = Path.GetExtension(pathName);
                string path      = Path.GetFileNameWithoutExtension(pathName) + "@2x" + extension;
                text = Path.Combine(Path.GetDirectoryName(pathName), path);
                lookForRetinaAssets = !string.IsNullOrEmpty(text);
            }
            if (lookForRetinaAssets)
            {
                @object = EditorGUIUtility.Load(text);
            }
            if (@object == null)
            {
                @object = EditorGUIUtility.Load(pathName);
            }
            if (@object == null && lookForRetinaAssets)
            {
                @object = Resources.Load(text, type);
            }
            if (@object == null)
            {
                @object = Resources.Load(pathName, type);
            }
            if (@object == null && lookForRetinaAssets)
            {
                @object = AssetDatabase.LoadMainAssetAtPath(text);
            }
            if (@object == null)
            {
                @object = AssetDatabase.LoadMainAssetAtPath(pathName);
            }
            if (@object != null)
            {
                string assetPath = AssetDatabase.GetAssetPath(@object);
                if (type != typeof(StyleSheet) && !assetPath.StartsWith("Library"))
                {
                    StyleSheetAssetPostprocessor.AddReferencedAssetPath(assetPath);
                }
            }
            return(@object);
        }