CreateBlankTexture() public static method

Creates a blank atlas texture.
public static CreateBlankTexture ( string path, bool alphaTransparency ) : bool
path string Asset Path.
alphaTransparency bool If set to true alpha transparency.
return bool
示例#1
0
        public static void CreateInstance()
        {
            string assetPath = GetSavePath();

            if (string.IsNullOrEmpty(assetPath))
            {
                return;
            }

            // Create the sprite packer instance
            SPInstance asset = ScriptableObject.CreateInstance("SPInstance") as SPInstance;

            AssetDatabase.CreateAsset(asset, AssetDatabase.GenerateUniqueAssetPath(assetPath));
            AssetDatabase.Refresh();

            // Save the instance id in the editor prefs
            EditorPrefs.SetInt(SPTools.Settings_SavedInstanceIDKey, asset.GetInstanceID());

            // Repaint the SPDropWindow
            EditorWindow.GetWindow(typeof(SPDropWindow)).Repaint();

            // Get a name for the texture
            string texturePath = assetPath.Replace(".asset", ".png");

            // Create blank texture
            if (SPTools.CreateBlankTexture(texturePath, true))
            {
                // Set the texture reff in the sprite packer instance
                asset.texture = AssetDatabase.LoadAssetAtPath(texturePath, typeof(Texture2D)) as Texture2D;
            }

            // Focus on the new sprite packer
            EditorUtility.FocusProjectWindow();
            Selection.activeObject = asset;
        }