chicken_dy/Assets/WX-WASM-SDK/UnityMarkdownViewer/Editor/Scripts/Layout/ContentImage.cs

32 lines
793 B
C#
Raw Normal View History

2022-07-27 13:57:29 +00:00
using UnityEngine;
namespace WeChatWASM.MDV
{
public class ContentImage : Content
{
public string URL;
public string Alt;
public ContentImage( GUIContent payload, Style style, string link )
: base( payload, style, link )
{
}
public override void Update( Context context )
{
Payload.image = context.FetchImage( URL );
Payload.text = null;
if( Payload.image == null )
{
context.Apply( Style );
var text = !string.IsNullOrEmpty( Alt ) ? Alt : URL;
Payload.text = string.Format( "[{0}]", text );
}
Location.size = context.CalcSize( Payload );
}
}
}