Files
MinFt/Client/Assets/Scripts/UI/UIImage.cs
Liubing\LB 3d8d4d18f3 first commit
先修复一下,错误的场景

删除不必要的钓场资产

修复into场景

update:更新meta文件,修复报错

update:修复资源

修复第一章节建造

修复建造第三章

update:删除多余内容

update:更新README.md

update:还原图标

update:更新README

update:更新配置
2026-04-28 02:17:22 +08:00

62 lines
1.5 KiB
C#
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
using asap.core;
using UnityEngine;
using UnityEngine.UI;
public class UIImage : Image
{
ShowImageData imageData;
IUIService uiService;
public void Sprite(string spriteName)
{
if (imageData == null)
{
imageData = new ShowImageData(this);
}
if (uiService == null)
{
uiService = GContext.container.Resolve<IUIService>();
}
if (uiService != null)
{
imageData.SetName(spriteName);
uiService.SetImageSprite(imageData);
}
else
{
Debug.LogError("IUIService is not resolved.");
}
}
}
public class ShowImageData : IShowImageData
{
public string spriteName { set; get; }
public Image image { set; get; }
string otherName;
/// <summary>
/// image 赋值必须新new一个对象防止sprite 给的一个错误的对象
/// </summary>
/// <param name="image"></param>
public ShowImageData(Image image)
{
this.image = image;
}
public ShowImageData(Image image, string spriteName)
{
this.image = image;
SetName(spriteName);
}
public void SetName(string spriteName)
{
this.spriteName = spriteName;
otherName = spriteName + "(Clone)";
}
public void SetImage(Sprite sprite)
{
if (image != null && (sprite.name == otherName || sprite.name == spriteName))
{
image.sprite = sprite;
}
}
}