1. 总体层次设计
- 放在HUD下

- Compass脚本:

using System.Collections.Generic;
using Unity.FPS.Game;
using Unity.FPS.Gameplay;
using UnityEngine;
namespace Unity.FPS.UI
{
public class Compass : MonoBehaviour
{
public RectTransform CompasRect;
public float VisibilityAngle = 180f;
public float HeightDifferenceMultiplier = 2f;
public float MinScale = 0.5f;
public float DistanceMinScale = 50f;
public float CompasMarginRatio = 0.8f;
public GameObject MarkerDirectionPrefab;
Transform m_PlayerTransform;
Dictionary<Transform, CompassMarker> m_ElementsDictionnary = new Dictionary<Transform, CompassMarker>();
float m_WidthMultiplier;
float m_HeightOffset;
void Awake()
{
PlayerCharacterController playerCharacterController = FindObjectOfType<PlayerCharacterController>();
DebugUtility.HandleErrorIfNullFindObject<PlayerCharacterController, Compass>(playerCharacterController,
this);
m_PlayerTransform = playerCharacterController.transform;
m_WidthMultiplier = CompasRect.rect.width / VisibilityAngle;
m_HeightOffset = -CompasRect.rect.height / 2;
}
void Update()
{