コード例 #1
0
    // Loads up a Texture2D with the image at the given path
    public static IEnumerator textureFromFileAtPath( string filePath, EceteraTextureDelegate del, EceteraTextureFailedDelegate errorDel )
    {
        using( WWW www = new WWW( filePath ) )
        {
            yield return www;

            if( www.error != null )
            {
                if( errorDel != null )
                    errorDel( www.error );
            }

            // Assign the texture to a local variable to avoid leaking it (Unity bug)
            Texture2D tex = www.texture;

            if( tex != null )
                del( tex );
        }
    }
コード例 #2
0
    // Loads up a Texture2D with the image at the given path
    public static IEnumerator textureFromFileAtPath(string filePath, EceteraTextureDelegate del, EceteraTextureFailedDelegate errorDel)
    {
        using (WWW www = new WWW(filePath))
        {
            yield return(www);

            if (www.error != null)
            {
                if (errorDel != null)
                {
                    errorDel(www.error);
                }
            }

            // Assign the texture to a local variable to avoid leaking it (Unity bug)
            Texture2D tex = www.texture;

            if (tex != null)
            {
                del(tex);
            }
        }
    }