This commit is contained in:
yaoyanwei
2025-08-04 16:45:48 +08:00
parent 565aa16389
commit 2f2a601227
2296 changed files with 522745 additions and 93 deletions

View File

@@ -0,0 +1,58 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using TcgEngine.Client;
namespace TcgEngine.FX
{
/// <summary>
/// Rotate FX to face camera
/// </summary>
public class FaceFX : MonoBehaviour
{
public FaceType type;
void Start()
{
Vector3 up = GameBoard.Get().transform.up;
if (type == FaceType.FaceCamera)
{
GameCamera cam = GameCamera.Get();
if (cam != null)
{
Vector3 forward = cam.transform.forward;
transform.rotation = Quaternion.LookRotation(forward, up);
}
}
if (type == FaceType.FaceCameraCenter)
{
GameCamera cam = GameCamera.Get();
if (cam != null)
{
Vector3 forward = transform.position - cam.transform.position;
transform.rotation = Quaternion.LookRotation(forward.normalized, up);
}
}
if (type == FaceType.FaceBoard)
{
GameBoard board = GameBoard.Get();
if (board != null)
{
Vector3 forward = board.transform.forward;
transform.rotation = Quaternion.LookRotation(forward, up);
}
}
}
}
public enum FaceType
{
FaceCamera = 0, //Set same rotation as camera rotation
FaceCameraCenter = 5, //Face camera world position
FaceBoard = 10 //Set same rotation as to board rotation
}
}