PersistentTrails.Utilities.LoadImage C# (CSharp) Method

LoadImage() public static method

public static LoadImage ( string filename, int width, int height ) : Texture2D
filename string
width int
height int
return UnityEngine.Texture2D
        public static Texture2D LoadImage(string filename, int width, int height)
        {
            if (File.Exists(PlugInIconPath + filename))
            {
                var bytes = File.ReadAllBytes(PlugInIconPath + filename);
                //Debug.Log("image bytes read");
                Texture2D texture = new Texture2D(width, height, TextureFormat.ARGB32, false);
                //Debug.Log("texture created");
                texture.LoadImage(bytes);
                //Debug.Log("image loaded to texture");
                return texture;
            }
            return null;
        }

Usage Example

 public void Awake()
 {
     playTex  = Utilities.LoadImage("play.png", 24, 24);
     pauseTex = Utilities.LoadImage("pause.png", 24, 24);;
     ffTex    = Utilities.LoadImage("ff2.png", 24, 24);;
     stopTex  = Utilities.LoadImage("stop.png", 24, 24);
 }
All Usage Examples Of PersistentTrails.Utilities::LoadImage