SimpleSpritePackerEditor.SPTools.GetAssetPath C# (CSharp) Method

GetAssetPath() public static method

Gets the asset path of a object.
public static GetAssetPath ( Object obj ) : string
obj Object Object.
return string
        public static string GetAssetPath(Object obj)
        {
            if (obj == null)
                return string.Empty;

            return AssetDatabase.GetAssetPath(obj);
        }

Same methods

SPTools::GetAssetPath ( Texture2D texture ) : string

Usage Example

Beispiel #1
0
        /// <summary>
        /// Filters the resources for atlas import.
        /// </summary>
        /// <returns>The resources for atlas import.</returns>
        /// <param name="resources">Resources.</param>
        public static Object[] FilterResourcesForAtlasImport(Object[] resources)
        {
            List <Object> tempList = new List <Object>();

            foreach (Object resource in resources)
            {
                string resourcePath = SPTools.GetAssetPath(resource);

                // Check if this is a main asset and queue all it's sub assets
                if (SPTools.IsMainAsset(resource) && SPTools.HasSubAssets(resource))
                {
                    Object[] subAssets = SPTools.FilterResourcesForAtlasImport(SPTools.GetSubAssets(resource));

                    foreach (Object a in subAssets)
                    {
                        tempList.Add(a);
                    }
                }
                else if (resource is Texture2D || resource is Sprite)
                {
                    tempList.Add(resource);
                }
                else if (SPTools.IsDirectory(resourcePath))
                {
                    Object[] subAssets = SPTools.FilterResourcesForAtlasImport(SPTools.GetDirectoryAssets(resourcePath));

                    foreach (Object a in subAssets)
                    {
                        tempList.Add(a);
                    }
                }
            }

            return(tempList.ToArray());
        }
All Usage Examples Of SimpleSpritePackerEditor.SPTools::GetAssetPath