- LocalizationManager: 新增翻译表(SetFormatted/SetDuration/LocalizeOperateMsg) - LoginPanel: InputField placeholder本地化、字体颜色保持 - HistoryPanel: 用时数据本地化、placeholder本地化 - RecordDetailPanel: 操作详情消息本地化(LanguageChanged重建) - AppraiseWindowBase: 评价等级本地化、操作消息重建 - EditorAppraiser: 所有评估消息改用InjectOperateMsgLocalized - StudentOperateRecorder: 新增InjectOperateMsgLocalized方法 - LocalizationLanguageTestBar: 单例模式、ScreenSpaceOverlay筛选 - 字体切换时保留颜色和verticalOverflow
94 lines
2.8 KiB
C#
94 lines
2.8 KiB
C#
using System.Collections;
|
|
using System.Collections.Generic;
|
|
using UnityEngine;
|
|
using UnityEngine.AI;
|
|
using XFramework;
|
|
|
|
public class NavMeshManager : MonoBehaviour
|
|
{
|
|
public Transform targetPoints;
|
|
public LineRenderer lineRenderer;
|
|
NavMeshAgent meshAgent;
|
|
|
|
bool showLine= false;
|
|
// Start is called before the first frame update
|
|
void Start()
|
|
{
|
|
meshAgent = this.transform.GetOrAddComponent<NavMeshAgent>();
|
|
if (showLine)
|
|
{
|
|
lineRenderer = new GameObject("LineRenderer").transform.GetOrAddComponent<LineRenderer>();
|
|
}
|
|
}
|
|
|
|
/// <summary>
|
|
/// 设置待寻路的起点
|
|
/// </summary>
|
|
/// <param name="startPos"></param>
|
|
public void SetStartPos(Vector3 startPos)
|
|
{
|
|
if(meshAgent==null)
|
|
meshAgent = this.transform.GetOrAddComponent<NavMeshAgent>();
|
|
meshAgent.enabled = false;
|
|
this.transform.position = startPos;
|
|
meshAgent.enabled = true;
|
|
|
|
//if (!meshAgent.isOnNavMesh)
|
|
// meshAgent.Warp(this.transform.position);
|
|
}
|
|
|
|
/// <summary>
|
|
/// 设置待寻路的终点 并返回该点位置是否可达 返回数组为空时代表不可达
|
|
/// </summary>
|
|
/// <param name="postion">终点位置</param>
|
|
public Vector3[] SetTargetPointPostion(Vector3 postion)
|
|
{
|
|
NavMeshPath meshPath = new NavMeshPath();
|
|
meshAgent.CalculatePath(postion, meshPath);
|
|
|
|
if (meshPath.status == NavMeshPathStatus.PathComplete)
|
|
{
|
|
meshAgent.enabled = false;
|
|
this.transform.position = postion;
|
|
meshAgent.enabled = true;
|
|
if (lineRenderer)
|
|
{
|
|
lineRenderer.positionCount = meshPath.corners.Length;
|
|
lineRenderer.SetPositions(meshPath.corners);
|
|
}
|
|
return meshPath.corners;
|
|
}
|
|
else
|
|
{
|
|
return null;
|
|
}
|
|
|
|
}
|
|
|
|
|
|
// Update is called once per frame
|
|
void Update()
|
|
{
|
|
//if (Input.GetKeyDown(KeyCode.Space))
|
|
//{
|
|
// //meshAgent.destination = targetPoints.position;
|
|
// // Debug.Log("hasPath:" + meshAgent.hasPath);
|
|
// NavMeshPath meshPath = new NavMeshPath();
|
|
// meshAgent.CalculatePath(targetPoints.position, meshPath);
|
|
// if (meshPath.status == NavMeshPathStatus.PathComplete)
|
|
// {
|
|
// Debug.Log("该路点可达");
|
|
// lineRenderer.LineCount = meshPath.corners.Length;
|
|
// lineRenderer.lineRenderer.SetPositions(meshPath.corners);
|
|
// }
|
|
// //for (int i = 0; i < meshAgent.path.corners.Length; i++)
|
|
// //{
|
|
// // lineRenderer.AddPostion(meshAgent.path.corners[i]);
|
|
// //}
|
|
|
|
//}
|
|
|
|
|
|
}
|
|
}
|