添加指引系统,退出APP功能,安徽宿州砀山古城商业街苏州场景

This commit is contained in:
ZYT
2025-12-06 11:38:05 +08:00
parent 488197692e
commit a05d8a18d2
52 changed files with 2980 additions and 819 deletions

View File

@@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: ab89cc5a9acefa34db85ad4749b51af8
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,102 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class GuideArrowPath : MonoBehaviour
{
public LayerMask obstacleMask;
public float pathHeight = 0.5f;
private LineRenderer lineRenderer;
private bool isPathVisible = false;
void Awake()
{
// 从预制体上获取已存在的LineRenderer组件
lineRenderer = GetComponent<LineRenderer>();
if (lineRenderer == null)
{
Debug.LogError("LineRenderer组件未找到请确保预制体上已挂载LineRenderer组件");
return;
}
// 预制体上已预设LineRenderer属性这里不再动态设置
// 如果需要在代码中覆盖预制体设置,可以取消注释以下代码
/*
lineRenderer.startWidth = 0.1f;
lineRenderer.endWidth = 0.1f;
lineRenderer.material = new Material(Shader.Find("Sprites/Default"));
lineRenderer.startColor = Color.yellow;
lineRenderer.endColor = Color.red;
*/
lineRenderer.positionCount = 0;
lineRenderer.enabled = false; // 初始禁用
Debug.Log("GuideArrowPath 初始化完成LineRenderer: " + (lineRenderer != null));
}
/// <summary>
/// 设置路径
/// </summary>
public void SetPath(List<Vector3> pathPoints)
{
if (lineRenderer == null)
{
Debug.LogError("LineRenderer 未找到!");
return;
}
if (pathPoints == null || pathPoints.Count < 2)
{
lineRenderer.positionCount = 0;
return;
}
// 调整路径点高度
for (int i = 0; i < pathPoints.Count; i++)
{
pathPoints[i] = new Vector3(pathPoints[i].x, pathHeight, pathPoints[i].z);
}
lineRenderer.positionCount = pathPoints.Count;
lineRenderer.SetPositions(pathPoints.ToArray());
Debug.Log("设置路径,点数: " + pathPoints.Count);
}
/// <summary>
/// 显示路径
/// </summary>
public void ShowPath()
{
if (lineRenderer != null)
{
lineRenderer.enabled = true;
isPathVisible = true;
Debug.Log("显示路径LineRenderer enabled: " + lineRenderer.enabled);
}
}
/// <summary>
/// 关闭路径
/// </summary>
public void ClosePath()
{
if (lineRenderer != null)
{
lineRenderer.enabled = false;
isPathVisible = false;
lineRenderer.positionCount = 0;
Debug.Log("关闭路径");
}
}
/// <summary>
/// 检查路径是否可见
/// </summary>
public bool IsPathVisible()
{
return isPathVisible && lineRenderer != null && lineRenderer.enabled;
}
}

View File

@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 8cdda35296b966646ada44468a5c40c5
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant: