编队系统重置 选角页面基本完成 等待存入playerprefs

This commit is contained in:
FloatGaming
2025-12-07 12:04:21 +08:00
parent 941b294fce
commit c0a822b958
134 changed files with 14796 additions and 198 deletions
+50
View File
@@ -0,0 +1,50 @@
using UnityEngine;
using UnityEngine.UI;
namespace Utils
{
public static class DragGhost
{
private static GameObject ghost;
private static Image ghostImage;
private static Canvas parentCanvas;
// Ensure ghost exists under given canvas
public static void Show(Canvas canvas, Sprite sprite)
{
if (canvas == null || sprite == null) return;
if (ghost == null || parentCanvas != canvas)
{
if (ghost != null) Object.Destroy(ghost);
parentCanvas = canvas;
ghost = new GameObject("_SharedDragGhost");
ghost.transform.SetParent(parentCanvas.transform, false);
ghostImage = ghost.AddComponent<Image>();
ghostImage.raycastTarget = false;
var cg = ghost.AddComponent<CanvasGroup>();
cg.blocksRaycasts = false;
}
ghostImage.sprite = sprite;
// set size to sprite rect (avoid SetNativeSize to reduce layout work)
var rt = ghostImage.rectTransform;
rt.sizeDelta = new Vector2(sprite.rect.width, sprite.rect.height);
ghost.SetActive(true);
}
public static void Hide()
{
if (ghost != null) ghost.SetActive(false);
}
public static void UpdatePosition(Vector2 screenPosition, Camera cam)
{
if (ghost == null || parentCanvas == null) return;
RectTransformUtility.ScreenPointToLocalPointInRectangle(
parentCanvas.transform as RectTransform,
screenPosition,
cam,
out Vector2 localPoint);
ghost.transform.localPosition = localPoint;
}
}
}